Chris@0
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@0
|
2
|
Chris@0
|
3 /*
|
Chris@0
|
4 Tony
|
Chris@0
|
5 An intonation analysis and annotation tool
|
Chris@0
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@0
|
7 This file copyright 2006-2012 Chris Cannam and QMUL.
|
Chris@0
|
8
|
Chris@0
|
9 This program is free software; you can redistribute it and/or
|
Chris@0
|
10 modify it under the terms of the GNU General Public License as
|
Chris@0
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@0
|
12 License, or (at your option) any later version. See the file
|
Chris@0
|
13 COPYING included with this distribution for more information.
|
Chris@0
|
14 */
|
Chris@0
|
15
|
Chris@0
|
16 #include "../version.h"
|
Chris@0
|
17
|
Chris@0
|
18 #include "MainWindow.h"
|
Chris@95
|
19 #include "NetworkPermissionTester.h"
|
Chris@6
|
20 #include "Analyser.h"
|
Chris@6
|
21
|
Chris@0
|
22 #include "framework/Document.h"
|
Chris@95
|
23 #include "framework/VersionTester.h"
|
Chris@0
|
24
|
Chris@0
|
25 #include "view/Pane.h"
|
Chris@0
|
26 #include "view/PaneStack.h"
|
Chris@0
|
27 #include "data/model/WaveFileModel.h"
|
matthiasm@26
|
28 #include "data/model/NoteModel.h"
|
matthiasm@26
|
29 #include "data/model/FlexiNoteModel.h"
|
matthiasm@42
|
30 #include "layer/FlexiNoteLayer.h"
|
matthiasm@26
|
31 #include "data/model/NoteModel.h"
|
Chris@0
|
32 #include "view/ViewManager.h"
|
Chris@0
|
33 #include "base/Preferences.h"
|
Chris@404
|
34 #include "base/AudioLevel.h"
|
Chris@0
|
35 #include "layer/WaveformLayer.h"
|
Chris@0
|
36 #include "layer/TimeInstantLayer.h"
|
Chris@0
|
37 #include "layer/TimeValueLayer.h"
|
Chris@192
|
38 #include "layer/SpectrogramLayer.h"
|
Chris@0
|
39 #include "widgets/Fader.h"
|
Chris@0
|
40 #include "view/Overview.h"
|
Chris@0
|
41 #include "widgets/AudioDial.h"
|
Chris@0
|
42 #include "widgets/IconLoader.h"
|
Chris@0
|
43 #include "widgets/KeyReference.h"
|
Chris@404
|
44 #include "widgets/LevelPanWidget.h"
|
Chris@0
|
45 #include "audioio/AudioCallbackPlaySource.h"
|
Chris@0
|
46 #include "audioio/AudioCallbackPlayTarget.h"
|
Chris@0
|
47 #include "audioio/PlaySpeedRangeMapper.h"
|
Chris@0
|
48 #include "base/Profiler.h"
|
Chris@0
|
49 #include "base/UnitDatabase.h"
|
Chris@0
|
50 #include "layer/ColourDatabase.h"
|
Chris@139
|
51 #include "base/Selection.h"
|
Chris@0
|
52
|
Chris@174
|
53 #include "rdf/RDFImporter.h"
|
Chris@174
|
54 #include "data/fileio/DataFileReaderFactory.h"
|
Chris@174
|
55 #include "data/fileio/CSVFormat.h"
|
matthiasm@26
|
56 #include "data/fileio/CSVFileWriter.h"
|
matthiasm@26
|
57 #include "data/fileio/MIDIFileWriter.h"
|
matthiasm@26
|
58 #include "rdf/RDFExporter.h"
|
matthiasm@26
|
59
|
Chris@227
|
60 #include "widgets/RangeInputDialog.h"
|
Chris@244
|
61 #include "widgets/ActivityLog.h"
|
Chris@227
|
62
|
Chris@0
|
63 // For version information
|
Chris@0
|
64 #include "vamp/vamp.h"
|
Chris@0
|
65 #include "vamp-sdk/PluginBase.h"
|
Chris@0
|
66 #include "plugin/api/ladspa.h"
|
Chris@0
|
67 #include "plugin/api/dssi.h"
|
Chris@0
|
68
|
Chris@0
|
69 #include <QApplication>
|
Chris@0
|
70 #include <QMessageBox>
|
Chris@0
|
71 #include <QGridLayout>
|
Chris@0
|
72 #include <QLabel>
|
Chris@0
|
73 #include <QMenuBar>
|
Chris@0
|
74 #include <QToolBar>
|
Chris@0
|
75 #include <QToolButton>
|
Chris@0
|
76 #include <QInputDialog>
|
Chris@0
|
77 #include <QStatusBar>
|
Chris@0
|
78 #include <QFileInfo>
|
Chris@0
|
79 #include <QDir>
|
Chris@0
|
80 #include <QProcess>
|
Chris@2
|
81 #include <QPushButton>
|
Chris@0
|
82 #include <QSettings>
|
Chris@0
|
83 #include <QScrollArea>
|
Chris@128
|
84 #include <QPainter>
|
Chris@0
|
85
|
Chris@0
|
86 #include <iostream>
|
Chris@0
|
87 #include <cstdio>
|
Chris@0
|
88 #include <errno.h>
|
Chris@0
|
89
|
Chris@0
|
90 using std::vector;
|
Chris@0
|
91
|
Chris@0
|
92
|
matthiasm@364
|
93 MainWindow::MainWindow(bool withAudioOutput, bool withSonification, bool withSpectrogram) :
|
Chris@277
|
94 MainWindowBase(withAudioOutput, false),
|
Chris@0
|
95 m_overview(0),
|
Chris@0
|
96 m_mainMenusCreated(false),
|
Chris@0
|
97 m_playbackMenu(0),
|
gyorgyf@45
|
98 m_recentFilesMenu(0),
|
Chris@0
|
99 m_rightButtonMenu(0),
|
Chris@0
|
100 m_rightButtonPlaybackMenu(0),
|
Chris@0
|
101 m_deleteSelectedAction(0),
|
Chris@0
|
102 m_ffwdAction(0),
|
Chris@0
|
103 m_rwdAction(0),
|
Chris@168
|
104 m_intelligentActionOn(true), //GF: !!! temporary
|
Chris@244
|
105 m_activityLog(new ActivityLog()),
|
matthiasm@296
|
106 m_keyReference(new KeyReference()),
|
matthiasm@364
|
107 m_selectionAnchor(0),
|
matthiasm@364
|
108 m_withSonification(withSonification),
|
matthiasm@364
|
109 m_withSpectrogram(withSpectrogram)
|
Chris@0
|
110 {
|
Chris@0
|
111 setWindowTitle(QApplication::applicationName());
|
Chris@0
|
112
|
Chris@206
|
113 #ifdef Q_OS_MAC
|
Chris@206
|
114 #if (QT_VERSION >= QT_VERSION_CHECK(5, 2, 0))
|
Chris@206
|
115 setUnifiedTitleAndToolBarOnMac(true);
|
Chris@206
|
116 #endif
|
Chris@206
|
117 #endif
|
Chris@206
|
118
|
Chris@0
|
119 UnitDatabase *udb = UnitDatabase::getInstance();
|
Chris@0
|
120 udb->registerUnit("Hz");
|
Chris@0
|
121 udb->registerUnit("dB");
|
Chris@0
|
122 udb->registerUnit("s");
|
Chris@0
|
123
|
Chris@0
|
124 ColourDatabase *cdb = ColourDatabase::getInstance();
|
Chris@0
|
125 cdb->addColour(Qt::black, tr("Black"));
|
Chris@0
|
126 cdb->addColour(Qt::darkRed, tr("Red"));
|
Chris@0
|
127 cdb->addColour(Qt::darkBlue, tr("Blue"));
|
Chris@0
|
128 cdb->addColour(Qt::darkGreen, tr("Green"));
|
Chris@0
|
129 cdb->addColour(QColor(200, 50, 255), tr("Purple"));
|
Chris@0
|
130 cdb->addColour(QColor(255, 150, 50), tr("Orange"));
|
Chris@120
|
131 cdb->addColour(QColor(180, 180, 180), tr("Grey"));
|
Chris@0
|
132 cdb->setUseDarkBackground(cdb->addColour(Qt::white, tr("White")), true);
|
Chris@0
|
133 cdb->setUseDarkBackground(cdb->addColour(Qt::red, tr("Bright Red")), true);
|
Chris@0
|
134 cdb->setUseDarkBackground(cdb->addColour(QColor(30, 150, 255), tr("Bright Blue")), true);
|
Chris@0
|
135 cdb->setUseDarkBackground(cdb->addColour(Qt::green, tr("Bright Green")), true);
|
Chris@0
|
136 cdb->setUseDarkBackground(cdb->addColour(QColor(225, 74, 255), tr("Bright Purple")), true);
|
Chris@0
|
137 cdb->setUseDarkBackground(cdb->addColour(QColor(255, 188, 80), tr("Bright Orange")), true);
|
Chris@0
|
138
|
Chris@0
|
139 Preferences::getInstance()->setResampleOnLoad(true);
|
Chris@315
|
140 Preferences::getInstance()->setFixedSampleRate(44100);
|
Chris@0
|
141 Preferences::getInstance()->setSpectrogramSmoothing
|
Chris@0
|
142 (Preferences::SpectrogramInterpolated);
|
Chris@332
|
143 Preferences::getInstance()->setNormaliseAudio(true);
|
Chris@0
|
144
|
Chris@0
|
145 QSettings settings;
|
Chris@0
|
146
|
Chris@0
|
147 settings.beginGroup("MainWindow");
|
Chris@0
|
148 settings.setValue("showstatusbar", false);
|
Chris@0
|
149 settings.endGroup();
|
Chris@0
|
150
|
Chris@96
|
151 settings.beginGroup("Transformer");
|
Chris@96
|
152 settings.setValue("use-flexi-note-model", true);
|
Chris@96
|
153 settings.endGroup();
|
Chris@96
|
154
|
Chris@73
|
155 settings.beginGroup("LayerDefaults");
|
Chris@73
|
156 settings.setValue("waveform",
|
Chris@73
|
157 QString("<layer scale=\"%1\" channelMode=\"%2\"/>")
|
Chris@73
|
158 .arg(int(WaveformLayer::LinearScale))
|
Chris@73
|
159 .arg(int(WaveformLayer::MixChannels)));
|
Chris@73
|
160 settings.endGroup();
|
Chris@73
|
161
|
Chris@6
|
162 m_viewManager->setAlignMode(false);
|
Chris@6
|
163 m_viewManager->setPlaySoloMode(false);
|
Chris@392
|
164 m_viewManager->setToolMode(ViewManager::NavigateMode);
|
Chris@0
|
165 m_viewManager->setZoomWheelsEnabled(false);
|
Chris@6
|
166 m_viewManager->setIlluminateLocalFeatures(true);
|
matthiasm@368
|
167 m_viewManager->setShowWorkTitle(false);
|
Chris@6
|
168 m_viewManager->setShowCentreLine(false);
|
matthiasm@368
|
169 m_viewManager->setShowDuration(false);
|
Chris@213
|
170 m_viewManager->setOverlayMode(ViewManager::GlobalOverlays);
|
Chris@0
|
171
|
Chris@192
|
172 connect(m_viewManager, SIGNAL(selectionChangedByUser()),
|
Chris@192
|
173 this, SLOT(selectionChangedByUser()));
|
Chris@164
|
174
|
Chris@0
|
175 QFrame *frame = new QFrame;
|
Chris@0
|
176 setCentralWidget(frame);
|
Chris@0
|
177
|
Chris@0
|
178 QGridLayout *layout = new QGridLayout;
|
Chris@0
|
179
|
Chris@0
|
180 QScrollArea *scroll = new QScrollArea(frame);
|
Chris@0
|
181 scroll->setWidgetResizable(true);
|
Chris@0
|
182 scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
Chris@0
|
183 scroll->setFrameShape(QFrame::NoFrame);
|
Chris@0
|
184
|
Chris@6
|
185 // We have a pane stack: it comes with the territory. However, we
|
Chris@120
|
186 // have a fixed and known number of panes in it -- it isn't
|
Chris@120
|
187 // variable
|
Chris@0
|
188 m_paneStack->setLayoutStyle(PaneStack::NoPropertyStacks);
|
Chris@137
|
189 m_paneStack->setShowPaneAccessories(false);
|
Chris@399
|
190 connect(m_paneStack, SIGNAL(doubleClickSelectInvoked(sv_frame_t)),
|
Chris@399
|
191 this, SLOT(doubleClickSelectInvoked(sv_frame_t)));
|
Chris@0
|
192 scroll->setWidget(m_paneStack);
|
Chris@6
|
193
|
Chris@0
|
194 m_overview = new Overview(frame);
|
Chris@362
|
195 m_overview->setPlaybackFollow(PlaybackScrollPage);
|
Chris@0
|
196 m_overview->setViewManager(m_viewManager);
|
Chris@393
|
197 m_overview->setFixedHeight(60);
|
Chris@0
|
198 #ifndef _WIN32
|
Chris@0
|
199 // For some reason, the contents of the overview never appear if we
|
Chris@0
|
200 // make this setting on Windows. I have no inclination at the moment
|
Chris@0
|
201 // to track down the reason why.
|
Chris@0
|
202 m_overview->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
|
Chris@0
|
203 #endif
|
Chris@0
|
204 connect(m_overview, SIGNAL(contextHelpChanged(const QString &)),
|
Chris@0
|
205 this, SLOT(contextHelpChanged(const QString &)));
|
Chris@0
|
206
|
Chris@0
|
207 m_panLayer = new WaveformLayer;
|
Chris@0
|
208 m_panLayer->setChannelMode(WaveformLayer::MergeChannels);
|
Chris@0
|
209 m_panLayer->setAggressiveCacheing(true);
|
Chris@393
|
210 m_panLayer->setGain(0.5);
|
Chris@0
|
211 m_overview->addLayer(m_panLayer);
|
Chris@0
|
212
|
Chris@0
|
213 if (m_viewManager->getGlobalDarkBackground()) {
|
Chris@0
|
214 m_panLayer->setBaseColour
|
Chris@0
|
215 (ColourDatabase::getInstance()->getColourIndex(tr("Bright Green")));
|
Chris@0
|
216 } else {
|
Chris@0
|
217 m_panLayer->setBaseColour
|
matthiasm@13
|
218 (ColourDatabase::getInstance()->getColourIndex(tr("Blue")));
|
Chris@0
|
219 }
|
Chris@0
|
220
|
Chris@0
|
221 m_fader = new Fader(frame, false);
|
Chris@0
|
222 connect(m_fader, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
Chris@0
|
223 connect(m_fader, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
Chris@0
|
224
|
Chris@0
|
225 m_playSpeed = new AudioDial(frame);
|
Chris@343
|
226 m_playSpeed->setMeterColor(Qt::darkBlue);
|
Chris@0
|
227 m_playSpeed->setMinimum(0);
|
Chris@0
|
228 m_playSpeed->setMaximum(200);
|
Chris@0
|
229 m_playSpeed->setValue(100);
|
Chris@0
|
230 m_playSpeed->setFixedWidth(24);
|
Chris@0
|
231 m_playSpeed->setFixedHeight(24);
|
Chris@0
|
232 m_playSpeed->setNotchesVisible(true);
|
Chris@0
|
233 m_playSpeed->setPageStep(10);
|
Chris@0
|
234 m_playSpeed->setObjectName(tr("Playback Speedup"));
|
Chris@0
|
235 m_playSpeed->setDefaultValue(100);
|
Chris@0
|
236 m_playSpeed->setRangeMapper(new PlaySpeedRangeMapper(0, 200));
|
Chris@0
|
237 m_playSpeed->setShowToolTip(true);
|
Chris@0
|
238 connect(m_playSpeed, SIGNAL(valueChanged(int)),
|
gyorgyf@27
|
239 this, SLOT(playSpeedChanged(int)));
|
Chris@0
|
240 connect(m_playSpeed, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
Chris@0
|
241 connect(m_playSpeed, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
Chris@0
|
242
|
Chris@404
|
243 m_audioLPW = new LevelPanWidget(frame);
|
Chris@404
|
244 m_audioLPW->setObjectName(tr("Audio Track Level and Pan"));
|
Chris@404
|
245 m_audioLPW->setPan(-1);
|
Chris@404
|
246 connect(m_audioLPW, SIGNAL(levelChanged(float)), this, SLOT(audioGainChanged(float)));
|
Chris@404
|
247 connect(m_audioLPW, SIGNAL(panChanged(float)), this, SLOT(audioPanChanged(float)));
|
Chris@404
|
248
|
Chris@404
|
249 if (m_withSonification) {
|
Chris@404
|
250
|
Chris@404
|
251 m_pitchLPW = new LevelPanWidget(frame);
|
Chris@404
|
252 m_pitchLPW->setObjectName(tr("Pitch Track Level and Pan"));
|
Chris@404
|
253 m_pitchLPW->setPan(1);
|
Chris@404
|
254 connect(m_pitchLPW, SIGNAL(levelChanged(float)), this, SLOT(pitchGainChanged(float)));
|
Chris@404
|
255 connect(m_pitchLPW, SIGNAL(panChanged(float)), this, SLOT(pitchPanChanged(float)));
|
Chris@404
|
256
|
Chris@404
|
257 m_notesLPW = new LevelPanWidget(frame);
|
Chris@404
|
258 m_notesLPW->setObjectName(tr("Note Track Level and Pan"));
|
Chris@404
|
259 m_notesLPW->setPan(1);
|
Chris@404
|
260 connect(m_notesLPW, SIGNAL(levelChanged(float)), this, SLOT(notesGainChanged(float)));
|
Chris@404
|
261 connect(m_notesLPW, SIGNAL(panChanged(float)), this, SLOT(notesPanChanged(float)));
|
matthiasm@366
|
262 }
|
justin@160
|
263
|
Chris@0
|
264 layout->setSpacing(4);
|
Chris@6
|
265 layout->addWidget(m_overview, 0, 1);
|
Chris@6
|
266 layout->addWidget(scroll, 1, 1);
|
Chris@0
|
267
|
Chris@0
|
268 layout->setColumnStretch(1, 10);
|
Chris@0
|
269
|
Chris@0
|
270 frame->setLayout(layout);
|
Chris@0
|
271
|
gyorgyf@21
|
272 m_analyser = new Analyser();
|
Chris@128
|
273 connect(m_analyser, SIGNAL(layersChanged()),
|
Chris@128
|
274 this, SLOT(updateLayerStatuses()));
|
Chris@187
|
275 connect(m_analyser, SIGNAL(layersChanged()),
|
Chris@187
|
276 this, SLOT(updateMenuStates()));
|
gyorgyf@21
|
277
|
Chris@0
|
278 setupMenus();
|
Chris@0
|
279 setupToolbars();
|
Chris@0
|
280 setupHelpMenu();
|
Chris@0
|
281
|
Chris@0
|
282 statusBar();
|
Chris@0
|
283
|
Chris@288
|
284 finaliseMenus();
|
Chris@288
|
285
|
Chris@244
|
286 connect(m_viewManager, SIGNAL(activity(QString)),
|
Chris@244
|
287 m_activityLog, SLOT(activityHappened(QString)));
|
Chris@244
|
288 connect(m_playSource, SIGNAL(activity(QString)),
|
Chris@244
|
289 m_activityLog, SLOT(activityHappened(QString)));
|
Chris@244
|
290 connect(CommandHistory::getInstance(), SIGNAL(activity(QString)),
|
Chris@244
|
291 m_activityLog, SLOT(activityHappened(QString)));
|
Chris@244
|
292 connect(this, SIGNAL(activity(QString)),
|
Chris@244
|
293 m_activityLog, SLOT(activityHappened(QString)));
|
Chris@244
|
294 connect(this, SIGNAL(replacedDocument()), this, SLOT(documentReplaced()));
|
Chris@260
|
295 connect(this, SIGNAL(sessionLoaded()), this, SLOT(analyseNewMainModel()));
|
Chris@260
|
296 connect(this, SIGNAL(audioFileLoaded()), this, SLOT(analyseNewMainModel()));
|
Chris@244
|
297 m_activityLog->hide();
|
Chris@244
|
298
|
Chris@95
|
299 newSession();
|
Chris@6
|
300
|
Chris@95
|
301 settings.beginGroup("MainWindow");
|
Chris@95
|
302 settings.setValue("zoom-default", 512);
|
Chris@95
|
303 settings.endGroup();
|
Chris@95
|
304 zoomDefault();
|
Chris@95
|
305
|
Chris@95
|
306 NetworkPermissionTester tester;
|
Chris@95
|
307 bool networkPermission = tester.havePermission();
|
Chris@95
|
308 if (networkPermission) {
|
Chris@95
|
309 m_versionTester = new VersionTester
|
Chris@95
|
310 ("sonicvisualiser.org", "latest-tony-version.txt", TONY_VERSION);
|
Chris@95
|
311 connect(m_versionTester, SIGNAL(newerVersionAvailable(QString)),
|
Chris@95
|
312 this, SLOT(newerVersionAvailable(QString)));
|
Chris@95
|
313 } else {
|
Chris@95
|
314 m_versionTester = 0;
|
Chris@95
|
315 }
|
Chris@0
|
316 }
|
Chris@0
|
317
|
Chris@0
|
318 MainWindow::~MainWindow()
|
Chris@0
|
319 {
|
Chris@6
|
320 delete m_analyser;
|
Chris@0
|
321 delete m_keyReference;
|
Chris@0
|
322 Profiles::getInstance()->dump();
|
Chris@0
|
323 }
|
Chris@0
|
324
|
Chris@0
|
325 void
|
Chris@0
|
326 MainWindow::setupMenus()
|
Chris@0
|
327 {
|
Chris@0
|
328 if (!m_mainMenusCreated) {
|
Chris@385
|
329
|
Chris@385
|
330 #ifdef Q_OS_LINUX
|
Chris@385
|
331 // In Ubuntu 14.04 the window's menu bar goes missing entirely
|
Chris@385
|
332 // if the user is running any desktop environment other than Unity
|
Chris@385
|
333 // (in which the faux single-menubar appears). The user has a
|
Chris@385
|
334 // workaround, to remove the appmenu-qt5 package, but that is
|
Chris@385
|
335 // awkward and the problem is so severe that it merits disabling
|
Chris@385
|
336 // the system menubar integration altogether. Like this:
|
Chris@385
|
337 menuBar()->setNativeMenuBar(false);
|
Chris@385
|
338 #endif
|
Chris@385
|
339
|
Chris@0
|
340 m_rightButtonMenu = new QMenu();
|
Chris@0
|
341 }
|
Chris@0
|
342
|
Chris@0
|
343 if (!m_mainMenusCreated) {
|
Chris@0
|
344 CommandHistory::getInstance()->registerMenu(m_rightButtonMenu);
|
Chris@0
|
345 m_rightButtonMenu->addSeparator();
|
Chris@0
|
346 }
|
Chris@0
|
347
|
Chris@0
|
348 setupFileMenu();
|
Chris@0
|
349 setupEditMenu();
|
Chris@0
|
350 setupViewMenu();
|
matthiasm@317
|
351 setupAnalysisMenu();
|
Chris@0
|
352
|
Chris@0
|
353 m_mainMenusCreated = true;
|
Chris@0
|
354 }
|
Chris@0
|
355
|
Chris@0
|
356 void
|
Chris@0
|
357 MainWindow::setupFileMenu()
|
Chris@0
|
358 {
|
Chris@0
|
359 if (m_mainMenusCreated) return;
|
Chris@0
|
360
|
Chris@0
|
361 QMenu *menu = menuBar()->addMenu(tr("&File"));
|
Chris@0
|
362 menu->setTearOffEnabled(true);
|
Chris@0
|
363 QToolBar *toolbar = addToolBar(tr("File Toolbar"));
|
Chris@0
|
364
|
Chris@0
|
365 m_keyReference->setCategory(tr("File and Session Management"));
|
Chris@0
|
366
|
Chris@0
|
367 IconLoader il;
|
Chris@1
|
368 QIcon icon;
|
Chris@1
|
369 QAction *action;
|
Chris@0
|
370
|
Chris@0
|
371 icon = il.load("fileopen");
|
Chris@0
|
372 icon.addPixmap(il.loadPixmap("fileopen-22"));
|
Chris@1
|
373 action = new QAction(icon, tr("&Open..."), this);
|
Chris@0
|
374 action->setShortcut(tr("Ctrl+O"));
|
Chris@257
|
375 action->setStatusTip(tr("Open a session or audio file"));
|
Chris@0
|
376 connect(action, SIGNAL(triggered()), this, SLOT(openFile()));
|
Chris@0
|
377 m_keyReference->registerShortcut(action);
|
Chris@0
|
378 menu->addAction(action);
|
Chris@0
|
379 toolbar->addAction(action);
|
Chris@0
|
380
|
Chris@1
|
381 action = new QAction(tr("Open Lo&cation..."), this);
|
Chris@0
|
382 action->setShortcut(tr("Ctrl+Shift+O"));
|
Chris@1
|
383 action->setStatusTip(tr("Open a file from a remote URL"));
|
Chris@0
|
384 connect(action, SIGNAL(triggered()), this, SLOT(openLocation()));
|
Chris@0
|
385 m_keyReference->registerShortcut(action);
|
Chris@0
|
386 menu->addAction(action);
|
Chris@0
|
387
|
Chris@1
|
388 m_recentFilesMenu = menu->addMenu(tr("Open &Recent"));
|
Chris@0
|
389 m_recentFilesMenu->setTearOffEnabled(true);
|
Chris@0
|
390 setupRecentFilesMenu();
|
Chris@0
|
391 connect(&m_recentFiles, SIGNAL(recentChanged()),
|
Chris@0
|
392 this, SLOT(setupRecentFilesMenu()));
|
Chris@0
|
393
|
Chris@0
|
394 menu->addSeparator();
|
Chris@257
|
395
|
Chris@257
|
396 icon = il.load("filesave");
|
Chris@257
|
397 icon.addPixmap(il.loadPixmap("filesave-22"));
|
Chris@257
|
398 action = new QAction(icon, tr("&Save Session"), this);
|
Chris@257
|
399 action->setShortcut(tr("Ctrl+S"));
|
Chris@257
|
400 action->setStatusTip(tr("Save the current session into a %1 session file").arg(QApplication::applicationName()));
|
Chris@257
|
401 connect(action, SIGNAL(triggered()), this, SLOT(saveSession()));
|
Chris@257
|
402 connect(this, SIGNAL(canSave(bool)), action, SLOT(setEnabled(bool)));
|
Chris@257
|
403 m_keyReference->registerShortcut(action);
|
Chris@257
|
404 menu->addAction(action);
|
Chris@257
|
405 toolbar->addAction(action);
|
Chris@257
|
406
|
Chris@257
|
407 icon = il.load("filesaveas");
|
Chris@257
|
408 icon.addPixmap(il.loadPixmap("filesaveas-22"));
|
Chris@257
|
409 action = new QAction(icon, tr("Save Session &As..."), this);
|
Chris@257
|
410 action->setShortcut(tr("Ctrl+Shift+S"));
|
Chris@257
|
411 action->setStatusTip(tr("Save the current session into a new %1 session file").arg(QApplication::applicationName()));
|
Chris@257
|
412 connect(action, SIGNAL(triggered()), this, SLOT(saveSessionAs()));
|
Chris@313
|
413 connect(this, SIGNAL(canSaveAs(bool)), action, SLOT(setEnabled(bool)));
|
Chris@257
|
414 menu->addAction(action);
|
Chris@257
|
415 toolbar->addAction(action);
|
Chris@257
|
416
|
matthiasm@319
|
417 action = new QAction(tr("Save Session to Audio &Path"), this);
|
matthiasm@310
|
418 action->setShortcut(tr("Ctrl+Alt+S"));
|
Chris@313
|
419 action->setStatusTip(tr("Save the current session into a %1 session file with the same filename as the audio but a .ton extension.").arg(QApplication::applicationName()));
|
matthiasm@310
|
420 connect(action, SIGNAL(triggered()), this, SLOT(saveSessionInAudioPath()));
|
Chris@313
|
421 connect(this, SIGNAL(canSaveAs(bool)), action, SLOT(setEnabled(bool)));
|
matthiasm@310
|
422 menu->addAction(action);
|
matthiasm@310
|
423
|
Chris@257
|
424 menu->addSeparator();
|
Chris@257
|
425
|
Chris@253
|
426 action = new QAction(tr("I&mport Pitch Track Data..."), this);
|
Chris@253
|
427 action->setStatusTip(tr("Import pitch-track data from a CSV, RDF, or layer XML file"));
|
Chris@174
|
428 connect(action, SIGNAL(triggered()), this, SLOT(importPitchLayer()));
|
Chris@174
|
429 connect(this, SIGNAL(canImportLayer(bool)), action, SLOT(setEnabled(bool)));
|
Chris@174
|
430 menu->addAction(action);
|
Chris@174
|
431
|
Chris@253
|
432 action = new QAction(tr("E&xport Pitch Track Data..."), this);
|
Chris@253
|
433 action->setStatusTip(tr("Export pitch-track data to a CSV, RDF, or layer XML file"));
|
Chris@85
|
434 connect(action, SIGNAL(triggered()), this, SLOT(exportPitchLayer()));
|
Chris@224
|
435 connect(this, SIGNAL(canExportPitchTrack(bool)), action, SLOT(setEnabled(bool)));
|
Chris@85
|
436 menu->addAction(action);
|
Chris@85
|
437
|
Chris@253
|
438 action = new QAction(tr("&Export Note Data..."), this);
|
Chris@253
|
439 action->setStatusTip(tr("Export note data to a CSV, RDF, layer XML, or MIDI file"));
|
Chris@85
|
440 connect(action, SIGNAL(triggered()), this, SLOT(exportNoteLayer()));
|
Chris@224
|
441 connect(this, SIGNAL(canExportNotes(bool)), action, SLOT(setEnabled(bool)));
|
matthiasm@26
|
442 menu->addAction(action);
|
matthiasm@26
|
443
|
matthiasm@26
|
444 menu->addSeparator();
|
Chris@0
|
445 action = new QAction(il.load("exit"), tr("&Quit"), this);
|
Chris@0
|
446 action->setShortcut(tr("Ctrl+Q"));
|
Chris@0
|
447 action->setStatusTip(tr("Exit %1").arg(QApplication::applicationName()));
|
Chris@0
|
448 connect(action, SIGNAL(triggered()), this, SLOT(close()));
|
Chris@0
|
449 m_keyReference->registerShortcut(action);
|
Chris@0
|
450 menu->addAction(action);
|
Chris@0
|
451 }
|
Chris@0
|
452
|
Chris@0
|
453 void
|
Chris@0
|
454 MainWindow::setupEditMenu()
|
Chris@0
|
455 {
|
Chris@0
|
456 if (m_mainMenusCreated) return;
|
Chris@0
|
457
|
Chris@0
|
458 QMenu *menu = menuBar()->addMenu(tr("&Edit"));
|
Chris@0
|
459 menu->setTearOffEnabled(true);
|
Chris@0
|
460 CommandHistory::getInstance()->registerMenu(menu);
|
Chris@126
|
461 menu->addSeparator();
|
Chris@126
|
462
|
Chris@254
|
463 m_keyReference->setCategory
|
Chris@254
|
464 (tr("Selection Strip Mouse Actions"));
|
Chris@254
|
465 m_keyReference->registerShortcut
|
Chris@254
|
466 (tr("Jump"), tr("Left"),
|
Chris@254
|
467 tr("Click left button to move the playback position to a time"));
|
Chris@254
|
468 m_keyReference->registerShortcut
|
Chris@254
|
469 (tr("Select"), tr("Left"),
|
Chris@254
|
470 tr("Click left button and drag to select a region of time"));
|
Chris@254
|
471 m_keyReference->registerShortcut
|
Chris@254
|
472 (tr("Select Note Duration"), tr("Double-Click Left"),
|
Chris@254
|
473 tr("Double-click left button to select the region of time corresponding to a note"));
|
Chris@254
|
474
|
Chris@126
|
475 QToolBar *toolbar = addToolBar(tr("Tools Toolbar"));
|
Chris@126
|
476
|
Chris@126
|
477 CommandHistory::getInstance()->registerToolbar(toolbar);
|
Chris@126
|
478
|
Chris@250
|
479 QActionGroup *group = new QActionGroup(this);
|
Chris@250
|
480
|
Chris@250
|
481 IconLoader il;
|
Chris@250
|
482
|
Chris@126
|
483 m_keyReference->setCategory(tr("Tool Selection"));
|
Chris@126
|
484 QAction *action = toolbar->addAction(il.load("navigate"),
|
Chris@126
|
485 tr("Navigate"));
|
Chris@126
|
486 action->setCheckable(true);
|
Chris@126
|
487 action->setChecked(true);
|
Chris@126
|
488 action->setShortcut(tr("1"));
|
Chris@126
|
489 action->setStatusTip(tr("Navigate"));
|
Chris@126
|
490 connect(action, SIGNAL(triggered()), this, SLOT(toolNavigateSelected()));
|
Chris@126
|
491 connect(this, SIGNAL(replacedDocument()), action, SLOT(trigger()));
|
Chris@126
|
492 group->addAction(action);
|
Chris@126
|
493 menu->addAction(action);
|
Chris@126
|
494 m_keyReference->registerShortcut(action);
|
Chris@126
|
495
|
Chris@250
|
496 m_keyReference->setCategory
|
Chris@250
|
497 (tr("Navigate Tool Mouse Actions"));
|
Chris@250
|
498 m_keyReference->registerShortcut
|
Chris@250
|
499 (tr("Navigate"), tr("Left"),
|
Chris@250
|
500 tr("Click left button and drag to move around"));
|
Chris@250
|
501 m_keyReference->registerShortcut
|
Chris@250
|
502 (tr("Re-Analyse Area"), tr("Shift+Left"),
|
Chris@250
|
503 tr("Shift-click left button and drag to define a specific pitch and time range to re-analyse"));
|
Chris@250
|
504 m_keyReference->registerShortcut
|
Chris@250
|
505 (tr("Edit"), tr("Double-Click Left"),
|
Chris@250
|
506 tr("Double-click left button on an item to edit it"));
|
Chris@392
|
507
|
Chris@250
|
508 m_keyReference->setCategory(tr("Tool Selection"));
|
Chris@126
|
509 action = toolbar->addAction(il.load("move"),
|
Chris@126
|
510 tr("Edit"));
|
Chris@126
|
511 action->setCheckable(true);
|
Chris@126
|
512 action->setShortcut(tr("2"));
|
Chris@126
|
513 action->setStatusTip(tr("Edit with Note Intelligence"));
|
Chris@126
|
514 connect(action, SIGNAL(triggered()), this, SLOT(toolEditSelected()));
|
Chris@126
|
515 group->addAction(action);
|
Chris@126
|
516 menu->addAction(action);
|
Chris@126
|
517 m_keyReference->registerShortcut(action);
|
Chris@126
|
518
|
Chris@250
|
519 m_keyReference->setCategory
|
Chris@250
|
520 (tr("Note Edit Tool Mouse Actions"));
|
Chris@250
|
521 m_keyReference->registerShortcut
|
Chris@250
|
522 (tr("Adjust Pitch"), tr("Left"),
|
Chris@250
|
523 tr("Click left button on the main part of a note and drag to move it up or down"));
|
Chris@250
|
524 m_keyReference->registerShortcut
|
Chris@250
|
525 (tr("Split"), tr("Left"),
|
Chris@250
|
526 tr("Click left button on the bottom edge of a note to split it at the click point"));
|
Chris@250
|
527 m_keyReference->registerShortcut
|
Chris@250
|
528 (tr("Resize"), tr("Left"),
|
Chris@250
|
529 tr("Click left button on the left or right edge of a note and drag to change the time or duration of the note"));
|
Chris@250
|
530 m_keyReference->registerShortcut
|
Chris@250
|
531 (tr("Erase"), tr("Shift+Left"),
|
Chris@250
|
532 tr("Shift-click left button on a note to remove it"));
|
Chris@250
|
533
|
Chris@250
|
534
|
Chris@126
|
535 /* Remove for now...
|
Chris@126
|
536
|
Chris@250
|
537 m_keyReference->setCategory(tr("Tool Selection"));
|
Chris@126
|
538 action = toolbar->addAction(il.load("notes"),
|
Chris@126
|
539 tr("Free Edit"));
|
Chris@126
|
540 action->setCheckable(true);
|
Chris@126
|
541 action->setShortcut(tr("3"));
|
Chris@126
|
542 action->setStatusTip(tr("Free Edit"));
|
Chris@126
|
543 connect(action, SIGNAL(triggered()), this, SLOT(toolFreeEditSelected()));
|
Chris@126
|
544 group->addAction(action);
|
Chris@126
|
545 m_keyReference->registerShortcut(action);
|
Chris@126
|
546 */
|
Chris@142
|
547
|
Chris@142
|
548 menu->addSeparator();
|
Chris@142
|
549
|
Chris@143
|
550 m_keyReference->setCategory(tr("Selection"));
|
Chris@143
|
551
|
Chris@143
|
552 action = new QAction(tr("Select &All"), this);
|
Chris@143
|
553 action->setShortcut(tr("Ctrl+A"));
|
Chris@143
|
554 action->setStatusTip(tr("Select the whole duration of the current session"));
|
Chris@143
|
555 connect(action, SIGNAL(triggered()), this, SLOT(selectAll()));
|
Chris@143
|
556 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool)));
|
Chris@143
|
557 m_keyReference->registerShortcut(action);
|
Chris@143
|
558 menu->addAction(action);
|
Chris@143
|
559 m_rightButtonMenu->addAction(action);
|
Chris@143
|
560
|
Chris@287
|
561 action = new QAction(tr("C&lear Selection"), this);
|
Chris@211
|
562 action->setShortcuts(QList<QKeySequence>()
|
Chris@211
|
563 << QKeySequence(tr("Esc"))
|
Chris@211
|
564 << QKeySequence(tr("Ctrl+Esc")));
|
Chris@211
|
565 action->setStatusTip(tr("Clear the selection and abandon any pending pitch choices in it"));
|
Chris@194
|
566 connect(action, SIGNAL(triggered()), this, SLOT(abandonSelection()));
|
Chris@143
|
567 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool)));
|
Chris@143
|
568 m_keyReference->registerShortcut(action);
|
Chris@211
|
569 m_keyReference->registerAlternativeShortcut(action, QKeySequence(tr("Ctrl+Esc")));
|
Chris@143
|
570 menu->addAction(action);
|
Chris@143
|
571 m_rightButtonMenu->addAction(action);
|
Chris@143
|
572
|
Chris@143
|
573 menu->addSeparator();
|
Chris@189
|
574 m_rightButtonMenu->addSeparator();
|
Chris@143
|
575
|
Chris@189
|
576 m_keyReference->setCategory(tr("Pitch Track"));
|
Chris@211
|
577
|
Chris@211
|
578 action = new QAction(tr("Choose Higher Pitch"), this);
|
Chris@211
|
579 action->setShortcut(tr("Ctrl+Up"));
|
Chris@211
|
580 action->setStatusTip(tr("Move pitches up an octave, or to the next higher pitch candidate"));
|
Chris@211
|
581 m_keyReference->registerShortcut(action);
|
Chris@211
|
582 connect(action, SIGNAL(triggered()), this, SLOT(switchPitchUp()));
|
Chris@211
|
583 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool)));
|
Chris@211
|
584 menu->addAction(action);
|
Chris@211
|
585 m_rightButtonMenu->addAction(action);
|
Chris@211
|
586
|
Chris@211
|
587 action = new QAction(tr("Choose Lower Pitch"), this);
|
Chris@211
|
588 action->setShortcut(tr("Ctrl+Down"));
|
Chris@211
|
589 action->setStatusTip(tr("Move pitches down an octave, or to the next lower pitch candidate"));
|
Chris@211
|
590 m_keyReference->registerShortcut(action);
|
Chris@211
|
591 connect(action, SIGNAL(triggered()), this, SLOT(switchPitchDown()));
|
Chris@211
|
592 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool)));
|
Chris@211
|
593 menu->addAction(action);
|
Chris@211
|
594 m_rightButtonMenu->addAction(action);
|
Chris@189
|
595
|
Chris@187
|
596 m_showCandidatesAction = new QAction(tr("Show Pitch Candidates"), this);
|
Chris@187
|
597 m_showCandidatesAction->setShortcut(tr("Ctrl+Return"));
|
Chris@189
|
598 m_showCandidatesAction->setStatusTip(tr("Toggle the display of alternative pitch candidates for the selected region"));
|
Chris@189
|
599 m_keyReference->registerShortcut(m_showCandidatesAction);
|
Chris@187
|
600 connect(m_showCandidatesAction, SIGNAL(triggered()), this, SLOT(togglePitchCandidates()));
|
Chris@187
|
601 connect(this, SIGNAL(canClearSelection(bool)), m_showCandidatesAction, SLOT(setEnabled(bool)));
|
Chris@187
|
602 menu->addAction(m_showCandidatesAction);
|
Chris@189
|
603 m_rightButtonMenu->addAction(m_showCandidatesAction);
|
Chris@187
|
604
|
Chris@287
|
605 action = new QAction(tr("Remove Pitches"), this);
|
matthiasm@327
|
606 action->setShortcut(tr("Ctrl+Backspace"));
|
Chris@211
|
607 action->setStatusTip(tr("Remove all pitch estimates within the selected region, making it unvoiced"));
|
Chris@189
|
608 m_keyReference->registerShortcut(action);
|
Chris@187
|
609 connect(action, SIGNAL(triggered()), this, SLOT(clearPitches()));
|
Chris@167
|
610 connect(this, SIGNAL(canClearSelection(bool)), action, SLOT(setEnabled(bool)));
|
Chris@167
|
611 menu->addAction(action);
|
Chris@189
|
612 m_rightButtonMenu->addAction(action);
|
Chris@237
|
613
|
Chris@237
|
614 menu->addSeparator();
|
Chris@237
|
615 m_rightButtonMenu->addSeparator();
|
Chris@237
|
616
|
matthiasm@327
|
617 m_keyReference->setCategory(tr("Note Track"));
|
matthiasm@327
|
618
|
Chris@287
|
619 action = new QAction(tr("Split Note"), this);
|
matthiasm@327
|
620 action->setShortcut(tr("/"));
|
Chris@240
|
621 action->setStatusTip(tr("Split the note at the current playback position into two"));
|
Chris@237
|
622 m_keyReference->registerShortcut(action);
|
Chris@240
|
623 connect(action, SIGNAL(triggered()), this, SLOT(splitNote()));
|
Chris@240
|
624 connect(this, SIGNAL(canExportNotes(bool)), action, SLOT(setEnabled(bool)));
|
Chris@237
|
625 menu->addAction(action);
|
Chris@237
|
626 m_rightButtonMenu->addAction(action);
|
Chris@238
|
627
|
Chris@287
|
628 action = new QAction(tr("Merge Notes"), this);
|
matthiasm@327
|
629 action->setShortcut(tr("\\"));
|
Chris@238
|
630 action->setStatusTip(tr("Merge all notes within the selected region into a single note"));
|
Chris@238
|
631 m_keyReference->registerShortcut(action);
|
Chris@238
|
632 connect(action, SIGNAL(triggered()), this, SLOT(mergeNotes()));
|
Chris@238
|
633 connect(this, SIGNAL(canSnapNotes(bool)), action, SLOT(setEnabled(bool)));
|
Chris@238
|
634 menu->addAction(action);
|
Chris@238
|
635 m_rightButtonMenu->addAction(action);
|
matthiasm@292
|
636
|
matthiasm@292
|
637 action = new QAction(tr("Delete Notes"), this);
|
matthiasm@327
|
638 action->setShortcut(tr("Backspace"));
|
matthiasm@327
|
639 action->setStatusTip(tr("Delete all notes within the selected region"));
|
matthiasm@292
|
640 m_keyReference->registerShortcut(action);
|
matthiasm@292
|
641 connect(action, SIGNAL(triggered()), this, SLOT(deleteNotes()));
|
matthiasm@292
|
642 connect(this, SIGNAL(canSnapNotes(bool)), action, SLOT(setEnabled(bool)));
|
matthiasm@292
|
643 menu->addAction(action);
|
matthiasm@292
|
644 m_rightButtonMenu->addAction(action);
|
Chris@238
|
645
|
Chris@240
|
646 action = new QAction(tr("Form Note from Selection"), this);
|
matthiasm@327
|
647 action->setShortcut(tr("="));
|
Chris@240
|
648 action->setStatusTip(tr("Form a note spanning the selected region, splitting any existing notes at its boundaries"));
|
Chris@240
|
649 m_keyReference->registerShortcut(action);
|
Chris@240
|
650 connect(action, SIGNAL(triggered()), this, SLOT(formNoteFromSelection()));
|
Chris@240
|
651 connect(this, SIGNAL(canSnapNotes(bool)), action, SLOT(setEnabled(bool)));
|
Chris@240
|
652 menu->addAction(action);
|
Chris@240
|
653 m_rightButtonMenu->addAction(action);
|
Chris@247
|
654
|
Chris@238
|
655 action = new QAction(tr("Snap Notes to Pitch Track"), this);
|
Chris@238
|
656 action->setStatusTip(tr("Set notes within the selected region to the median frequency of their underlying pitches, or remove them if there are no underlying pitches"));
|
matthiasm@327
|
657 // m_keyReference->registerShortcut(action);
|
Chris@238
|
658 connect(action, SIGNAL(triggered()), this, SLOT(snapNotesToPitches()));
|
Chris@238
|
659 connect(this, SIGNAL(canSnapNotes(bool)), action, SLOT(setEnabled(bool)));
|
Chris@238
|
660 menu->addAction(action);
|
Chris@238
|
661 m_rightButtonMenu->addAction(action);
|
Chris@0
|
662 }
|
Chris@0
|
663
|
Chris@0
|
664 void
|
Chris@0
|
665 MainWindow::setupViewMenu()
|
Chris@0
|
666 {
|
Chris@0
|
667 if (m_mainMenusCreated) return;
|
Chris@0
|
668
|
Chris@0
|
669 IconLoader il;
|
Chris@0
|
670
|
Chris@0
|
671 QAction *action = 0;
|
Chris@0
|
672
|
Chris@0
|
673 m_keyReference->setCategory(tr("Panning and Navigation"));
|
Chris@0
|
674
|
Chris@0
|
675 QMenu *menu = menuBar()->addMenu(tr("&View"));
|
Chris@0
|
676 menu->setTearOffEnabled(true);
|
Chris@300
|
677 action = new QAction(tr("Peek &Left"), this);
|
Chris@300
|
678 action->setShortcut(tr("Alt+Left"));
|
Chris@300
|
679 action->setStatusTip(tr("Scroll the current pane to the left without changing the play position"));
|
Chris@0
|
680 connect(action, SIGNAL(triggered()), this, SLOT(scrollLeft()));
|
Chris@0
|
681 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
682 m_keyReference->registerShortcut(action);
|
Chris@0
|
683 menu->addAction(action);
|
gyorgyf@27
|
684
|
Chris@300
|
685 action = new QAction(tr("Peek &Right"), this);
|
Chris@300
|
686 action->setShortcut(tr("Alt+Right"));
|
Chris@300
|
687 action->setStatusTip(tr("Scroll the current pane to the right without changing the play position"));
|
Chris@0
|
688 connect(action, SIGNAL(triggered()), this, SLOT(scrollRight()));
|
Chris@0
|
689 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
690 m_keyReference->registerShortcut(action);
|
Chris@0
|
691 menu->addAction(action);
|
matthiasm@283
|
692
|
Chris@0
|
693 menu->addSeparator();
|
Chris@0
|
694
|
Chris@0
|
695 m_keyReference->setCategory(tr("Zoom"));
|
Chris@0
|
696
|
Chris@0
|
697 action = new QAction(il.load("zoom-in"),
|
Chris@0
|
698 tr("Zoom &In"), this);
|
Chris@0
|
699 action->setShortcut(tr("Up"));
|
Chris@0
|
700 action->setStatusTip(tr("Increase the zoom level"));
|
Chris@0
|
701 connect(action, SIGNAL(triggered()), this, SLOT(zoomIn()));
|
Chris@0
|
702 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
703 m_keyReference->registerShortcut(action);
|
Chris@0
|
704 menu->addAction(action);
|
gyorgyf@27
|
705
|
Chris@0
|
706 action = new QAction(il.load("zoom-out"),
|
Chris@0
|
707 tr("Zoom &Out"), this);
|
Chris@0
|
708 action->setShortcut(tr("Down"));
|
Chris@0
|
709 action->setStatusTip(tr("Decrease the zoom level"));
|
Chris@0
|
710 connect(action, SIGNAL(triggered()), this, SLOT(zoomOut()));
|
Chris@0
|
711 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
712 m_keyReference->registerShortcut(action);
|
Chris@0
|
713 menu->addAction(action);
|
gyorgyf@27
|
714
|
Chris@0
|
715 action = new QAction(tr("Restore &Default Zoom"), this);
|
Chris@0
|
716 action->setStatusTip(tr("Restore the zoom level to the default"));
|
Chris@0
|
717 connect(action, SIGNAL(triggered()), this, SLOT(zoomDefault()));
|
Chris@0
|
718 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
719 menu->addAction(action);
|
Chris@0
|
720
|
Chris@0
|
721 action = new QAction(il.load("zoom-fit"),
|
Chris@0
|
722 tr("Zoom to &Fit"), this);
|
Chris@0
|
723 action->setShortcut(tr("F"));
|
Chris@0
|
724 action->setStatusTip(tr("Zoom to show the whole file"));
|
Chris@0
|
725 connect(action, SIGNAL(triggered()), this, SLOT(zoomToFit()));
|
Chris@0
|
726 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
|
Chris@0
|
727 m_keyReference->registerShortcut(action);
|
Chris@0
|
728 menu->addAction(action);
|
Chris@227
|
729
|
Chris@227
|
730 menu->addSeparator();
|
Chris@227
|
731
|
Chris@227
|
732 action = new QAction(tr("Set Displayed Fre&quency Range..."), this);
|
Chris@227
|
733 action->setStatusTip(tr("Set the minimum and maximum frequencies in the visible display"));
|
Chris@227
|
734 connect(action, SIGNAL(triggered()), this, SLOT(editDisplayExtents()));
|
Chris@227
|
735 menu->addAction(action);
|
Chris@0
|
736 }
|
Chris@0
|
737
|
Chris@0
|
738 void
|
matthiasm@317
|
739 MainWindow::setupAnalysisMenu()
|
matthiasm@317
|
740 {
|
matthiasm@317
|
741 if (m_mainMenusCreated) return;
|
matthiasm@317
|
742
|
matthiasm@317
|
743 IconLoader il;
|
matthiasm@317
|
744
|
matthiasm@317
|
745 QAction *action = 0;
|
matthiasm@317
|
746
|
matthiasm@317
|
747 QMenu *menu = menuBar()->addMenu(tr("&Analysis"));
|
matthiasm@317
|
748 menu->setTearOffEnabled(true);
|
matthiasm@317
|
749
|
matthiasm@333
|
750
|
matthiasm@333
|
751 action = new QAction(tr("&Analyse now!"), this);
|
matthiasm@333
|
752 action->setStatusTip(tr("Trigger analysis of pitches and notes. (This will delete all existing pitches and notes.)"));
|
Chris@323
|
753 connect(action, SIGNAL(triggered()), this, SLOT(analyseNow()));
|
matthiasm@317
|
754 menu->addAction(action);
|
matthiasm@317
|
755 m_keyReference->registerShortcut(action);
|
matthiasm@317
|
756
|
matthiasm@317
|
757 menu->addSeparator();
|
matthiasm@317
|
758
|
Chris@323
|
759 QSettings settings;
|
Chris@323
|
760 settings.beginGroup("Analyser");
|
Chris@323
|
761 bool autoAnalyse = settings.value("auto-analysis", true).toBool();
|
Chris@323
|
762 bool precise = settings.value("precision-analysis", false).toBool();
|
matthiasm@345
|
763 bool lowamp = settings.value("lowamp-analysis", true).toBool();
|
Chris@323
|
764 settings.endGroup();
|
Chris@323
|
765
|
matthiasm@333
|
766 action = new QAction(tr("Auto-Analyse &New Audio"), this);
|
matthiasm@333
|
767 action->setStatusTip(tr("Automatically trigger analysis upon opening of a new audio file."));
|
matthiasm@317
|
768 action->setCheckable(true);
|
Chris@323
|
769 action->setChecked(autoAnalyse);
|
Chris@323
|
770 connect(action, SIGNAL(triggered()), this, SLOT(autoAnalysisToggled()));
|
matthiasm@317
|
771 menu->addAction(action);
|
matthiasm@317
|
772
|
matthiasm@333
|
773 action = new QAction(tr("&Unbiased Timing (slow)"), this);
|
matthiasm@333
|
774 action->setStatusTip(tr("Use a symmetric window in YIN to remove frequency-dependent timing bias. (This is slow!)"));
|
matthiasm@317
|
775 action->setCheckable(true);
|
Chris@323
|
776 action->setChecked(precise);
|
Chris@323
|
777 connect(action, SIGNAL(triggered()), this, SLOT(precisionAnalysisToggled()));
|
matthiasm@317
|
778 menu->addAction(action);
|
matthiasm@345
|
779
|
matthiasm@348
|
780 action = new QAction(tr("&Penalise Soft Pitches"), this);
|
matthiasm@345
|
781 action->setStatusTip(tr("Reduce the likelihood of detecting a pitch when the signal has low amplitude."));
|
matthiasm@345
|
782 action->setCheckable(true);
|
matthiasm@345
|
783 action->setChecked(lowamp);
|
matthiasm@345
|
784 connect(action, SIGNAL(triggered()), this, SLOT(lowampAnalysisToggled()));
|
matthiasm@345
|
785 menu->addAction(action);
|
matthiasm@345
|
786
|
Chris@323
|
787 }
|
Chris@323
|
788
|
Chris@323
|
789 void
|
Chris@323
|
790 MainWindow::autoAnalysisToggled()
|
Chris@323
|
791 {
|
Chris@323
|
792 QAction *a = qobject_cast<QAction *>(sender());
|
Chris@323
|
793 if (!a) return;
|
Chris@323
|
794
|
Chris@323
|
795 bool set = a->isChecked();
|
Chris@323
|
796
|
Chris@323
|
797 QSettings settings;
|
Chris@323
|
798 settings.beginGroup("Analyser");
|
Chris@323
|
799 settings.setValue("auto-analysis", set);
|
Chris@323
|
800 settings.endGroup();
|
Chris@323
|
801 }
|
Chris@323
|
802
|
Chris@323
|
803 void
|
Chris@323
|
804 MainWindow::precisionAnalysisToggled()
|
Chris@323
|
805 {
|
Chris@323
|
806 QAction *a = qobject_cast<QAction *>(sender());
|
Chris@323
|
807 if (!a) return;
|
Chris@323
|
808
|
Chris@323
|
809 bool set = a->isChecked();
|
Chris@323
|
810
|
Chris@323
|
811 QSettings settings;
|
Chris@323
|
812 settings.beginGroup("Analyser");
|
Chris@323
|
813 settings.setValue("precision-analysis", set);
|
Chris@323
|
814 settings.endGroup();
|
Chris@323
|
815
|
Chris@326
|
816 // don't run analyseNow() automatically -- it's a destructive operation
|
matthiasm@317
|
817 }
|
matthiasm@317
|
818
|
matthiasm@317
|
819 void
|
matthiasm@345
|
820 MainWindow::lowampAnalysisToggled()
|
matthiasm@345
|
821 {
|
matthiasm@345
|
822 QAction *a = qobject_cast<QAction *>(sender());
|
matthiasm@345
|
823 if (!a) return;
|
matthiasm@345
|
824
|
matthiasm@345
|
825 bool set = a->isChecked();
|
matthiasm@345
|
826
|
matthiasm@345
|
827 QSettings settings;
|
matthiasm@345
|
828 settings.beginGroup("Analyser");
|
matthiasm@345
|
829 settings.setValue("lowamp-analysis", set);
|
matthiasm@345
|
830 settings.endGroup();
|
matthiasm@345
|
831
|
matthiasm@345
|
832 // don't run analyseNow() automatically -- it's a destructive operation
|
matthiasm@345
|
833 }
|
matthiasm@345
|
834
|
matthiasm@345
|
835 void
|
Chris@0
|
836 MainWindow::setupHelpMenu()
|
Chris@0
|
837 {
|
Chris@0
|
838 QMenu *menu = menuBar()->addMenu(tr("&Help"));
|
Chris@0
|
839 menu->setTearOffEnabled(true);
|
Chris@0
|
840
|
Chris@0
|
841 m_keyReference->setCategory(tr("Help"));
|
Chris@0
|
842
|
Chris@0
|
843 IconLoader il;
|
Chris@0
|
844
|
Chris@1
|
845 QString name = QApplication::applicationName();
|
matthiasm@367
|
846 QAction *action;
|
matthiasm@367
|
847
|
Chris@0
|
848 action = new QAction(tr("&Key and Mouse Reference"), this);
|
Chris@0
|
849 action->setShortcut(tr("F2"));
|
Chris@1
|
850 action->setStatusTip(tr("Open a window showing the keystrokes you can use in %1").arg(name));
|
Chris@0
|
851 connect(action, SIGNAL(triggered()), this, SLOT(keyReference()));
|
Chris@0
|
852 m_keyReference->registerShortcut(action);
|
Chris@0
|
853 menu->addAction(action);
|
matthiasm@369
|
854
|
matthiasm@369
|
855 action = new QAction(il.load("help"),
|
matthiasm@369
|
856 tr("&Help Reference"), this);
|
matthiasm@369
|
857 action->setShortcut(tr("F1"));
|
matthiasm@369
|
858 action->setStatusTip(tr("Open the %1 reference manual").arg(name));
|
matthiasm@369
|
859 connect(action, SIGNAL(triggered()), this, SLOT(help()));
|
matthiasm@369
|
860 m_keyReference->registerShortcut(action);
|
matthiasm@369
|
861 menu->addAction(action);
|
matthiasm@369
|
862
|
Chris@0
|
863
|
Chris@1
|
864 action = new QAction(tr("%1 on the &Web").arg(name), this);
|
Chris@1
|
865 action->setStatusTip(tr("Open the %1 website").arg(name));
|
Chris@0
|
866 connect(action, SIGNAL(triggered()), this, SLOT(website()));
|
Chris@0
|
867 menu->addAction(action);
|
Chris@0
|
868
|
Chris@1
|
869 action = new QAction(tr("&About %1").arg(name), this);
|
Chris@1
|
870 action->setStatusTip(tr("Show information about %1").arg(name));
|
Chris@0
|
871 connect(action, SIGNAL(triggered()), this, SLOT(about()));
|
Chris@0
|
872 menu->addAction(action);
|
Chris@0
|
873 }
|
Chris@0
|
874
|
Chris@0
|
875 void
|
Chris@0
|
876 MainWindow::setupRecentFilesMenu()
|
Chris@0
|
877 {
|
Chris@0
|
878 m_recentFilesMenu->clear();
|
Chris@0
|
879 vector<QString> files = m_recentFiles.getRecent();
|
Chris@0
|
880 for (size_t i = 0; i < files.size(); ++i) {
|
Chris@50
|
881 QAction *action = new QAction(files[i], this);
|
Chris@50
|
882 connect(action, SIGNAL(triggered()), this, SLOT(openRecentFile()));
|
Chris@0
|
883 if (i == 0) {
|
Chris@0
|
884 action->setShortcut(tr("Ctrl+R"));
|
Chris@0
|
885 m_keyReference->registerShortcut
|
Chris@0
|
886 (tr("Re-open"),
|
Chris@50
|
887 action->shortcut().toString(),
|
Chris@0
|
888 tr("Re-open the current or most recently opened file"));
|
Chris@0
|
889 }
|
Chris@50
|
890 m_recentFilesMenu->addAction(action);
|
Chris@0
|
891 }
|
Chris@0
|
892 }
|
Chris@0
|
893
|
Chris@0
|
894 void
|
Chris@0
|
895 MainWindow::setupToolbars()
|
Chris@0
|
896 {
|
Chris@0
|
897 m_keyReference->setCategory(tr("Playback and Transport Controls"));
|
Chris@0
|
898
|
Chris@0
|
899 IconLoader il;
|
Chris@0
|
900
|
Chris@0
|
901 QMenu *menu = m_playbackMenu = menuBar()->addMenu(tr("Play&back"));
|
Chris@0
|
902 menu->setTearOffEnabled(true);
|
Chris@0
|
903 m_rightButtonMenu->addSeparator();
|
Chris@0
|
904 m_rightButtonPlaybackMenu = m_rightButtonMenu->addMenu(tr("Playback"));
|
Chris@0
|
905
|
Chris@0
|
906 QToolBar *toolbar = addToolBar(tr("Playback Toolbar"));
|
Chris@0
|
907
|
Chris@0
|
908 QAction *rwdStartAction = toolbar->addAction(il.load("rewind-start"),
|
Chris@0
|
909 tr("Rewind to Start"));
|
Chris@0
|
910 rwdStartAction->setShortcut(tr("Home"));
|
Chris@0
|
911 rwdStartAction->setStatusTip(tr("Rewind to the start"));
|
Chris@0
|
912 connect(rwdStartAction, SIGNAL(triggered()), this, SLOT(rewindStart()));
|
Chris@0
|
913 connect(this, SIGNAL(canPlay(bool)), rwdStartAction, SLOT(setEnabled(bool)));
|
Chris@0
|
914
|
Chris@0
|
915 QAction *m_rwdAction = toolbar->addAction(il.load("rewind"),
|
Chris@0
|
916 tr("Rewind"));
|
Chris@300
|
917 m_rwdAction->setShortcut(tr("Left"));
|
Chris@300
|
918 m_rwdAction->setStatusTip(tr("Rewind to the previous one-second boundary"));
|
Chris@0
|
919 connect(m_rwdAction, SIGNAL(triggered()), this, SLOT(rewind()));
|
Chris@0
|
920 connect(this, SIGNAL(canRewind(bool)), m_rwdAction, SLOT(setEnabled(bool)));
|
Chris@0
|
921
|
Chris@300
|
922 setDefaultFfwdRwdStep(RealTime(1, 0));
|
Chris@300
|
923
|
Chris@0
|
924 QAction *playAction = toolbar->addAction(il.load("playpause"),
|
Chris@0
|
925 tr("Play / Pause"));
|
Chris@0
|
926 playAction->setCheckable(true);
|
Chris@0
|
927 playAction->setShortcut(tr("Space"));
|
Chris@0
|
928 playAction->setStatusTip(tr("Start or stop playback from the current position"));
|
Chris@0
|
929 connect(playAction, SIGNAL(triggered()), this, SLOT(play()));
|
Chris@0
|
930 connect(m_playSource, SIGNAL(playStatusChanged(bool)),
|
gyorgyf@27
|
931 playAction, SLOT(setChecked(bool)));
|
Chris@0
|
932 connect(this, SIGNAL(canPlay(bool)), playAction, SLOT(setEnabled(bool)));
|
Chris@0
|
933
|
Chris@0
|
934 m_ffwdAction = toolbar->addAction(il.load("ffwd"),
|
Chris@0
|
935 tr("Fast Forward"));
|
Chris@300
|
936 m_ffwdAction->setShortcut(tr("Right"));
|
Chris@300
|
937 m_ffwdAction->setStatusTip(tr("Fast-forward to the next one-second boundary"));
|
Chris@0
|
938 connect(m_ffwdAction, SIGNAL(triggered()), this, SLOT(ffwd()));
|
Chris@0
|
939 connect(this, SIGNAL(canFfwd(bool)), m_ffwdAction, SLOT(setEnabled(bool)));
|
Chris@0
|
940
|
Chris@0
|
941 QAction *ffwdEndAction = toolbar->addAction(il.load("ffwd-end"),
|
Chris@0
|
942 tr("Fast Forward to End"));
|
Chris@0
|
943 ffwdEndAction->setShortcut(tr("End"));
|
Chris@0
|
944 ffwdEndAction->setStatusTip(tr("Fast-forward to the end"));
|
Chris@0
|
945 connect(ffwdEndAction, SIGNAL(triggered()), this, SLOT(ffwdEnd()));
|
Chris@0
|
946 connect(this, SIGNAL(canPlay(bool)), ffwdEndAction, SLOT(setEnabled(bool)));
|
Chris@6
|
947
|
Chris@0
|
948 toolbar = addToolBar(tr("Play Mode Toolbar"));
|
Chris@0
|
949
|
Chris@0
|
950 QAction *psAction = toolbar->addAction(il.load("playselection"),
|
Chris@0
|
951 tr("Constrain Playback to Selection"));
|
Chris@0
|
952 psAction->setCheckable(true);
|
Chris@0
|
953 psAction->setChecked(m_viewManager->getPlaySelectionMode());
|
Chris@0
|
954 psAction->setShortcut(tr("s"));
|
Chris@0
|
955 psAction->setStatusTip(tr("Constrain playback to the selected regions"));
|
Chris@0
|
956 connect(m_viewManager, SIGNAL(playSelectionModeChanged(bool)),
|
Chris@0
|
957 psAction, SLOT(setChecked(bool)));
|
Chris@0
|
958 connect(psAction, SIGNAL(triggered()), this, SLOT(playSelectionToggled()));
|
Chris@0
|
959 connect(this, SIGNAL(canPlaySelection(bool)), psAction, SLOT(setEnabled(bool)));
|
Chris@0
|
960
|
Chris@0
|
961 QAction *plAction = toolbar->addAction(il.load("playloop"),
|
Chris@0
|
962 tr("Loop Playback"));
|
Chris@0
|
963 plAction->setCheckable(true);
|
Chris@0
|
964 plAction->setChecked(m_viewManager->getPlayLoopMode());
|
Chris@0
|
965 plAction->setShortcut(tr("l"));
|
Chris@0
|
966 plAction->setStatusTip(tr("Loop playback"));
|
Chris@0
|
967 connect(m_viewManager, SIGNAL(playLoopModeChanged(bool)),
|
Chris@0
|
968 plAction, SLOT(setChecked(bool)));
|
Chris@0
|
969 connect(plAction, SIGNAL(triggered()), this, SLOT(playLoopToggled()));
|
Chris@0
|
970 connect(this, SIGNAL(canPlay(bool)), plAction, SLOT(setEnabled(bool)));
|
Chris@0
|
971
|
Chris@300
|
972 QAction *oneLeftAction = new QAction(tr("&One Note Left"), this);
|
Chris@300
|
973 oneLeftAction->setShortcut(tr("Ctrl+Left"));
|
Chris@300
|
974 oneLeftAction->setStatusTip(tr("Move cursor to the preceding note (or silence) onset."));
|
Chris@300
|
975 connect(oneLeftAction, SIGNAL(triggered()), this, SLOT(moveOneNoteLeft()));
|
Chris@300
|
976 connect(this, SIGNAL(canScroll(bool)), oneLeftAction, SLOT(setEnabled(bool)));
|
Chris@300
|
977
|
Chris@300
|
978 QAction *oneRightAction = new QAction(tr("O&ne Note Right"), this);
|
Chris@300
|
979 oneRightAction->setShortcut(tr("Ctrl+Right"));
|
Chris@300
|
980 oneRightAction->setStatusTip(tr("Move cursor to the succeeding note (or silence)."));
|
Chris@300
|
981 connect(oneRightAction, SIGNAL(triggered()), this, SLOT(moveOneNoteRight()));
|
Chris@300
|
982 connect(this, SIGNAL(canScroll(bool)), oneRightAction, SLOT(setEnabled(bool)));
|
Chris@300
|
983
|
Chris@300
|
984 QAction *selectOneLeftAction = new QAction(tr("&Select One Note Left"), this);
|
Chris@300
|
985 selectOneLeftAction->setShortcut(tr("Ctrl+Shift+Left"));
|
Chris@300
|
986 selectOneLeftAction->setStatusTip(tr("Select to the preceding note (or silence) onset."));
|
Chris@300
|
987 connect(selectOneLeftAction, SIGNAL(triggered()), this, SLOT(selectOneNoteLeft()));
|
Chris@300
|
988 connect(this, SIGNAL(canScroll(bool)), selectOneLeftAction, SLOT(setEnabled(bool)));
|
Chris@300
|
989
|
Chris@300
|
990 QAction *selectOneRightAction = new QAction(tr("S&elect One Note Right"), this);
|
Chris@300
|
991 selectOneRightAction->setShortcut(tr("Ctrl+Shift+Right"));
|
Chris@300
|
992 selectOneRightAction->setStatusTip(tr("Select to the succeeding note (or silence)."));
|
Chris@300
|
993 connect(selectOneRightAction, SIGNAL(triggered()), this, SLOT(selectOneNoteRight()));
|
Chris@300
|
994 connect(this, SIGNAL(canScroll(bool)), selectOneRightAction, SLOT(setEnabled(bool)));
|
Chris@300
|
995
|
Chris@0
|
996 m_keyReference->registerShortcut(psAction);
|
Chris@0
|
997 m_keyReference->registerShortcut(plAction);
|
Chris@0
|
998 m_keyReference->registerShortcut(playAction);
|
Chris@0
|
999 m_keyReference->registerShortcut(m_rwdAction);
|
Chris@0
|
1000 m_keyReference->registerShortcut(m_ffwdAction);
|
Chris@0
|
1001 m_keyReference->registerShortcut(rwdStartAction);
|
Chris@0
|
1002 m_keyReference->registerShortcut(ffwdEndAction);
|
Chris@300
|
1003 m_keyReference->registerShortcut(oneLeftAction);
|
Chris@300
|
1004 m_keyReference->registerShortcut(oneRightAction);
|
Chris@300
|
1005 m_keyReference->registerShortcut(selectOneLeftAction);
|
Chris@300
|
1006 m_keyReference->registerShortcut(selectOneRightAction);
|
Chris@0
|
1007
|
Chris@6
|
1008 menu->addAction(playAction);
|
Chris@0
|
1009 menu->addAction(psAction);
|
Chris@0
|
1010 menu->addAction(plAction);
|
Chris@0
|
1011 menu->addSeparator();
|
Chris@0
|
1012 menu->addAction(m_rwdAction);
|
Chris@0
|
1013 menu->addAction(m_ffwdAction);
|
Chris@0
|
1014 menu->addSeparator();
|
Chris@0
|
1015 menu->addAction(rwdStartAction);
|
Chris@0
|
1016 menu->addAction(ffwdEndAction);
|
Chris@0
|
1017 menu->addSeparator();
|
Chris@300
|
1018 menu->addAction(oneLeftAction);
|
Chris@300
|
1019 menu->addAction(oneRightAction);
|
Chris@300
|
1020 menu->addAction(selectOneLeftAction);
|
Chris@300
|
1021 menu->addAction(selectOneRightAction);
|
Chris@300
|
1022 menu->addSeparator();
|
Chris@0
|
1023
|
Chris@0
|
1024 m_rightButtonPlaybackMenu->addAction(playAction);
|
Chris@0
|
1025 m_rightButtonPlaybackMenu->addAction(psAction);
|
Chris@0
|
1026 m_rightButtonPlaybackMenu->addAction(plAction);
|
Chris@0
|
1027 m_rightButtonPlaybackMenu->addSeparator();
|
Chris@0
|
1028 m_rightButtonPlaybackMenu->addAction(m_rwdAction);
|
Chris@0
|
1029 m_rightButtonPlaybackMenu->addAction(m_ffwdAction);
|
Chris@0
|
1030 m_rightButtonPlaybackMenu->addSeparator();
|
Chris@0
|
1031 m_rightButtonPlaybackMenu->addAction(rwdStartAction);
|
Chris@0
|
1032 m_rightButtonPlaybackMenu->addAction(ffwdEndAction);
|
Chris@0
|
1033 m_rightButtonPlaybackMenu->addSeparator();
|
Chris@300
|
1034 m_rightButtonPlaybackMenu->addAction(oneLeftAction);
|
Chris@300
|
1035 m_rightButtonPlaybackMenu->addAction(oneRightAction);
|
Chris@300
|
1036 m_rightButtonPlaybackMenu->addAction(selectOneLeftAction);
|
Chris@300
|
1037 m_rightButtonPlaybackMenu->addAction(selectOneRightAction);
|
Chris@300
|
1038 m_rightButtonPlaybackMenu->addSeparator();
|
Chris@0
|
1039
|
Chris@0
|
1040 QAction *fastAction = menu->addAction(tr("Speed Up"));
|
Chris@0
|
1041 fastAction->setShortcut(tr("Ctrl+PgUp"));
|
Chris@0
|
1042 fastAction->setStatusTip(tr("Time-stretch playback to speed it up without changing pitch"));
|
Chris@0
|
1043 connect(fastAction, SIGNAL(triggered()), this, SLOT(speedUpPlayback()));
|
Chris@0
|
1044 connect(this, SIGNAL(canSpeedUpPlayback(bool)), fastAction, SLOT(setEnabled(bool)));
|
Chris@0
|
1045
|
Chris@0
|
1046 QAction *slowAction = menu->addAction(tr("Slow Down"));
|
Chris@0
|
1047 slowAction->setShortcut(tr("Ctrl+PgDown"));
|
Chris@0
|
1048 slowAction->setStatusTip(tr("Time-stretch playback to slow it down without changing pitch"));
|
Chris@0
|
1049 connect(slowAction, SIGNAL(triggered()), this, SLOT(slowDownPlayback()));
|
Chris@0
|
1050 connect(this, SIGNAL(canSlowDownPlayback(bool)), slowAction, SLOT(setEnabled(bool)));
|
Chris@0
|
1051
|
Chris@0
|
1052 QAction *normalAction = menu->addAction(tr("Restore Normal Speed"));
|
Chris@0
|
1053 normalAction->setShortcut(tr("Ctrl+Home"));
|
Chris@0
|
1054 normalAction->setStatusTip(tr("Restore non-time-stretched playback"));
|
Chris@0
|
1055 connect(normalAction, SIGNAL(triggered()), this, SLOT(restoreNormalPlayback()));
|
Chris@0
|
1056 connect(this, SIGNAL(canChangePlaybackSpeed(bool)), normalAction, SLOT(setEnabled(bool)));
|
Chris@0
|
1057
|
Chris@0
|
1058 m_keyReference->registerShortcut(fastAction);
|
Chris@0
|
1059 m_keyReference->registerShortcut(slowAction);
|
Chris@0
|
1060 m_keyReference->registerShortcut(normalAction);
|
Chris@0
|
1061
|
Chris@0
|
1062 m_rightButtonPlaybackMenu->addAction(fastAction);
|
Chris@0
|
1063 m_rightButtonPlaybackMenu->addAction(slowAction);
|
Chris@0
|
1064 m_rightButtonPlaybackMenu->addAction(normalAction);
|
Chris@6
|
1065
|
Chris@195
|
1066 toolbar = new QToolBar(tr("Playback Controls"));
|
Chris@195
|
1067 addToolBar(Qt::BottomToolBarArea, toolbar);
|
Chris@195
|
1068
|
Chris@6
|
1069 toolbar->addWidget(m_playSpeed);
|
Chris@6
|
1070 toolbar->addWidget(m_fader);
|
Chris@0
|
1071
|
Chris@128
|
1072 toolbar = addToolBar(tr("Show and Play"));
|
matthiasm@258
|
1073 addToolBar(Qt::BottomToolBarArea, toolbar);
|
Chris@144
|
1074
|
Chris@144
|
1075 m_showAudio = toolbar->addAction(il.load("waveform"), tr("Show Audio"));
|
Chris@144
|
1076 m_showAudio->setCheckable(true);
|
Chris@144
|
1077 connect(m_showAudio, SIGNAL(triggered()), this, SLOT(showAudioToggled()));
|
Chris@144
|
1078 connect(this, SIGNAL(canPlay(bool)), m_showAudio, SLOT(setEnabled(bool)));
|
Chris@144
|
1079
|
Chris@290
|
1080 m_playAudio = toolbar->addAction(il.load("speaker"), tr("Play Audio"));
|
Chris@290
|
1081 m_playAudio->setCheckable(true);
|
Chris@290
|
1082 connect(m_playAudio, SIGNAL(triggered()), this, SLOT(playAudioToggled()));
|
Chris@291
|
1083 connect(this, SIGNAL(canPlayWaveform(bool)), m_playAudio, SLOT(setEnabled(bool)));
|
Chris@290
|
1084
|
Chris@404
|
1085 m_audioLPW->setFixedWidth(60);
|
Chris@404
|
1086 m_audioLPW->setFixedHeight(60);
|
Chris@404
|
1087 toolbar->addWidget(m_audioLPW);
|
Chris@404
|
1088
|
Chris@290
|
1089 // Pitch (f0)
|
Chris@290
|
1090 QLabel *spacer = new QLabel; // blank
|
Chris@290
|
1091 spacer->setFixedWidth(40);
|
Chris@290
|
1092 toolbar->addWidget(spacer);
|
Chris@145
|
1093
|
Chris@144
|
1094 m_showPitch = toolbar->addAction(il.load("values"), tr("Show Pitch Track"));
|
Chris@144
|
1095 m_showPitch->setCheckable(true);
|
Chris@144
|
1096 connect(m_showPitch, SIGNAL(triggered()), this, SLOT(showPitchToggled()));
|
Chris@144
|
1097 connect(this, SIGNAL(canPlay(bool)), m_showPitch, SLOT(setEnabled(bool)));
|
Chris@144
|
1098
|
Chris@404
|
1099 if (!m_withSonification) {
|
matthiasm@366
|
1100 m_playPitch = new QAction(tr("Play Pitch Track"), this);
|
matthiasm@366
|
1101 } else {
|
matthiasm@366
|
1102 m_playPitch = toolbar->addAction(il.load("speaker"), tr("Play Pitch Track"));
|
Chris@404
|
1103 m_pitchLPW->setFixedWidth(60);
|
Chris@404
|
1104 m_pitchLPW->setFixedHeight(60);
|
Chris@404
|
1105 toolbar->addWidget(m_pitchLPW);
|
matthiasm@366
|
1106 }
|
Chris@404
|
1107
|
Chris@290
|
1108 m_playPitch->setCheckable(true);
|
Chris@290
|
1109 connect(m_playPitch, SIGNAL(triggered()), this, SLOT(playPitchToggled()));
|
Chris@291
|
1110 connect(this, SIGNAL(canPlayPitch(bool)), m_playPitch, SLOT(setEnabled(bool)));
|
Chris@290
|
1111
|
Chris@290
|
1112 // Notes
|
Chris@290
|
1113 spacer = new QLabel;
|
Chris@290
|
1114 spacer->setFixedWidth(40);
|
Chris@290
|
1115 toolbar->addWidget(spacer);
|
Chris@290
|
1116
|
Chris@144
|
1117 m_showNotes = toolbar->addAction(il.load("notes"), tr("Show Notes"));
|
Chris@144
|
1118 m_showNotes->setCheckable(true);
|
Chris@144
|
1119 connect(m_showNotes, SIGNAL(triggered()), this, SLOT(showNotesToggled()));
|
Chris@144
|
1120 connect(this, SIGNAL(canPlay(bool)), m_showNotes, SLOT(setEnabled(bool)));
|
justin@156
|
1121
|
matthiasm@366
|
1122 if (!m_withSonification)
|
matthiasm@366
|
1123 {
|
matthiasm@366
|
1124 m_playNotes = new QAction(tr("Play Notes"), this);
|
matthiasm@366
|
1125 } else {
|
matthiasm@366
|
1126 m_playNotes = toolbar->addAction(il.load("speaker"), tr("Play Notes"));
|
Chris@404
|
1127 m_notesLPW->setFixedWidth(60);
|
Chris@404
|
1128 m_notesLPW->setFixedHeight(60);
|
Chris@404
|
1129 toolbar->addWidget(m_notesLPW);
|
matthiasm@366
|
1130 }
|
justin@156
|
1131 m_playNotes->setCheckable(true);
|
justin@156
|
1132 connect(m_playNotes, SIGNAL(triggered()), this, SLOT(playNotesToggled()));
|
Chris@291
|
1133 connect(this, SIGNAL(canPlayNotes(bool)), m_playNotes, SLOT(setEnabled(bool)));
|
justin@156
|
1134
|
justin@156
|
1135 // Spectrogram
|
Chris@290
|
1136 spacer = new QLabel;
|
Chris@290
|
1137 spacer->setFixedWidth(40);
|
Chris@290
|
1138 toolbar->addWidget(spacer);
|
Chris@290
|
1139
|
matthiasm@366
|
1140 if (!m_withSpectrogram)
|
matthiasm@366
|
1141 {
|
matthiasm@366
|
1142 m_showSpect = new QAction(tr("Show Spectrogram"), this);
|
matthiasm@366
|
1143 } else {
|
matthiasm@366
|
1144 m_showSpect = toolbar->addAction(il.load("spectrogram"), tr("Show Spectrogram"));
|
matthiasm@366
|
1145 }
|
justin@156
|
1146 m_showSpect->setCheckable(true);
|
justin@156
|
1147 connect(m_showSpect, SIGNAL(triggered()), this, SLOT(showSpectToggled()));
|
justin@156
|
1148 connect(this, SIGNAL(canPlay(bool)), m_showSpect, SLOT(setEnabled(bool)));
|
Chris@128
|
1149
|
Chris@0
|
1150 Pane::registerShortcuts(*m_keyReference);
|
matthiasm@366
|
1151
|
Chris@0
|
1152 }
|
Chris@0
|
1153
|
matthiasm@281
|
1154
|
matthiasm@281
|
1155 void
|
matthiasm@281
|
1156 MainWindow::moveOneNoteRight()
|
matthiasm@281
|
1157 {
|
matthiasm@281
|
1158 // cerr << "MainWindow::moveOneNoteRight" << endl;
|
matthiasm@296
|
1159 moveByOneNote(true, false);
|
matthiasm@281
|
1160 }
|
matthiasm@281
|
1161
|
matthiasm@281
|
1162 void
|
matthiasm@281
|
1163 MainWindow::moveOneNoteLeft()
|
matthiasm@281
|
1164 {
|
matthiasm@281
|
1165 // cerr << "MainWindow::moveOneNoteLeft" << endl;
|
matthiasm@296
|
1166 moveByOneNote(false, false);
|
matthiasm@281
|
1167 }
|
matthiasm@281
|
1168
|
matthiasm@281
|
1169 void
|
matthiasm@283
|
1170 MainWindow::selectOneNoteRight()
|
matthiasm@283
|
1171 {
|
matthiasm@296
|
1172 moveByOneNote(true, true);
|
matthiasm@283
|
1173 }
|
matthiasm@283
|
1174
|
matthiasm@283
|
1175 void
|
matthiasm@283
|
1176 MainWindow::selectOneNoteLeft()
|
matthiasm@283
|
1177 {
|
matthiasm@296
|
1178 moveByOneNote(false, true);
|
matthiasm@283
|
1179 }
|
matthiasm@283
|
1180
|
matthiasm@283
|
1181
|
matthiasm@283
|
1182 void
|
matthiasm@296
|
1183 MainWindow::moveByOneNote(bool right, bool doSelect)
|
matthiasm@281
|
1184 {
|
Chris@399
|
1185 sv_frame_t frame = m_viewManager->getPlaybackFrame();
|
matthiasm@301
|
1186 cerr << "MainWindow::moveByOneNote startframe: " << frame << endl;
|
matthiasm@281
|
1187
|
matthiasm@304
|
1188 bool isAtSelectionBoundary = false;
|
matthiasm@304
|
1189 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
matthiasm@304
|
1190 if (!selections.empty()) {
|
matthiasm@304
|
1191 Selection sel = *selections.begin();
|
matthiasm@342
|
1192 isAtSelectionBoundary = (frame == sel.getStartFrame()) || (frame == sel.getEndFrame());
|
matthiasm@304
|
1193 }
|
matthiasm@304
|
1194 if (!doSelect || !isAtSelectionBoundary) {
|
matthiasm@296
|
1195 m_selectionAnchor = frame;
|
matthiasm@296
|
1196 }
|
matthiasm@296
|
1197
|
matthiasm@281
|
1198 Layer *layer = m_analyser->getLayer(Analyser::Notes);
|
matthiasm@281
|
1199 if (!layer) return;
|
matthiasm@281
|
1200
|
matthiasm@281
|
1201 FlexiNoteModel *model = qobject_cast<FlexiNoteModel *>(layer->getModel());
|
matthiasm@281
|
1202 if (!model) return;
|
matthiasm@281
|
1203
|
matthiasm@281
|
1204 FlexiNoteModel::PointList points = model->getPoints();
|
matthiasm@281
|
1205 if (points.empty()) return;
|
matthiasm@281
|
1206
|
matthiasm@281
|
1207 FlexiNoteModel::PointList::iterator i = points.begin();
|
Chris@399
|
1208 std::set<sv_frame_t> snapFrames;
|
matthiasm@281
|
1209 snapFrames.insert(0);
|
matthiasm@281
|
1210 while (i != points.end()) {
|
matthiasm@281
|
1211 snapFrames.insert(i->frame);
|
matthiasm@281
|
1212 snapFrames.insert(i->frame + i->duration + 1);
|
matthiasm@281
|
1213 ++i;
|
matthiasm@281
|
1214 }
|
Chris@399
|
1215 std::set<sv_frame_t>::iterator i2;
|
Chris@399
|
1216 if (snapFrames.find(frame) == snapFrames.end()) {
|
matthiasm@281
|
1217 // we're not on an existing snap point, so go to previous
|
matthiasm@281
|
1218 snapFrames.insert(frame);
|
matthiasm@281
|
1219 }
|
matthiasm@281
|
1220 i2 = snapFrames.find(frame);
|
Chris@399
|
1221 if (right) {
|
matthiasm@281
|
1222 i2++;
|
matthiasm@281
|
1223 if (i2 == snapFrames.end()) i2--;
|
matthiasm@281
|
1224 } else {
|
matthiasm@281
|
1225 if (i2 != snapFrames.begin()) i2--;
|
matthiasm@281
|
1226 }
|
matthiasm@281
|
1227 frame = *i2;
|
matthiasm@281
|
1228 m_viewManager->setPlaybackFrame(frame);
|
matthiasm@296
|
1229 if (doSelect) {
|
matthiasm@296
|
1230 Selection sel;
|
matthiasm@296
|
1231 if (frame > m_selectionAnchor) {
|
matthiasm@342
|
1232 sel = Selection(m_selectionAnchor, frame);
|
matthiasm@296
|
1233 } else {
|
matthiasm@342
|
1234 sel = Selection(frame, m_selectionAnchor);
|
matthiasm@296
|
1235 }
|
matthiasm@296
|
1236 m_viewManager->setSelection(sel);
|
matthiasm@296
|
1237 }
|
matthiasm@301
|
1238 cerr << "MainWindow::moveByOneNote endframe: " << frame << endl;
|
matthiasm@281
|
1239 }
|
matthiasm@281
|
1240
|
Chris@0
|
1241 void
|
Chris@70
|
1242 MainWindow::toolNavigateSelected()
|
Chris@70
|
1243 {
|
Chris@70
|
1244 m_viewManager->setToolMode(ViewManager::NavigateMode);
|
Chris@70
|
1245 m_intelligentActionOn = true;
|
Chris@70
|
1246 }
|
Chris@70
|
1247
|
Chris@70
|
1248 void
|
Chris@70
|
1249 MainWindow::toolEditSelected()
|
Chris@70
|
1250 {
|
matthiasm@294
|
1251 cerr << "MainWindow::toolEditSelected" << endl;
|
Chris@77
|
1252 m_viewManager->setToolMode(ViewManager::NoteEditMode);
|
Chris@70
|
1253 m_intelligentActionOn = true;
|
Chris@70
|
1254 m_analyser->setIntelligentActions(m_intelligentActionOn);
|
Chris@70
|
1255 }
|
Chris@70
|
1256
|
Chris@70
|
1257 void
|
Chris@70
|
1258 MainWindow::toolFreeEditSelected()
|
Chris@70
|
1259 {
|
Chris@77
|
1260 m_viewManager->setToolMode(ViewManager::NoteEditMode);
|
Chris@70
|
1261 m_intelligentActionOn = false;
|
Chris@70
|
1262 m_analyser->setIntelligentActions(m_intelligentActionOn);
|
Chris@70
|
1263 }
|
Chris@70
|
1264
|
gyorgyf@21
|
1265 void
|
Chris@0
|
1266 MainWindow::updateMenuStates()
|
Chris@0
|
1267 {
|
Chris@0
|
1268 MainWindowBase::updateMenuStates();
|
Chris@0
|
1269
|
Chris@0
|
1270 Pane *currentPane = 0;
|
Chris@0
|
1271 Layer *currentLayer = 0;
|
Chris@0
|
1272
|
Chris@0
|
1273 if (m_paneStack) currentPane = m_paneStack->getCurrentPane();
|
Chris@0
|
1274 if (currentPane) currentLayer = currentPane->getSelectedLayer();
|
Chris@0
|
1275
|
Chris@291
|
1276 bool haveMainModel =
|
Chris@291
|
1277 (getMainModel() != 0);
|
Chris@291
|
1278 bool havePlayTarget =
|
Chris@291
|
1279 (m_playTarget != 0);
|
Chris@0
|
1280 bool haveCurrentPane =
|
Chris@0
|
1281 (currentPane != 0);
|
Chris@0
|
1282 bool haveCurrentLayer =
|
Chris@0
|
1283 (haveCurrentPane &&
|
Chris@0
|
1284 (currentLayer != 0));
|
Chris@0
|
1285 bool haveSelection =
|
Chris@187
|
1286 (m_viewManager &&
|
Chris@187
|
1287 !m_viewManager->getSelections().empty());
|
Chris@0
|
1288 bool haveCurrentTimeInstantsLayer =
|
Chris@187
|
1289 (haveCurrentLayer &&
|
Chris@187
|
1290 qobject_cast<TimeInstantLayer *>(currentLayer));
|
Chris@0
|
1291 bool haveCurrentTimeValueLayer =
|
Chris@187
|
1292 (haveCurrentLayer &&
|
Chris@187
|
1293 qobject_cast<TimeValueLayer *>(currentLayer));
|
Chris@187
|
1294 bool pitchCandidatesVisible =
|
Chris@187
|
1295 m_analyser->arePitchCandidatesShown();
|
Chris@0
|
1296
|
Chris@0
|
1297 emit canChangePlaybackSpeed(true);
|
Chris@0
|
1298 int v = m_playSpeed->value();
|
Chris@0
|
1299 emit canSpeedUpPlayback(v < m_playSpeed->maximum());
|
Chris@0
|
1300 emit canSlowDownPlayback(v > m_playSpeed->minimum());
|
Chris@0
|
1301
|
Chris@291
|
1302 bool haveWaveform =
|
Chris@291
|
1303 m_analyser->isVisible(Analyser::Audio) &&
|
Chris@291
|
1304 m_analyser->getLayer(Analyser::Audio);
|
Chris@291
|
1305
|
Chris@237
|
1306 bool havePitchTrack =
|
Chris@237
|
1307 m_analyser->isVisible(Analyser::PitchTrack) &&
|
Chris@237
|
1308 m_analyser->getLayer(Analyser::PitchTrack);
|
Chris@237
|
1309
|
Chris@237
|
1310 bool haveNotes =
|
Chris@237
|
1311 m_analyser->isVisible(Analyser::Notes) &&
|
Chris@237
|
1312 m_analyser->getLayer(Analyser::Notes);
|
Chris@237
|
1313
|
Chris@237
|
1314 emit canExportPitchTrack(havePitchTrack);
|
Chris@237
|
1315 emit canExportNotes(haveNotes);
|
Chris@237
|
1316 emit canSnapNotes(haveSelection && haveNotes);
|
Chris@224
|
1317
|
Chris@291
|
1318 emit canPlayWaveform(haveWaveform && haveMainModel && havePlayTarget);
|
Chris@291
|
1319 emit canPlayPitch(havePitchTrack && haveMainModel && havePlayTarget);
|
Chris@291
|
1320 emit canPlayNotes(haveNotes && haveMainModel && havePlayTarget);
|
Chris@291
|
1321
|
Chris@187
|
1322 if (pitchCandidatesVisible) {
|
Chris@187
|
1323 m_showCandidatesAction->setText(tr("Hide Pitch Candidates"));
|
Chris@187
|
1324 m_showCandidatesAction->setStatusTip(tr("Remove the display of alternate pitch candidates for the selected region"));
|
Chris@187
|
1325 } else {
|
Chris@187
|
1326 m_showCandidatesAction->setText(tr("Show Pitch Candidates"));
|
Chris@187
|
1327 m_showCandidatesAction->setStatusTip(tr("Show alternate pitch candidates for the selected region"));
|
Chris@187
|
1328 }
|
Chris@187
|
1329
|
Chris@0
|
1330 if (m_ffwdAction && m_rwdAction) {
|
Chris@0
|
1331 if (haveCurrentTimeInstantsLayer) {
|
Chris@0
|
1332 m_ffwdAction->setText(tr("Fast Forward to Next Instant"));
|
Chris@0
|
1333 m_ffwdAction->setStatusTip(tr("Fast forward to the next time instant in the current layer"));
|
Chris@0
|
1334 m_rwdAction->setText(tr("Rewind to Previous Instant"));
|
Chris@0
|
1335 m_rwdAction->setStatusTip(tr("Rewind to the previous time instant in the current layer"));
|
Chris@0
|
1336 } else if (haveCurrentTimeValueLayer) {
|
Chris@0
|
1337 m_ffwdAction->setText(tr("Fast Forward to Next Point"));
|
Chris@0
|
1338 m_ffwdAction->setStatusTip(tr("Fast forward to the next point in the current layer"));
|
Chris@0
|
1339 m_rwdAction->setText(tr("Rewind to Previous Point"));
|
Chris@0
|
1340 m_rwdAction->setStatusTip(tr("Rewind to the previous point in the current layer"));
|
Chris@0
|
1341 } else {
|
Chris@0
|
1342 m_ffwdAction->setText(tr("Fast Forward"));
|
Chris@0
|
1343 m_ffwdAction->setStatusTip(tr("Fast forward"));
|
Chris@0
|
1344 m_rwdAction->setText(tr("Rewind"));
|
Chris@0
|
1345 m_rwdAction->setStatusTip(tr("Rewind"));
|
Chris@0
|
1346 }
|
Chris@0
|
1347 }
|
Chris@0
|
1348 }
|
Chris@0
|
1349
|
Chris@0
|
1350 void
|
Chris@144
|
1351 MainWindow::showAudioToggled()
|
Chris@128
|
1352 {
|
Chris@144
|
1353 m_analyser->toggleVisible(Analyser::Audio);
|
justin@220
|
1354
|
Chris@291
|
1355 QSettings settings;
|
Chris@291
|
1356 settings.beginGroup("MainWindow");
|
Chris@291
|
1357
|
Chris@291
|
1358 bool playOn = false;
|
Chris@291
|
1359 if (m_analyser->isVisible(Analyser::Audio)) {
|
Chris@291
|
1360 // just switched layer on; check whether playback was also on previously
|
Chris@291
|
1361 playOn = settings.value("playaudiowas", true).toBool();
|
Chris@291
|
1362 } else {
|
Chris@291
|
1363 settings.setValue("playaudiowas", m_playAudio->isChecked());
|
justin@220
|
1364 }
|
Chris@291
|
1365 m_analyser->setAudible(Analyser::Audio, playOn);
|
Chris@291
|
1366 m_playAudio->setChecked(playOn);
|
Chris@291
|
1367
|
Chris@291
|
1368 settings.endGroup();
|
Chris@291
|
1369
|
Chris@291
|
1370 updateMenuStates();
|
Chris@128
|
1371 }
|
Chris@128
|
1372
|
Chris@128
|
1373 void
|
Chris@144
|
1374 MainWindow::showPitchToggled()
|
Chris@128
|
1375 {
|
Chris@144
|
1376 m_analyser->toggleVisible(Analyser::PitchTrack);
|
justin@185
|
1377
|
Chris@291
|
1378 QSettings settings;
|
Chris@291
|
1379 settings.beginGroup("MainWindow");
|
Chris@291
|
1380
|
Chris@291
|
1381 bool playOn = false;
|
Chris@291
|
1382 if (m_analyser->isVisible(Analyser::PitchTrack)) {
|
Chris@291
|
1383 // just switched layer on; check whether playback was also on previously
|
Chris@291
|
1384 playOn = settings.value("playpitchwas", true).toBool();
|
Chris@291
|
1385 } else {
|
Chris@291
|
1386 settings.setValue("playpitchwas", m_playPitch->isChecked());
|
justin@185
|
1387 }
|
matthiasm@384
|
1388 m_analyser->setAudible(Analyser::PitchTrack, playOn && m_withSonification);
|
Chris@291
|
1389 m_playPitch->setChecked(playOn);
|
Chris@291
|
1390
|
Chris@291
|
1391 settings.endGroup();
|
Chris@291
|
1392
|
Chris@291
|
1393 updateMenuStates();
|
Chris@128
|
1394 }
|
Chris@128
|
1395
|
Chris@128
|
1396 void
|
Chris@145
|
1397 MainWindow::showSpectToggled()
|
Chris@145
|
1398 {
|
Chris@145
|
1399 m_analyser->toggleVisible(Analyser::Spectrogram);
|
Chris@145
|
1400 }
|
Chris@145
|
1401
|
Chris@145
|
1402 void
|
Chris@144
|
1403 MainWindow::showNotesToggled()
|
Chris@128
|
1404 {
|
Chris@144
|
1405 m_analyser->toggleVisible(Analyser::Notes);
|
justin@220
|
1406
|
Chris@291
|
1407 QSettings settings;
|
Chris@291
|
1408 settings.beginGroup("MainWindow");
|
Chris@291
|
1409
|
Chris@291
|
1410 bool playOn = false;
|
Chris@291
|
1411 if (m_analyser->isVisible(Analyser::Notes)) {
|
Chris@291
|
1412 // just switched layer on; check whether playback was also on previously
|
Chris@291
|
1413 playOn = settings.value("playnoteswas", true).toBool();
|
Chris@291
|
1414 } else {
|
Chris@291
|
1415 settings.setValue("playnoteswas", m_playNotes->isChecked());
|
justin@220
|
1416 }
|
matthiasm@384
|
1417 m_analyser->setAudible(Analyser::Notes, playOn && m_withSonification);
|
Chris@291
|
1418 m_playNotes->setChecked(playOn);
|
Chris@291
|
1419
|
Chris@291
|
1420 settings.endGroup();
|
Chris@291
|
1421
|
Chris@291
|
1422 updateMenuStates();
|
Chris@144
|
1423 }
|
Chris@144
|
1424
|
Chris@144
|
1425 void
|
Chris@144
|
1426 MainWindow::playAudioToggled()
|
Chris@144
|
1427 {
|
Chris@144
|
1428 m_analyser->toggleAudible(Analyser::Audio);
|
Chris@144
|
1429 }
|
Chris@144
|
1430
|
Chris@144
|
1431 void
|
Chris@144
|
1432 MainWindow::playPitchToggled()
|
Chris@144
|
1433 {
|
Chris@144
|
1434 m_analyser->toggleAudible(Analyser::PitchTrack);
|
Chris@144
|
1435 }
|
Chris@144
|
1436
|
Chris@144
|
1437 void
|
Chris@144
|
1438 MainWindow::playNotesToggled()
|
Chris@144
|
1439 {
|
Chris@144
|
1440 m_analyser->toggleAudible(Analyser::Notes);
|
Chris@144
|
1441 }
|
Chris@144
|
1442
|
Chris@144
|
1443 void
|
Chris@144
|
1444 MainWindow::updateLayerStatuses()
|
Chris@144
|
1445 {
|
Chris@144
|
1446 m_showAudio->setChecked(m_analyser->isVisible(Analyser::Audio));
|
Chris@145
|
1447 m_showSpect->setChecked(m_analyser->isVisible(Analyser::Spectrogram));
|
Chris@144
|
1448 m_showPitch->setChecked(m_analyser->isVisible(Analyser::PitchTrack));
|
Chris@144
|
1449 m_showNotes->setChecked(m_analyser->isVisible(Analyser::Notes));
|
Chris@144
|
1450 m_playAudio->setChecked(m_analyser->isAudible(Analyser::Audio));
|
Chris@144
|
1451 m_playPitch->setChecked(m_analyser->isAudible(Analyser::PitchTrack));
|
Chris@144
|
1452 m_playNotes->setChecked(m_analyser->isAudible(Analyser::Notes));
|
Chris@128
|
1453 }
|
Chris@128
|
1454
|
Chris@128
|
1455 void
|
Chris@227
|
1456 MainWindow::editDisplayExtents()
|
Chris@227
|
1457 {
|
Chris@399
|
1458 double min, max;
|
Chris@399
|
1459 double vmin = 0;
|
Chris@399
|
1460 double vmax = getMainModel()->getSampleRate() /2;
|
Chris@227
|
1461
|
Chris@227
|
1462 if (!m_analyser->getDisplayFrequencyExtents(min, max)) {
|
Chris@227
|
1463 //!!!
|
Chris@227
|
1464 return;
|
Chris@227
|
1465 }
|
Chris@227
|
1466
|
Chris@227
|
1467 RangeInputDialog dialog(tr("Set frequency range"),
|
Chris@227
|
1468 tr("Enter new frequency range, from %1 to %2 Hz.\nThese values will be rounded to the nearest spectrogram bin.")
|
Chris@227
|
1469 .arg(vmin).arg(vmax),
|
Chris@399
|
1470 "Hz", float(vmin), float(vmax), this);
|
Chris@399
|
1471 dialog.setRange(float(min), float(max));
|
Chris@227
|
1472
|
Chris@227
|
1473 if (dialog.exec() == QDialog::Accepted) {
|
Chris@399
|
1474 float fmin, fmax;
|
Chris@399
|
1475 dialog.getRange(fmin, fmax);
|
Chris@399
|
1476 min = fmin;
|
Chris@399
|
1477 max = fmax;
|
Chris@227
|
1478 if (min > max) {
|
Chris@399
|
1479 double tmp = max;
|
Chris@227
|
1480 max = min;
|
Chris@227
|
1481 min = tmp;
|
Chris@227
|
1482 }
|
Chris@227
|
1483 m_analyser->setDisplayFrequencyExtents(min, max);
|
Chris@227
|
1484 }
|
Chris@227
|
1485 }
|
Chris@227
|
1486
|
Chris@227
|
1487 void
|
Chris@0
|
1488 MainWindow::updateDescriptionLabel()
|
Chris@0
|
1489 {
|
Chris@6
|
1490 // Nothing, we don't have one
|
Chris@0
|
1491 }
|
Chris@0
|
1492
|
Chris@0
|
1493 void
|
Chris@0
|
1494 MainWindow::documentModified()
|
Chris@0
|
1495 {
|
Chris@0
|
1496 MainWindowBase::documentModified();
|
Chris@0
|
1497 }
|
Chris@0
|
1498
|
Chris@0
|
1499 void
|
Chris@0
|
1500 MainWindow::documentRestored()
|
Chris@0
|
1501 {
|
Chris@0
|
1502 MainWindowBase::documentRestored();
|
Chris@0
|
1503 }
|
Chris@0
|
1504
|
Chris@0
|
1505 void
|
Chris@0
|
1506 MainWindow::newSession()
|
Chris@0
|
1507 {
|
Chris@0
|
1508 if (!checkSaveModified()) return;
|
Chris@0
|
1509
|
Chris@0
|
1510 closeSession();
|
Chris@0
|
1511 createDocument();
|
Chris@0
|
1512 m_document->setAutoAlignment(true);
|
Chris@0
|
1513
|
Chris@0
|
1514 Pane *pane = m_paneStack->addPane();
|
Chris@362
|
1515 pane->setPlaybackFollow(PlaybackScrollPage);
|
Chris@0
|
1516
|
Chris@391
|
1517 m_viewManager->setGlobalCentreFrame
|
Chris@391
|
1518 (pane->getFrameForX(width() / 2));
|
Chris@391
|
1519
|
Chris@0
|
1520 connect(pane, SIGNAL(contextHelpChanged(const QString &)),
|
Chris@0
|
1521 this, SLOT(contextHelpChanged(const QString &)));
|
Chris@0
|
1522
|
Chris@6
|
1523 // Layer *waveform = m_document->createMainModelLayer(LayerFactory::Waveform);
|
Chris@6
|
1524 // m_document->addLayerToView(pane, waveform);
|
Chris@0
|
1525
|
Chris@0
|
1526 m_overview->registerView(pane);
|
Chris@0
|
1527
|
Chris@0
|
1528 CommandHistory::getInstance()->clear();
|
Chris@0
|
1529 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
1530 documentRestored();
|
Chris@0
|
1531 updateMenuStates();
|
Chris@0
|
1532 }
|
Chris@0
|
1533
|
Chris@0
|
1534 void
|
Chris@244
|
1535 MainWindow::documentReplaced()
|
Chris@244
|
1536 {
|
Chris@244
|
1537 if (m_document) {
|
Chris@244
|
1538 connect(m_document, SIGNAL(activity(QString)),
|
Chris@244
|
1539 m_activityLog, SLOT(activityHappened(QString)));
|
Chris@244
|
1540 }
|
Chris@244
|
1541 }
|
Chris@244
|
1542
|
Chris@244
|
1543 void
|
Chris@0
|
1544 MainWindow::closeSession()
|
Chris@0
|
1545 {
|
Chris@0
|
1546 if (!checkSaveModified()) return;
|
Chris@0
|
1547
|
Chris@226
|
1548 m_analyser->fileClosed();
|
Chris@226
|
1549
|
Chris@0
|
1550 while (m_paneStack->getPaneCount() > 0) {
|
Chris@0
|
1551
|
Chris@167
|
1552 Pane *pane = m_paneStack->getPane(m_paneStack->getPaneCount() - 1);
|
Chris@0
|
1553
|
Chris@167
|
1554 while (pane->getLayerCount() > 0) {
|
Chris@167
|
1555 m_document->removeLayerFromView
|
Chris@167
|
1556 (pane, pane->getLayer(pane->getLayerCount() - 1));
|
Chris@167
|
1557 }
|
Chris@167
|
1558
|
Chris@167
|
1559 m_overview->unregisterView(pane);
|
Chris@167
|
1560 m_paneStack->deletePane(pane);
|
Chris@0
|
1561 }
|
Chris@0
|
1562
|
Chris@0
|
1563 while (m_paneStack->getHiddenPaneCount() > 0) {
|
Chris@0
|
1564
|
Chris@167
|
1565 Pane *pane = m_paneStack->getHiddenPane
|
Chris@167
|
1566 (m_paneStack->getHiddenPaneCount() - 1);
|
Chris@167
|
1567
|
Chris@167
|
1568 while (pane->getLayerCount() > 0) {
|
Chris@167
|
1569 m_document->removeLayerFromView
|
Chris@167
|
1570 (pane, pane->getLayer(pane->getLayerCount() - 1));
|
Chris@167
|
1571 }
|
Chris@167
|
1572
|
Chris@167
|
1573 m_overview->unregisterView(pane);
|
Chris@167
|
1574 m_paneStack->deletePane(pane);
|
Chris@0
|
1575 }
|
Chris@0
|
1576
|
Chris@0
|
1577 delete m_document;
|
Chris@0
|
1578 m_document = 0;
|
Chris@0
|
1579 m_viewManager->clearSelections();
|
Chris@0
|
1580 m_timeRulerLayer = 0; // document owned this
|
Chris@0
|
1581
|
Chris@0
|
1582 m_sessionFile = "";
|
Chris@0
|
1583
|
Chris@0
|
1584 CommandHistory::getInstance()->clear();
|
Chris@0
|
1585 CommandHistory::getInstance()->documentSaved();
|
Chris@0
|
1586 documentRestored();
|
Chris@0
|
1587 }
|
Chris@0
|
1588
|
Chris@0
|
1589 void
|
Chris@0
|
1590 MainWindow::openFile()
|
Chris@0
|
1591 {
|
Chris@0
|
1592 QString orig = m_audioFile;
|
Chris@0
|
1593 if (orig == "") orig = ".";
|
Chris@0
|
1594 else orig = QFileInfo(orig).absoluteDir().canonicalPath();
|
Chris@0
|
1595
|
Chris@0
|
1596 QString path = getOpenFileName(FileFinder::AnyFile);
|
Chris@0
|
1597
|
Chris@0
|
1598 if (path.isEmpty()) return;
|
Chris@0
|
1599
|
Chris@387
|
1600 FileOpenStatus status = openPath(path, ReplaceSession);
|
Chris@0
|
1601
|
Chris@0
|
1602 if (status == FileOpenFailed) {
|
Chris@0
|
1603 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@0
|
1604 tr("<b>File open failed</b><p>File \"%1\" could not be opened").arg(path));
|
Chris@0
|
1605 } else if (status == FileOpenWrongMode) {
|
Chris@0
|
1606 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@0
|
1607 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
|
Chris@0
|
1608 }
|
Chris@0
|
1609 }
|
Chris@0
|
1610
|
Chris@0
|
1611 void
|
Chris@0
|
1612 MainWindow::openLocation()
|
Chris@0
|
1613 {
|
Chris@0
|
1614 QSettings settings;
|
Chris@0
|
1615 settings.beginGroup("MainWindow");
|
Chris@0
|
1616 QString lastLocation = settings.value("lastremote", "").toString();
|
Chris@0
|
1617
|
Chris@0
|
1618 bool ok = false;
|
Chris@0
|
1619 QString text = QInputDialog::getText
|
Chris@0
|
1620 (this, tr("Open Location"),
|
Chris@0
|
1621 tr("Please enter the URL of the location to open:"),
|
Chris@0
|
1622 QLineEdit::Normal, lastLocation, &ok);
|
Chris@0
|
1623
|
Chris@0
|
1624 if (!ok) return;
|
Chris@0
|
1625
|
Chris@0
|
1626 settings.setValue("lastremote", text);
|
Chris@0
|
1627
|
Chris@0
|
1628 if (text.isEmpty()) return;
|
Chris@0
|
1629
|
Chris@387
|
1630 FileOpenStatus status = openPath(text, ReplaceSession);
|
Chris@0
|
1631
|
Chris@0
|
1632 if (status == FileOpenFailed) {
|
Chris@0
|
1633 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@0
|
1634 tr("<b>Open failed</b><p>URL \"%1\" could not be opened").arg(text));
|
Chris@0
|
1635 } else if (status == FileOpenWrongMode) {
|
Chris@0
|
1636 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@0
|
1637 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
|
Chris@0
|
1638 }
|
Chris@0
|
1639 }
|
Chris@0
|
1640
|
Chris@0
|
1641 void
|
Chris@0
|
1642 MainWindow::openRecentFile()
|
Chris@0
|
1643 {
|
Chris@0
|
1644 QObject *obj = sender();
|
Chris@3
|
1645 QAction *action = qobject_cast<QAction *>(obj);
|
Chris@0
|
1646
|
Chris@0
|
1647 if (!action) {
|
Chris@188
|
1648 cerr << "WARNING: MainWindow::openRecentFile: sender is not an action"
|
Chris@188
|
1649 << endl;
|
Chris@188
|
1650 return;
|
Chris@0
|
1651 }
|
Chris@0
|
1652
|
Chris@0
|
1653 QString path = action->text();
|
Chris@0
|
1654 if (path == "") return;
|
Chris@0
|
1655
|
Chris@387
|
1656 FileOpenStatus status = openPath(path, ReplaceSession);
|
Chris@0
|
1657
|
Chris@0
|
1658 if (status == FileOpenFailed) {
|
Chris@0
|
1659 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@0
|
1660 tr("<b>Open failed</b><p>File or URL \"%1\" could not be opened").arg(path));
|
Chris@0
|
1661 } else if (status == FileOpenWrongMode) {
|
Chris@0
|
1662 QMessageBox::critical(this, tr("Failed to open location"),
|
Chris@0
|
1663 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
|
Chris@0
|
1664 }
|
Chris@0
|
1665 }
|
Chris@0
|
1666
|
Chris@0
|
1667 void
|
Chris@0
|
1668 MainWindow::paneAdded(Pane *pane)
|
Chris@0
|
1669 {
|
Chris@6
|
1670 pane->setPlaybackFollow(PlaybackScrollPage);
|
Chris@0
|
1671 m_paneStack->sizePanesEqually();
|
Chris@0
|
1672 if (m_overview) m_overview->registerView(pane);
|
Chris@0
|
1673 }
|
Chris@0
|
1674
|
Chris@0
|
1675 void
|
Chris@0
|
1676 MainWindow::paneHidden(Pane *pane)
|
Chris@0
|
1677 {
|
Chris@0
|
1678 if (m_overview) m_overview->unregisterView(pane);
|
Chris@0
|
1679 }
|
Chris@0
|
1680
|
Chris@0
|
1681 void
|
Chris@0
|
1682 MainWindow::paneAboutToBeDeleted(Pane *pane)
|
Chris@0
|
1683 {
|
Chris@0
|
1684 if (m_overview) m_overview->unregisterView(pane);
|
Chris@0
|
1685 }
|
Chris@0
|
1686
|
Chris@0
|
1687 void
|
Chris@0
|
1688 MainWindow::paneDropAccepted(Pane *pane, QStringList uriList)
|
Chris@0
|
1689 {
|
Chris@4
|
1690 if (pane) m_paneStack->setCurrentPane(pane);
|
Chris@0
|
1691
|
Chris@0
|
1692 for (QStringList::iterator i = uriList.begin(); i != uriList.end(); ++i) {
|
Chris@0
|
1693
|
Chris@387
|
1694 FileOpenStatus status = openPath(*i, ReplaceSession);
|
Chris@0
|
1695
|
Chris@0
|
1696 if (status == FileOpenFailed) {
|
Chris@0
|
1697 QMessageBox::critical(this, tr("Failed to open dropped URL"),
|
Chris@0
|
1698 tr("<b>Open failed</b><p>Dropped URL \"%1\" could not be opened").arg(*i));
|
Chris@0
|
1699 } else if (status == FileOpenWrongMode) {
|
Chris@0
|
1700 QMessageBox::critical(this, tr("Failed to open dropped URL"),
|
Chris@0
|
1701 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
|
Chris@0
|
1702 }
|
Chris@0
|
1703 }
|
Chris@0
|
1704 }
|
Chris@0
|
1705
|
Chris@0
|
1706 void
|
Chris@0
|
1707 MainWindow::paneDropAccepted(Pane *pane, QString text)
|
Chris@0
|
1708 {
|
Chris@0
|
1709 if (pane) m_paneStack->setCurrentPane(pane);
|
Chris@0
|
1710
|
Chris@0
|
1711 QUrl testUrl(text);
|
Chris@0
|
1712 if (testUrl.scheme() == "file" ||
|
Chris@0
|
1713 testUrl.scheme() == "http" ||
|
Chris@0
|
1714 testUrl.scheme() == "ftp") {
|
Chris@0
|
1715 QStringList list;
|
Chris@0
|
1716 list.push_back(text);
|
Chris@0
|
1717 paneDropAccepted(pane, list);
|
Chris@0
|
1718 return;
|
Chris@0
|
1719 }
|
Chris@0
|
1720
|
Chris@0
|
1721 //!!! open as text -- but by importing as if a CSV, or just adding
|
Chris@0
|
1722 //to a text layer?
|
Chris@0
|
1723 }
|
Chris@0
|
1724
|
Chris@0
|
1725 void
|
Chris@0
|
1726 MainWindow::closeEvent(QCloseEvent *e)
|
Chris@0
|
1727 {
|
Chris@70
|
1728 // cerr << "MainWindow::closeEvent" << endl;
|
Chris@0
|
1729
|
Chris@0
|
1730 if (m_openingAudioFile) {
|
Chris@70
|
1731 // cerr << "Busy - ignoring close event" << endl;
|
Chris@257
|
1732 e->ignore();
|
Chris@257
|
1733 return;
|
Chris@0
|
1734 }
|
Chris@0
|
1735
|
Chris@0
|
1736 if (!m_abandoning && !checkSaveModified()) {
|
Chris@70
|
1737 // cerr << "Ignoring close event" << endl;
|
Chris@257
|
1738 e->ignore();
|
Chris@257
|
1739 return;
|
Chris@0
|
1740 }
|
Chris@0
|
1741
|
Chris@0
|
1742 QSettings settings;
|
Chris@0
|
1743 settings.beginGroup("MainWindow");
|
Chris@0
|
1744 settings.setValue("size", size());
|
Chris@0
|
1745 settings.setValue("position", pos());
|
Chris@0
|
1746 settings.endGroup();
|
Chris@0
|
1747
|
Chris@0
|
1748 delete m_keyReference;
|
Chris@0
|
1749 m_keyReference = 0;
|
Chris@0
|
1750
|
Chris@0
|
1751 closeSession();
|
Chris@0
|
1752
|
Chris@0
|
1753 e->accept();
|
Chris@0
|
1754 return;
|
Chris@0
|
1755 }
|
Chris@0
|
1756
|
Chris@0
|
1757 bool
|
Chris@0
|
1758 MainWindow::commitData(bool mayAskUser)
|
Chris@0
|
1759 {
|
Chris@0
|
1760 if (mayAskUser) {
|
Chris@0
|
1761 bool rv = checkSaveModified();
|
Chris@0
|
1762 return rv;
|
Chris@0
|
1763 } else {
|
Chris@0
|
1764 if (!m_documentModified) return true;
|
Chris@0
|
1765
|
Chris@0
|
1766 // If we can't check with the user first, then we can't save
|
Chris@0
|
1767 // to the original session file (even if we have it) -- have
|
Chris@0
|
1768 // to use a temporary file
|
Chris@0
|
1769
|
Chris@0
|
1770 QString svDirBase = ".sv1";
|
Chris@0
|
1771 QString svDir = QDir::home().filePath(svDirBase);
|
Chris@0
|
1772
|
Chris@0
|
1773 if (!QFileInfo(svDir).exists()) {
|
Chris@0
|
1774 if (!QDir::home().mkdir(svDirBase)) return false;
|
Chris@0
|
1775 } else {
|
Chris@0
|
1776 if (!QFileInfo(svDir).isDir()) return false;
|
Chris@0
|
1777 }
|
Chris@0
|
1778
|
Chris@0
|
1779 // This name doesn't have to be unguessable
|
Chris@0
|
1780 #ifndef _WIN32
|
Chris@0
|
1781 QString fname = QString("tmp-%1-%2.sv")
|
Chris@0
|
1782 .arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmsszzz"))
|
Chris@0
|
1783 .arg(QProcess().pid());
|
Chris@0
|
1784 #else
|
Chris@0
|
1785 QString fname = QString("tmp-%1.sv")
|
Chris@0
|
1786 .arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmsszzz"));
|
Chris@0
|
1787 #endif
|
Chris@0
|
1788 QString fpath = QDir(svDir).filePath(fname);
|
Chris@0
|
1789 if (saveSessionFile(fpath)) {
|
Chris@0
|
1790 m_recentFiles.addFile(fpath);
|
Chris@0
|
1791 return true;
|
Chris@0
|
1792 } else {
|
Chris@0
|
1793 return false;
|
Chris@0
|
1794 }
|
Chris@0
|
1795 }
|
Chris@0
|
1796 }
|
Chris@0
|
1797
|
Chris@0
|
1798 bool
|
Chris@0
|
1799 MainWindow::checkSaveModified()
|
Chris@0
|
1800 {
|
Chris@0
|
1801 // Called before some destructive operation (e.g. new session,
|
Chris@0
|
1802 // exit program). Return true if we can safely proceed, false to
|
Chris@0
|
1803 // cancel.
|
Chris@0
|
1804
|
Chris@0
|
1805 if (!m_documentModified) return true;
|
Chris@0
|
1806
|
Chris@0
|
1807 int button =
|
Chris@257
|
1808 QMessageBox::warning(this,
|
Chris@257
|
1809 tr("Session modified"),
|
Chris@257
|
1810 tr("The current session has been modified.\nDo you want to save it?"),
|
Chris@257
|
1811 QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,
|
Chris@0
|
1812 QMessageBox::Yes);
|
Chris@0
|
1813
|
Chris@0
|
1814 if (button == QMessageBox::Yes) {
|
Chris@257
|
1815 saveSession();
|
Chris@257
|
1816 if (m_documentModified) { // save failed -- don't proceed!
|
Chris@257
|
1817 return false;
|
Chris@257
|
1818 } else {
|
Chris@0
|
1819 return true; // saved, so it's safe to continue now
|
Chris@0
|
1820 }
|
Chris@0
|
1821 } else if (button == QMessageBox::No) {
|
Chris@257
|
1822 m_documentModified = false; // so we know to abandon it
|
Chris@257
|
1823 return true;
|
Chris@0
|
1824 }
|
Chris@0
|
1825
|
Chris@0
|
1826 // else cancel
|
Chris@0
|
1827 return false;
|
Chris@0
|
1828 }
|
Chris@0
|
1829
|
Chris@314
|
1830 bool
|
Chris@314
|
1831 MainWindow::waitForInitialAnalysis()
|
Chris@314
|
1832 {
|
Chris@314
|
1833 // Called before saving a session. We can't safely save while the
|
Chris@314
|
1834 // initial analysis is happening, because then we end up with an
|
Chris@314
|
1835 // incomplete session on reload. There are certainly theoretically
|
Chris@314
|
1836 // better ways to handle this...
|
Chris@314
|
1837
|
Chris@330
|
1838 QSettings settings;
|
Chris@330
|
1839 settings.beginGroup("Analyser");
|
Chris@330
|
1840 bool autoAnalyse = settings.value("auto-analysis", true).toBool();
|
Chris@330
|
1841 settings.endGroup();
|
Chris@330
|
1842
|
Chris@330
|
1843 if (!autoAnalyse) {
|
Chris@330
|
1844 return true;
|
Chris@330
|
1845 }
|
Chris@330
|
1846
|
Chris@314
|
1847 if (!m_analyser || m_analyser->getInitialAnalysisCompletion() >= 100) {
|
Chris@314
|
1848 return true;
|
Chris@314
|
1849 }
|
Chris@314
|
1850
|
Chris@314
|
1851 QMessageBox mb(QMessageBox::Information,
|
Chris@314
|
1852 tr("Waiting for analysis"),
|
Chris@314
|
1853 tr("Waiting for initial analysis to complete before saving..."),
|
Chris@314
|
1854 QMessageBox::Cancel,
|
Chris@314
|
1855 this);
|
Chris@314
|
1856
|
Chris@314
|
1857 connect(m_analyser, SIGNAL(initialAnalysisCompleted()),
|
Chris@314
|
1858 &mb, SLOT(accept()));
|
Chris@314
|
1859
|
Chris@314
|
1860 if (mb.exec() == QDialog::Accepted) {
|
Chris@314
|
1861 return true;
|
Chris@314
|
1862 } else {
|
Chris@314
|
1863 return false;
|
Chris@314
|
1864 }
|
Chris@314
|
1865 }
|
Chris@314
|
1866
|
Chris@0
|
1867 void
|
Chris@0
|
1868 MainWindow::saveSession()
|
Chris@0
|
1869 {
|
Chris@269
|
1870 // We do not want to save mid-analysis regions -- that would cause
|
Chris@269
|
1871 // confusion on reloading
|
Chris@269
|
1872 m_analyser->clearReAnalysis();
|
Chris@269
|
1873 clearSelection();
|
Chris@269
|
1874
|
Chris@0
|
1875 if (m_sessionFile != "") {
|
Chris@257
|
1876 if (!saveSessionFile(m_sessionFile)) {
|
Chris@257
|
1877 QMessageBox::critical
|
Chris@257
|
1878 (this, tr("Failed to save file"),
|
Chris@257
|
1879 tr("Session file \"%1\" could not be saved.").arg(m_sessionFile));
|
Chris@257
|
1880 } else {
|
Chris@257
|
1881 CommandHistory::getInstance()->documentSaved();
|
Chris@257
|
1882 documentRestored();
|
Chris@257
|
1883 }
|
Chris@0
|
1884 } else {
|
Chris@257
|
1885 saveSessionAs();
|
Chris@0
|
1886 }
|
Chris@0
|
1887 }
|
Chris@0
|
1888
|
Chris@0
|
1889 void
|
matthiasm@310
|
1890 MainWindow::saveSessionInAudioPath()
|
matthiasm@310
|
1891 {
|
matthiasm@311
|
1892 if (m_audioFile == "") return;
|
matthiasm@311
|
1893
|
Chris@314
|
1894 if (!waitForInitialAnalysis()) return;
|
Chris@314
|
1895
|
matthiasm@310
|
1896 // We do not want to save mid-analysis regions -- that would cause
|
matthiasm@310
|
1897 // confusion on reloading
|
matthiasm@310
|
1898 m_analyser->clearReAnalysis();
|
matthiasm@310
|
1899 clearSelection();
|
matthiasm@310
|
1900
|
matthiasm@310
|
1901 QString filepath = QFileInfo(m_audioFile).absoluteDir().canonicalPath();
|
matthiasm@310
|
1902 QString basename = QFileInfo(m_audioFile).completeBaseName();
|
matthiasm@310
|
1903
|
matthiasm@310
|
1904 QString path = QDir(filepath).filePath(basename + ".ton");
|
matthiasm@310
|
1905
|
matthiasm@310
|
1906 cerr << path << endl;
|
matthiasm@310
|
1907
|
Chris@313
|
1908 // We don't want to overwrite an existing .ton file unless we put
|
Chris@313
|
1909 // it there in the first place
|
Chris@313
|
1910 bool shouldVerify = true;
|
Chris@313
|
1911 if (m_sessionFile == path) {
|
Chris@313
|
1912 shouldVerify = false;
|
Chris@313
|
1913 }
|
Chris@313
|
1914
|
Chris@313
|
1915 if (shouldVerify && QFileInfo(path).exists()) {
|
Chris@313
|
1916 if (QMessageBox::question(0, tr("File exists"),
|
Chris@313
|
1917 tr("<b>File exists</b><p>The file \"%1\" already exists.\nDo you want to overwrite it?").arg(path),
|
Chris@313
|
1918 QMessageBox::Ok,
|
Chris@313
|
1919 QMessageBox::Cancel) != QMessageBox::Ok) {
|
Chris@313
|
1920 return;
|
Chris@313
|
1921 }
|
Chris@313
|
1922 }
|
Chris@313
|
1923
|
Chris@314
|
1924 if (!waitForInitialAnalysis()) {
|
Chris@314
|
1925 QMessageBox::warning(this, tr("File not saved"),
|
Chris@314
|
1926 tr("Wait cancelled: the session has not been saved."));
|
Chris@314
|
1927 }
|
Chris@314
|
1928
|
matthiasm@310
|
1929 if (!saveSessionFile(path)) {
|
matthiasm@310
|
1930 QMessageBox::critical(this, tr("Failed to save file"),
|
matthiasm@310
|
1931 tr("Session file \"%1\" could not be saved.").arg(path));
|
matthiasm@310
|
1932 } else {
|
matthiasm@310
|
1933 setWindowTitle(tr("%1: %2")
|
matthiasm@310
|
1934 .arg(QApplication::applicationName())
|
matthiasm@310
|
1935 .arg(QFileInfo(path).fileName()));
|
matthiasm@310
|
1936 m_sessionFile = path;
|
matthiasm@310
|
1937 CommandHistory::getInstance()->documentSaved();
|
matthiasm@310
|
1938 documentRestored();
|
matthiasm@310
|
1939 m_recentFiles.addFile(path);
|
matthiasm@310
|
1940 }
|
matthiasm@310
|
1941 }
|
matthiasm@310
|
1942
|
matthiasm@310
|
1943 void
|
Chris@0
|
1944 MainWindow::saveSessionAs()
|
Chris@0
|
1945 {
|
Chris@270
|
1946 // We do not want to save mid-analysis regions -- that would cause
|
Chris@270
|
1947 // confusion on reloading
|
Chris@270
|
1948 m_analyser->clearReAnalysis();
|
Chris@270
|
1949 clearSelection();
|
Chris@270
|
1950
|
Chris@0
|
1951 QString path = getSaveFileName(FileFinder::SessionFile);
|
Chris@0
|
1952
|
Chris@309
|
1953 if (path == "") {
|
Chris@309
|
1954 return;
|
Chris@309
|
1955 }
|
Chris@0
|
1956
|
Chris@314
|
1957 if (!waitForInitialAnalysis()) {
|
Chris@314
|
1958 QMessageBox::warning(this, tr("File not saved"),
|
Chris@314
|
1959 tr("Wait cancelled: the session has not been saved."));
|
Chris@314
|
1960 return;
|
Chris@314
|
1961 }
|
Chris@314
|
1962
|
Chris@0
|
1963 if (!saveSessionFile(path)) {
|
Chris@85
|
1964 QMessageBox::critical(this, tr("Failed to save file"),
|
Chris@85
|
1965 tr("Session file \"%1\" could not be saved.").arg(path));
|
Chris@0
|
1966 } else {
|
Chris@85
|
1967 setWindowTitle(tr("%1: %2")
|
Chris@0
|
1968 .arg(QApplication::applicationName())
|
Chris@85
|
1969 .arg(QFileInfo(path).fileName()));
|
Chris@85
|
1970 m_sessionFile = path;
|
Chris@85
|
1971 CommandHistory::getInstance()->documentSaved();
|
Chris@85
|
1972 documentRestored();
|
Chris@0
|
1973 m_recentFiles.addFile(path);
|
Chris@0
|
1974 }
|
Chris@0
|
1975 }
|
Chris@0
|
1976
|
Chris@85
|
1977 QString
|
Chris@85
|
1978 MainWindow::exportToSVL(QString path, Layer *layer)
|
Chris@85
|
1979 {
|
Chris@85
|
1980 Model *model = layer->getModel();
|
Chris@85
|
1981
|
Chris@85
|
1982 QFile file(path);
|
Chris@85
|
1983 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
Chris@85
|
1984 return tr("Failed to open file %1 for writing").arg(path);
|
Chris@85
|
1985 } else {
|
Chris@85
|
1986 QTextStream out(&file);
|
Chris@85
|
1987 out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
Chris@85
|
1988 << "<!DOCTYPE sonic-visualiser>\n"
|
Chris@85
|
1989 << "<sv>\n"
|
Chris@85
|
1990 << " <data>\n";
|
Chris@85
|
1991
|
Chris@85
|
1992 model->toXml(out, " ");
|
Chris@85
|
1993
|
Chris@85
|
1994 out << " </data>\n"
|
Chris@85
|
1995 << " <display>\n";
|
Chris@85
|
1996
|
Chris@85
|
1997 layer->toXml(out, " ");
|
Chris@85
|
1998
|
Chris@85
|
1999 out << " </display>\n"
|
Chris@85
|
2000 << "</sv>\n";
|
Chris@85
|
2001
|
Chris@85
|
2002 return "";
|
Chris@85
|
2003 }
|
Chris@85
|
2004 }
|
Chris@85
|
2005
|
Chris@0
|
2006 void
|
Chris@174
|
2007 MainWindow::importPitchLayer()
|
Chris@174
|
2008 {
|
Chris@174
|
2009 QString path = getOpenFileName(FileFinder::LayerFileNoMidiNonSV);
|
Chris@174
|
2010 if (path == "") return;
|
Chris@174
|
2011
|
Chris@174
|
2012 FileOpenStatus status = importPitchLayer(path);
|
Chris@174
|
2013
|
Chris@174
|
2014 if (status == FileOpenFailed) {
|
Chris@174
|
2015 emit hideSplash();
|
Chris@174
|
2016 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@174
|
2017 tr("<b>File open failed</b><p>Layer file %1 could not be opened.").arg(path));
|
Chris@174
|
2018 return;
|
Chris@174
|
2019 } else if (status == FileOpenWrongMode) {
|
Chris@174
|
2020 emit hideSplash();
|
Chris@174
|
2021 QMessageBox::critical(this, tr("Failed to open file"),
|
Chris@174
|
2022 tr("<b>Audio required</b><p>Unable to load layer data from \"%1\" without an audio file.<br>Please load at least one audio file before importing annotations.").arg(path));
|
Chris@174
|
2023 }
|
Chris@174
|
2024 }
|
Chris@174
|
2025
|
Chris@174
|
2026 MainWindow::FileOpenStatus
|
Chris@174
|
2027 MainWindow::importPitchLayer(FileSource source)
|
Chris@174
|
2028 {
|
Chris@174
|
2029 if (!source.isAvailable()) return FileOpenFailed;
|
Chris@174
|
2030 source.waitForData();
|
Chris@174
|
2031
|
Chris@174
|
2032 QString path = source.getLocalFilename();
|
Chris@174
|
2033
|
Chris@174
|
2034 RDFImporter::RDFDocumentType rdfType =
|
Chris@174
|
2035 RDFImporter::identifyDocumentType(QUrl::fromLocalFile(path).toString());
|
Chris@174
|
2036
|
Chris@174
|
2037 if (rdfType != RDFImporter::NotRDF) {
|
Chris@174
|
2038
|
Chris@174
|
2039 //!!!
|
Chris@174
|
2040 return FileOpenFailed;
|
Chris@174
|
2041
|
Chris@174
|
2042 } else if (source.getExtension().toLower() == "svl" ||
|
Chris@174
|
2043 (source.getExtension().toLower() == "xml" &&
|
Chris@174
|
2044 (SVFileReader::identifyXmlFile(source.getLocalFilename())
|
Chris@174
|
2045 == SVFileReader::SVLayerFile))) {
|
Chris@174
|
2046
|
Chris@174
|
2047 //!!!
|
Chris@174
|
2048 return FileOpenFailed;
|
Chris@174
|
2049
|
Chris@174
|
2050 } else {
|
Chris@174
|
2051
|
Chris@174
|
2052 try {
|
Chris@174
|
2053
|
Chris@174
|
2054 CSVFormat format(path);
|
Chris@174
|
2055 format.setSampleRate(getMainModel()->getSampleRate());
|
Chris@174
|
2056
|
Chris@174
|
2057 if (format.getModelType() != CSVFormat::TwoDimensionalModel) {
|
Chris@174
|
2058 //!!! error report
|
Chris@174
|
2059 return FileOpenFailed;
|
Chris@174
|
2060 }
|
Chris@174
|
2061
|
Chris@174
|
2062 Model *model = DataFileReaderFactory::loadCSV
|
Chris@174
|
2063 (path, format, getMainModel()->getSampleRate());
|
Chris@174
|
2064
|
Chris@174
|
2065 if (model) {
|
Chris@174
|
2066
|
Chris@174
|
2067 SVDEBUG << "MainWindow::importPitchLayer: Have model" << endl;
|
Chris@174
|
2068
|
Chris@174
|
2069 CommandHistory::getInstance()->startCompoundOperation
|
Chris@174
|
2070 (tr("Import Pitch Track"), true);
|
Chris@174
|
2071
|
Chris@174
|
2072 Layer *newLayer = m_document->createImportedLayer(model);
|
Chris@174
|
2073
|
Chris@174
|
2074 m_analyser->takePitchTrackFrom(newLayer);
|
Chris@174
|
2075
|
Chris@174
|
2076 m_document->deleteLayer(newLayer);
|
Chris@174
|
2077
|
Chris@174
|
2078 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@174
|
2079
|
Chris@174
|
2080 //!!! swap all data in to existing layer instead of this
|
Chris@174
|
2081
|
Chris@174
|
2082 if (!source.isRemote()) {
|
Chris@174
|
2083 registerLastOpenedFilePath
|
Chris@174
|
2084 (FileFinder::LayerFile,
|
Chris@174
|
2085 path); // for file dialog
|
Chris@174
|
2086 }
|
Chris@174
|
2087
|
Chris@174
|
2088 return FileOpenSucceeded;
|
Chris@174
|
2089 }
|
Chris@174
|
2090 } catch (DataFileReaderFactory::Exception e) {
|
Chris@174
|
2091 if (e == DataFileReaderFactory::ImportCancelled) {
|
Chris@174
|
2092 return FileOpenCancelled;
|
Chris@174
|
2093 }
|
Chris@174
|
2094 }
|
Chris@174
|
2095 }
|
Chris@174
|
2096
|
Chris@174
|
2097 return FileOpenFailed;
|
Chris@174
|
2098 }
|
Chris@174
|
2099
|
Chris@174
|
2100 void
|
Chris@85
|
2101 MainWindow::exportPitchLayer()
|
matthiasm@26
|
2102 {
|
Chris@174
|
2103 Layer *layer = m_analyser->getLayer(Analyser::PitchTrack);
|
matthiasm@26
|
2104 if (!layer) return;
|
matthiasm@26
|
2105
|
Chris@85
|
2106 SparseTimeValueModel *model =
|
Chris@85
|
2107 qobject_cast<SparseTimeValueModel *>(layer->getModel());
|
matthiasm@26
|
2108 if (!model) return;
|
matthiasm@26
|
2109
|
Chris@96
|
2110 FileFinder::FileType type = FileFinder::LayerFileNoMidiNonSV;
|
matthiasm@26
|
2111
|
matthiasm@26
|
2112 QString path = getSaveFileName(type);
|
matthiasm@26
|
2113
|
matthiasm@26
|
2114 if (path == "") return;
|
matthiasm@26
|
2115
|
matthiasm@26
|
2116 if (QFileInfo(path).suffix() == "") path += ".svl";
|
matthiasm@26
|
2117
|
matthiasm@26
|
2118 QString suffix = QFileInfo(path).suffix().toLower();
|
matthiasm@26
|
2119
|
matthiasm@26
|
2120 QString error;
|
matthiasm@26
|
2121
|
matthiasm@26
|
2122 if (suffix == "xml" || suffix == "svl") {
|
matthiasm@26
|
2123
|
Chris@85
|
2124 error = exportToSVL(path, layer);
|
matthiasm@26
|
2125
|
matthiasm@26
|
2126 } else if (suffix == "ttl" || suffix == "n3") {
|
matthiasm@26
|
2127
|
Chris@85
|
2128 RDFExporter exporter(path, model);
|
Chris@85
|
2129 exporter.write();
|
Chris@85
|
2130 if (!exporter.isOK()) {
|
Chris@85
|
2131 error = exporter.getError();
|
Chris@85
|
2132 }
|
Chris@85
|
2133
|
Chris@85
|
2134 } else {
|
Chris@85
|
2135
|
Chris@85
|
2136 CSVFileWriter writer(path, model,
|
Chris@85
|
2137 ((suffix == "csv") ? "," : "\t"));
|
Chris@85
|
2138 writer.write();
|
Chris@85
|
2139
|
Chris@85
|
2140 if (!writer.isOK()) {
|
Chris@85
|
2141 error = writer.getError();
|
Chris@85
|
2142 }
|
Chris@85
|
2143 }
|
Chris@85
|
2144
|
Chris@85
|
2145 if (error != "") {
|
Chris@85
|
2146 QMessageBox::critical(this, tr("Failed to write file"), error);
|
Chris@85
|
2147 } else {
|
Chris@85
|
2148 emit activity(tr("Export layer to \"%1\"").arg(path));
|
Chris@85
|
2149 }
|
Chris@85
|
2150 }
|
Chris@85
|
2151
|
Chris@85
|
2152 void
|
Chris@85
|
2153 MainWindow::exportNoteLayer()
|
Chris@85
|
2154 {
|
Chris@174
|
2155 Layer *layer = m_analyser->getLayer(Analyser::Notes);
|
Chris@85
|
2156 if (!layer) return;
|
Chris@85
|
2157
|
Chris@85
|
2158 FlexiNoteModel *model = qobject_cast<FlexiNoteModel *>(layer->getModel());
|
Chris@85
|
2159 if (!model) return;
|
Chris@85
|
2160
|
Chris@96
|
2161 FileFinder::FileType type = FileFinder::LayerFileNonSV;
|
Chris@85
|
2162
|
Chris@85
|
2163 QString path = getSaveFileName(type);
|
Chris@85
|
2164
|
Chris@85
|
2165 if (path == "") return;
|
Chris@85
|
2166
|
Chris@85
|
2167 if (QFileInfo(path).suffix() == "") path += ".svl";
|
Chris@85
|
2168
|
Chris@85
|
2169 QString suffix = QFileInfo(path).suffix().toLower();
|
Chris@85
|
2170
|
Chris@85
|
2171 QString error;
|
Chris@85
|
2172
|
Chris@85
|
2173 if (suffix == "xml" || suffix == "svl") {
|
Chris@85
|
2174
|
Chris@85
|
2175 error = exportToSVL(path, layer);
|
Chris@85
|
2176
|
Chris@85
|
2177 } else if (suffix == "mid" || suffix == "midi") {
|
Chris@85
|
2178
|
Chris@85
|
2179 MIDIFileWriter writer(path, model, model->getSampleRate());
|
Chris@85
|
2180 writer.write();
|
Chris@85
|
2181 if (!writer.isOK()) {
|
Chris@85
|
2182 error = writer.getError();
|
Chris@85
|
2183 }
|
Chris@85
|
2184
|
Chris@85
|
2185 } else if (suffix == "ttl" || suffix == "n3") {
|
Chris@85
|
2186
|
Chris@85
|
2187 RDFExporter exporter(path, model);
|
Chris@85
|
2188 exporter.write();
|
Chris@85
|
2189 if (!exporter.isOK()) {
|
Chris@85
|
2190 error = exporter.getError();
|
matthiasm@26
|
2191 }
|
matthiasm@26
|
2192
|
matthiasm@26
|
2193 } else {
|
matthiasm@26
|
2194
|
matthiasm@26
|
2195 CSVFileWriter writer(path, model,
|
matthiasm@26
|
2196 ((suffix == "csv") ? "," : "\t"));
|
matthiasm@26
|
2197 writer.write();
|
matthiasm@26
|
2198
|
matthiasm@26
|
2199 if (!writer.isOK()) {
|
matthiasm@26
|
2200 error = writer.getError();
|
matthiasm@26
|
2201 }
|
matthiasm@26
|
2202 }
|
matthiasm@26
|
2203
|
matthiasm@26
|
2204 if (error != "") {
|
matthiasm@26
|
2205 QMessageBox::critical(this, tr("Failed to write file"), error);
|
matthiasm@26
|
2206 } else {
|
matthiasm@26
|
2207 emit activity(tr("Export layer to \"%1\"").arg(path));
|
matthiasm@26
|
2208 }
|
matthiasm@26
|
2209 }
|
matthiasm@26
|
2210
|
Chris@139
|
2211 void
|
Chris@399
|
2212 MainWindow::doubleClickSelectInvoked(sv_frame_t frame)
|
Chris@139
|
2213 {
|
Chris@399
|
2214 sv_frame_t f0, f1;
|
Chris@139
|
2215 m_analyser->getEnclosingSelectionScope(frame, f0, f1);
|
Chris@139
|
2216
|
Chris@139
|
2217 cerr << "MainWindow::doubleClickSelectInvoked(" << frame << "): [" << f0 << "," << f1 << "]" << endl;
|
Chris@139
|
2218
|
Chris@164
|
2219 Selection sel(f0, f1);
|
Chris@164
|
2220 m_viewManager->setSelection(sel);
|
Chris@164
|
2221 }
|
Chris@164
|
2222
|
Chris@164
|
2223 void
|
Chris@194
|
2224 MainWindow::abandonSelection()
|
Chris@167
|
2225 {
|
Chris@194
|
2226 // Named abandonSelection rather than clearSelection to indicate
|
Chris@194
|
2227 // that this is an active operation -- it restores the original
|
Chris@194
|
2228 // content of the pitch track in the selected region rather than
|
Chris@194
|
2229 // simply un-selecting.
|
Chris@194
|
2230
|
Chris@194
|
2231 cerr << "MainWindow::abandonSelection()" << endl;
|
Chris@167
|
2232
|
Chris@199
|
2233 CommandHistory::getInstance()->startCompoundOperation(tr("Abandon Selection"), true);
|
Chris@168
|
2234
|
Chris@194
|
2235 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@194
|
2236 if (!selections.empty()) {
|
Chris@194
|
2237 Selection sel = *selections.begin();
|
Chris@199
|
2238 m_analyser->abandonReAnalysis(sel);
|
Chris@252
|
2239 auxSnapNotes(sel);
|
Chris@194
|
2240 }
|
Chris@194
|
2241
|
Chris@167
|
2242 MainWindowBase::clearSelection();
|
Chris@168
|
2243
|
Chris@168
|
2244 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@167
|
2245 }
|
Chris@167
|
2246
|
Chris@167
|
2247 void
|
Chris@192
|
2248 MainWindow::selectionChangedByUser()
|
Chris@164
|
2249 {
|
Chris@221
|
2250 if (!m_document) {
|
Chris@221
|
2251 // we're exiting, most likely
|
Chris@221
|
2252 return;
|
Chris@221
|
2253 }
|
Chris@221
|
2254
|
Chris@164
|
2255 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@164
|
2256
|
Chris@192
|
2257 cerr << "MainWindow::selectionChangedByUser" << endl;
|
Chris@192
|
2258
|
Chris@192
|
2259 m_analyser->showPitchCandidates(m_pendingConstraint.isConstrained());
|
Chris@190
|
2260
|
Chris@164
|
2261 if (!selections.empty()) {
|
Chris@164
|
2262 Selection sel = *selections.begin();
|
Chris@192
|
2263 cerr << "MainWindow::selectionChangedByUser: have selection" << endl;
|
Chris@192
|
2264 QString error = m_analyser->reAnalyseSelection
|
Chris@192
|
2265 (sel, m_pendingConstraint);
|
Chris@164
|
2266 if (error != "") {
|
Chris@164
|
2267 QMessageBox::critical
|
Chris@164
|
2268 (this, tr("Failed to analyse selection"),
|
Chris@164
|
2269 tr("<b>Analysis failed</b><p>%2</p>").arg(error));
|
Chris@164
|
2270 }
|
Chris@164
|
2271 }
|
Chris@192
|
2272
|
Chris@192
|
2273 m_pendingConstraint = Analyser::FrequencyRange();
|
Chris@192
|
2274 }
|
Chris@192
|
2275
|
Chris@192
|
2276 void
|
Chris@192
|
2277 MainWindow::regionOutlined(QRect r)
|
Chris@192
|
2278 {
|
Chris@192
|
2279 cerr << "MainWindow::regionOutlined(" << r.x() << "," << r.y() << "," << r.width() << "," << r.height() << ")" << endl;
|
Chris@192
|
2280
|
Chris@192
|
2281 Pane *pane = qobject_cast<Pane *>(sender());
|
Chris@192
|
2282 if (!pane) {
|
Chris@192
|
2283 cerr << "MainWindow::regionOutlined: not sent by pane, ignoring" << endl;
|
Chris@192
|
2284 return;
|
Chris@192
|
2285 }
|
Chris@192
|
2286
|
Chris@192
|
2287 if (!m_analyser) {
|
Chris@192
|
2288 cerr << "MainWindow::regionOutlined: no analyser, ignoring" << endl;
|
Chris@192
|
2289 return;
|
Chris@192
|
2290 }
|
Chris@192
|
2291
|
Chris@192
|
2292 SpectrogramLayer *spectrogram = qobject_cast<SpectrogramLayer *>
|
Chris@192
|
2293 (m_analyser->getLayer(Analyser::Spectrogram));
|
Chris@192
|
2294 if (!spectrogram) {
|
Chris@192
|
2295 cerr << "MainWindow::regionOutlined: no spectrogram layer, ignoring" << endl;
|
Chris@192
|
2296 return;
|
Chris@192
|
2297 }
|
Chris@192
|
2298
|
Chris@399
|
2299 sv_frame_t f0 = pane->getFrameForX(r.x());
|
Chris@399
|
2300 sv_frame_t f1 = pane->getFrameForX(r.x() + r.width());
|
Chris@192
|
2301
|
Chris@399
|
2302 double v0 = spectrogram->getFrequencyForY(pane, r.y() + r.height());
|
Chris@399
|
2303 double v1 = spectrogram->getFrequencyForY(pane, r.y());
|
Chris@192
|
2304
|
Chris@192
|
2305 cerr << "MainWindow::regionOutlined: frame " << f0 << " -> " << f1
|
Chris@192
|
2306 << ", frequency " << v0 << " -> " << v1 << endl;
|
Chris@192
|
2307
|
Chris@192
|
2308 m_pendingConstraint = Analyser::FrequencyRange(v0, v1);
|
Chris@192
|
2309
|
Chris@192
|
2310 Selection sel(f0, f1);
|
Chris@192
|
2311 m_viewManager->setSelection(sel);
|
Chris@0
|
2312 }
|
Chris@0
|
2313
|
Chris@0
|
2314 void
|
Chris@168
|
2315 MainWindow::clearPitches()
|
Chris@168
|
2316 {
|
Chris@168
|
2317 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@168
|
2318
|
Chris@168
|
2319 CommandHistory::getInstance()->startCompoundOperation(tr("Clear Pitches"), true);
|
Chris@168
|
2320
|
Chris@168
|
2321 for (MultiSelection::SelectionList::iterator k = selections.begin();
|
Chris@168
|
2322 k != selections.end(); ++k) {
|
Chris@184
|
2323 m_analyser->deletePitches(*k);
|
Chris@252
|
2324 auxSnapNotes(*k);
|
Chris@168
|
2325 }
|
Chris@168
|
2326
|
Chris@168
|
2327 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@168
|
2328 }
|
Chris@168
|
2329
|
Chris@168
|
2330 void
|
Chris@142
|
2331 MainWindow::octaveShift(bool up)
|
Chris@142
|
2332 {
|
Chris@142
|
2333 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@142
|
2334
|
Chris@211
|
2335 CommandHistory::getInstance()->startCompoundOperation
|
Chris@211
|
2336 (up ? tr("Choose Higher Octave") : tr("Choose Lower Octave"), true);
|
Chris@142
|
2337
|
Chris@168
|
2338 for (MultiSelection::SelectionList::iterator k = selections.begin();
|
Chris@168
|
2339 k != selections.end(); ++k) {
|
Chris@142
|
2340
|
Chris@168
|
2341 m_analyser->shiftOctave(*k, up);
|
Chris@252
|
2342 auxSnapNotes(*k);
|
Chris@142
|
2343 }
|
Chris@142
|
2344
|
Chris@142
|
2345 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@142
|
2346 }
|
Chris@142
|
2347
|
Chris@142
|
2348 void
|
Chris@184
|
2349 MainWindow::togglePitchCandidates()
|
Chris@184
|
2350 {
|
Chris@199
|
2351 CommandHistory::getInstance()->startCompoundOperation(tr("Toggle Pitch Candidates"), true);
|
Chris@199
|
2352
|
Chris@184
|
2353 m_analyser->showPitchCandidates(!m_analyser->arePitchCandidatesShown());
|
Chris@199
|
2354
|
Chris@199
|
2355 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@199
|
2356
|
Chris@187
|
2357 updateMenuStates();
|
Chris@184
|
2358 }
|
Chris@184
|
2359
|
Chris@184
|
2360 void
|
Chris@184
|
2361 MainWindow::switchPitchUp()
|
Chris@167
|
2362 {
|
Chris@211
|
2363 if (m_analyser->arePitchCandidatesShown()) {
|
Chris@211
|
2364 if (m_analyser->haveHigherPitchCandidate()) {
|
Chris@211
|
2365
|
Chris@211
|
2366 CommandHistory::getInstance()->startCompoundOperation
|
Chris@211
|
2367 (tr("Choose Higher Pitch Candidate"), true);
|
Chris@211
|
2368
|
Chris@211
|
2369 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@211
|
2370
|
Chris@211
|
2371 for (MultiSelection::SelectionList::iterator k = selections.begin();
|
Chris@211
|
2372 k != selections.end(); ++k) {
|
Chris@211
|
2373 m_analyser->switchPitchCandidate(*k, true);
|
Chris@252
|
2374 auxSnapNotes(*k);
|
Chris@211
|
2375 }
|
Chris@211
|
2376
|
Chris@211
|
2377 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@211
|
2378 }
|
Chris@211
|
2379 } else {
|
Chris@211
|
2380 octaveShift(true);
|
Chris@167
|
2381 }
|
Chris@167
|
2382 }
|
Chris@167
|
2383
|
Chris@167
|
2384 void
|
Chris@184
|
2385 MainWindow::switchPitchDown()
|
Chris@184
|
2386 {
|
Chris@211
|
2387 if (m_analyser->arePitchCandidatesShown()) {
|
Chris@211
|
2388 if (m_analyser->haveLowerPitchCandidate()) {
|
Chris@211
|
2389
|
Chris@211
|
2390 CommandHistory::getInstance()->startCompoundOperation
|
Chris@211
|
2391 (tr("Choose Lower Pitch Candidate"), true);
|
Chris@211
|
2392
|
Chris@211
|
2393 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@211
|
2394
|
Chris@211
|
2395 for (MultiSelection::SelectionList::iterator k = selections.begin();
|
Chris@211
|
2396 k != selections.end(); ++k) {
|
Chris@211
|
2397 m_analyser->switchPitchCandidate(*k, false);
|
Chris@252
|
2398 auxSnapNotes(*k);
|
Chris@211
|
2399 }
|
Chris@211
|
2400
|
Chris@211
|
2401 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@211
|
2402 }
|
Chris@211
|
2403 } else {
|
Chris@211
|
2404 octaveShift(false);
|
Chris@184
|
2405 }
|
Chris@184
|
2406 }
|
Chris@184
|
2407
|
Chris@184
|
2408 void
|
Chris@237
|
2409 MainWindow::snapNotesToPitches()
|
Chris@237
|
2410 {
|
matthiasm@274
|
2411 cerr << "in snapNotesToPitches" << endl;
|
Chris@237
|
2412 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@237
|
2413
|
Chris@237
|
2414 if (!selections.empty()) {
|
Chris@237
|
2415
|
Chris@237
|
2416 CommandHistory::getInstance()->startCompoundOperation
|
Chris@237
|
2417 (tr("Snap Notes to Pitches"), true);
|
Chris@237
|
2418
|
Chris@237
|
2419 for (MultiSelection::SelectionList::iterator k = selections.begin();
|
Chris@237
|
2420 k != selections.end(); ++k) {
|
Chris@239
|
2421 auxSnapNotes(*k);
|
Chris@237
|
2422 }
|
Chris@237
|
2423
|
Chris@237
|
2424 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@237
|
2425 }
|
Chris@237
|
2426 }
|
Chris@237
|
2427
|
Chris@237
|
2428 void
|
Chris@239
|
2429 MainWindow::auxSnapNotes(Selection s)
|
Chris@239
|
2430 {
|
matthiasm@274
|
2431 cerr << "in auxSnapNotes" << endl;
|
Chris@239
|
2432 FlexiNoteLayer *layer =
|
Chris@239
|
2433 qobject_cast<FlexiNoteLayer *>(m_analyser->getLayer(Analyser::Notes));
|
Chris@239
|
2434 if (!layer) return;
|
Chris@239
|
2435
|
Chris@239
|
2436 layer->snapSelectedNotesToPitchTrack(m_analyser->getPane(), s);
|
Chris@239
|
2437 }
|
Chris@239
|
2438
|
Chris@239
|
2439 void
|
Chris@240
|
2440 MainWindow::splitNote()
|
Chris@237
|
2441 {
|
Chris@237
|
2442 FlexiNoteLayer *layer =
|
Chris@237
|
2443 qobject_cast<FlexiNoteLayer *>(m_analyser->getLayer(Analyser::Notes));
|
Chris@237
|
2444 if (!layer) return;
|
Chris@237
|
2445
|
Chris@240
|
2446 layer->splitNotesAt(m_analyser->getPane(), m_viewManager->getPlaybackFrame());
|
Chris@237
|
2447 }
|
Chris@237
|
2448
|
Chris@237
|
2449 void
|
Chris@238
|
2450 MainWindow::mergeNotes()
|
Chris@238
|
2451 {
|
Chris@238
|
2452 FlexiNoteLayer *layer =
|
Chris@238
|
2453 qobject_cast<FlexiNoteLayer *>(m_analyser->getLayer(Analyser::Notes));
|
Chris@238
|
2454 if (!layer) return;
|
Chris@238
|
2455
|
Chris@238
|
2456 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@238
|
2457
|
Chris@238
|
2458 if (!selections.empty()) {
|
Chris@238
|
2459
|
Chris@238
|
2460 CommandHistory::getInstance()->startCompoundOperation
|
Chris@238
|
2461 (tr("Merge Notes"), true);
|
Chris@238
|
2462
|
Chris@238
|
2463 for (MultiSelection::SelectionList::iterator k = selections.begin();
|
Chris@238
|
2464 k != selections.end(); ++k) {
|
Chris@240
|
2465 layer->mergeNotes(m_analyser->getPane(), *k, true);
|
Chris@238
|
2466 }
|
Chris@238
|
2467
|
Chris@238
|
2468 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@238
|
2469 }
|
Chris@238
|
2470 }
|
Chris@238
|
2471
|
Chris@238
|
2472 void
|
matthiasm@292
|
2473 MainWindow::deleteNotes()
|
matthiasm@292
|
2474 {
|
matthiasm@292
|
2475 FlexiNoteLayer *layer =
|
matthiasm@292
|
2476 qobject_cast<FlexiNoteLayer *>(m_analyser->getLayer(Analyser::Notes));
|
matthiasm@292
|
2477 if (!layer) return;
|
matthiasm@292
|
2478
|
matthiasm@292
|
2479 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
matthiasm@292
|
2480
|
matthiasm@292
|
2481 if (!selections.empty()) {
|
matthiasm@292
|
2482
|
matthiasm@292
|
2483 CommandHistory::getInstance()->startCompoundOperation
|
matthiasm@292
|
2484 (tr("Delete Notes"), true);
|
matthiasm@292
|
2485
|
matthiasm@292
|
2486 for (MultiSelection::SelectionList::iterator k = selections.begin();
|
matthiasm@292
|
2487 k != selections.end(); ++k) {
|
matthiasm@294
|
2488 layer->deleteSelectionInclusive(*k);
|
matthiasm@292
|
2489 }
|
matthiasm@292
|
2490
|
matthiasm@292
|
2491 CommandHistory::getInstance()->endCompoundOperation();
|
matthiasm@292
|
2492 }
|
matthiasm@292
|
2493 }
|
matthiasm@292
|
2494
|
matthiasm@292
|
2495
|
matthiasm@292
|
2496 void
|
Chris@240
|
2497 MainWindow::formNoteFromSelection()
|
Chris@240
|
2498 {
|
matthiasm@293
|
2499 Layer *layer0 = m_analyser->getLayer(Analyser::Notes);
|
matthiasm@293
|
2500 FlexiNoteModel *model = qobject_cast<FlexiNoteModel *>(layer0->getModel());
|
matthiasm@293
|
2501
|
Chris@240
|
2502 FlexiNoteLayer *layer =
|
Chris@240
|
2503 qobject_cast<FlexiNoteLayer *>(m_analyser->getLayer(Analyser::Notes));
|
Chris@240
|
2504 if (!layer) return;
|
Chris@240
|
2505
|
Chris@240
|
2506 MultiSelection::SelectionList selections = m_viewManager->getSelections();
|
Chris@240
|
2507
|
Chris@240
|
2508 if (!selections.empty()) {
|
Chris@240
|
2509
|
Chris@240
|
2510 CommandHistory::getInstance()->startCompoundOperation
|
Chris@240
|
2511 (tr("Form Note from Selection"), true);
|
Chris@240
|
2512 for (MultiSelection::SelectionList::iterator k = selections.begin();
|
Chris@240
|
2513 k != selections.end(); ++k) {
|
Chris@355
|
2514 if (!model->getNotesWithin(k->getStartFrame(), k->getEndFrame()).empty()) {
|
matthiasm@293
|
2515 layer->splitNotesAt(m_analyser->getPane(), k->getStartFrame());
|
matthiasm@293
|
2516 layer->splitNotesAt(m_analyser->getPane(), k->getEndFrame());
|
matthiasm@293
|
2517 layer->mergeNotes(m_analyser->getPane(), *k, false);
|
matthiasm@293
|
2518 } else {
|
matthiasm@293
|
2519 layer->addNoteOn(k->getStartFrame(), 100, 100);
|
matthiasm@293
|
2520 layer->addNoteOff(k->getEndFrame(), 100);
|
matthiasm@293
|
2521 layer->mergeNotes(m_analyser->getPane(), *k, false); // only so the note adapts in case of exisitng pitch track
|
matthiasm@293
|
2522 }
|
Chris@240
|
2523 }
|
Chris@240
|
2524
|
matthiasm@293
|
2525 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@240
|
2526 }
|
Chris@240
|
2527 }
|
Chris@240
|
2528
|
Chris@240
|
2529 void
|
Chris@0
|
2530 MainWindow::playSpeedChanged(int position)
|
Chris@0
|
2531 {
|
Chris@0
|
2532 PlaySpeedRangeMapper mapper(0, 200);
|
Chris@0
|
2533
|
Chris@399
|
2534 double percent = m_playSpeed->mappedValue();
|
Chris@399
|
2535 double factor = mapper.getFactorForValue(percent);
|
Chris@0
|
2536
|
Chris@70
|
2537 cerr << "speed = " << position << " percent = " << percent << " factor = " << factor << endl;
|
Chris@0
|
2538
|
Chris@0
|
2539 bool something = (position != 100);
|
Chris@0
|
2540
|
Chris@399
|
2541 int pc = int(lrint(percent));
|
Chris@0
|
2542
|
Chris@0
|
2543 if (!something) {
|
Chris@0
|
2544 contextHelpChanged(tr("Playback speed: Normal"));
|
Chris@0
|
2545 } else {
|
Chris@0
|
2546 contextHelpChanged(tr("Playback speed: %1%2%")
|
Chris@0
|
2547 .arg(position > 100 ? "+" : "")
|
Chris@0
|
2548 .arg(pc));
|
Chris@0
|
2549 }
|
Chris@0
|
2550
|
Chris@0
|
2551 m_playSource->setTimeStretch(factor);
|
Chris@0
|
2552
|
Chris@0
|
2553 updateMenuStates();
|
Chris@0
|
2554 }
|
Chris@0
|
2555
|
Chris@0
|
2556 void
|
Chris@0
|
2557 MainWindow::playSharpenToggled()
|
Chris@0
|
2558 {
|
Chris@0
|
2559 QSettings settings;
|
Chris@0
|
2560 settings.beginGroup("MainWindow");
|
Chris@0
|
2561 settings.setValue("playsharpen", m_playSharpen->isChecked());
|
Chris@0
|
2562 settings.endGroup();
|
Chris@0
|
2563
|
Chris@0
|
2564 playSpeedChanged(m_playSpeed->value());
|
justin@157
|
2565 // TODO: pitch gain?
|
Chris@0
|
2566 }
|
Chris@0
|
2567
|
Chris@0
|
2568 void
|
Chris@0
|
2569 MainWindow::playMonoToggled()
|
Chris@0
|
2570 {
|
Chris@0
|
2571 QSettings settings;
|
Chris@0
|
2572 settings.beginGroup("MainWindow");
|
Chris@0
|
2573 settings.setValue("playmono", m_playMono->isChecked());
|
Chris@0
|
2574 settings.endGroup();
|
Chris@0
|
2575
|
Chris@0
|
2576 playSpeedChanged(m_playSpeed->value());
|
justin@157
|
2577 // TODO: pitch gain?
|
Chris@0
|
2578 }
|
Chris@0
|
2579
|
Chris@0
|
2580 void
|
Chris@0
|
2581 MainWindow::speedUpPlayback()
|
Chris@0
|
2582 {
|
Chris@0
|
2583 int value = m_playSpeed->value();
|
Chris@0
|
2584 value = value + m_playSpeed->pageStep();
|
Chris@0
|
2585 if (value > m_playSpeed->maximum()) value = m_playSpeed->maximum();
|
Chris@0
|
2586 m_playSpeed->setValue(value);
|
Chris@0
|
2587 }
|
Chris@0
|
2588
|
Chris@0
|
2589 void
|
Chris@0
|
2590 MainWindow::slowDownPlayback()
|
Chris@0
|
2591 {
|
Chris@0
|
2592 int value = m_playSpeed->value();
|
Chris@0
|
2593 value = value - m_playSpeed->pageStep();
|
Chris@0
|
2594 if (value < m_playSpeed->minimum()) value = m_playSpeed->minimum();
|
Chris@0
|
2595 m_playSpeed->setValue(value);
|
Chris@0
|
2596 }
|
Chris@0
|
2597
|
Chris@0
|
2598 void
|
Chris@0
|
2599 MainWindow::restoreNormalPlayback()
|
Chris@0
|
2600 {
|
Chris@0
|
2601 m_playSpeed->setValue(m_playSpeed->defaultValue());
|
Chris@0
|
2602 }
|
Chris@0
|
2603
|
justin@157
|
2604 void
|
Chris@404
|
2605 MainWindow::audioGainChanged(float gain)
|
justin@159
|
2606 {
|
Chris@404
|
2607 double db = AudioLevel::multiplier_to_dB(gain);
|
Chris@404
|
2608 cerr << "gain = " << gain << " (" << db << " dB)" << endl;
|
Chris@404
|
2609 contextHelpChanged(tr("Audio Gain: %1 dB").arg(db));
|
Chris@404
|
2610 m_analyser->setGain(Analyser::Audio, gain);
|
justin@159
|
2611 updateMenuStates();
|
justin@159
|
2612 }
|
justin@159
|
2613
|
justin@159
|
2614 void
|
Chris@404
|
2615 MainWindow::pitchGainChanged(float gain)
|
justin@159
|
2616 {
|
Chris@404
|
2617 double db = AudioLevel::multiplier_to_dB(gain);
|
Chris@404
|
2618 cerr << "gain = " << gain << " (" << db << " dB)" << endl;
|
Chris@404
|
2619 contextHelpChanged(tr("Pitch Gain: %1 dB").arg(db));
|
Chris@404
|
2620 m_analyser->setGain(Analyser::PitchTrack, gain);
|
justin@157
|
2621 updateMenuStates();
|
justin@157
|
2622 }
|
justin@157
|
2623
|
justin@157
|
2624 void
|
Chris@404
|
2625 MainWindow::notesGainChanged(float gain)
|
justin@157
|
2626 {
|
Chris@404
|
2627 double db = AudioLevel::multiplier_to_dB(gain);
|
Chris@404
|
2628 cerr << "gain = " << gain << " (" << db << " dB)" << endl;
|
Chris@404
|
2629 contextHelpChanged(tr("Notes Gain: %1 dB").arg(db));
|
Chris@404
|
2630 m_analyser->setGain(Analyser::Notes, gain);
|
justin@159
|
2631 updateMenuStates();
|
justin@159
|
2632 }
|
justin@159
|
2633
|
justin@159
|
2634 void
|
Chris@404
|
2635 MainWindow::audioPanChanged(float pan)
|
justin@159
|
2636 {
|
Chris@404
|
2637 contextHelpChanged(tr("Audio Pan: %1").arg(pan));
|
Chris@404
|
2638 m_analyser->setPan(Analyser::Audio, pan);
|
justin@160
|
2639 updateMenuStates();
|
justin@160
|
2640 }
|
justin@160
|
2641
|
justin@160
|
2642 void
|
Chris@404
|
2643 MainWindow::pitchPanChanged(float pan)
|
justin@160
|
2644 {
|
Chris@404
|
2645 contextHelpChanged(tr("Pitch Pan: %1").arg(pan));
|
Chris@404
|
2646 m_analyser->setPan(Analyser::PitchTrack, pan);
|
justin@160
|
2647 updateMenuStates();
|
justin@160
|
2648 }
|
justin@160
|
2649
|
justin@160
|
2650 void
|
Chris@404
|
2651 MainWindow::notesPanChanged(float pan)
|
justin@160
|
2652 {
|
Chris@404
|
2653 contextHelpChanged(tr("Notes Pan: %1").arg(pan));
|
Chris@404
|
2654 m_analyser->setPan(Analyser::Notes, pan);
|
justin@160
|
2655 updateMenuStates();
|
justin@160
|
2656 }
|
justin@160
|
2657
|
justin@160
|
2658 void
|
Chris@0
|
2659 MainWindow::updateVisibleRangeDisplay(Pane *p) const
|
Chris@0
|
2660 {
|
Chris@0
|
2661 if (!getMainModel() || !p) {
|
Chris@0
|
2662 return;
|
Chris@0
|
2663 }
|
Chris@0
|
2664
|
Chris@0
|
2665 bool haveSelection = false;
|
Chris@403
|
2666 sv_frame_t startFrame = 0, endFrame = 0;
|
Chris@0
|
2667
|
Chris@0
|
2668 if (m_viewManager && m_viewManager->haveInProgressSelection()) {
|
Chris@0
|
2669
|
Chris@0
|
2670 bool exclusive = false;
|
Chris@0
|
2671 Selection s = m_viewManager->getInProgressSelection(exclusive);
|
Chris@0
|
2672
|
Chris@0
|
2673 if (!s.isEmpty()) {
|
Chris@0
|
2674 haveSelection = true;
|
Chris@0
|
2675 startFrame = s.getStartFrame();
|
Chris@0
|
2676 endFrame = s.getEndFrame();
|
Chris@0
|
2677 }
|
Chris@0
|
2678 }
|
Chris@0
|
2679
|
Chris@0
|
2680 if (!haveSelection) {
|
Chris@0
|
2681 startFrame = p->getFirstVisibleFrame();
|
Chris@0
|
2682 endFrame = p->getLastVisibleFrame();
|
Chris@0
|
2683 }
|
Chris@0
|
2684
|
Chris@0
|
2685 RealTime start = RealTime::frame2RealTime
|
Chris@0
|
2686 (startFrame, getMainModel()->getSampleRate());
|
Chris@0
|
2687
|
Chris@0
|
2688 RealTime end = RealTime::frame2RealTime
|
Chris@0
|
2689 (endFrame, getMainModel()->getSampleRate());
|
Chris@0
|
2690
|
Chris@0
|
2691 RealTime duration = end - start;
|
Chris@0
|
2692
|
Chris@0
|
2693 QString startStr, endStr, durationStr;
|
Chris@0
|
2694 startStr = start.toText(true).c_str();
|
Chris@0
|
2695 endStr = end.toText(true).c_str();
|
Chris@0
|
2696 durationStr = duration.toText(true).c_str();
|
Chris@0
|
2697
|
Chris@0
|
2698 if (haveSelection) {
|
Chris@0
|
2699 m_myStatusMessage = tr("Selection: %1 to %2 (duration %3)")
|
Chris@0
|
2700 .arg(startStr).arg(endStr).arg(durationStr);
|
Chris@0
|
2701 } else {
|
Chris@0
|
2702 m_myStatusMessage = tr("Visible: %1 to %2 (duration %3)")
|
Chris@0
|
2703 .arg(startStr).arg(endStr).arg(durationStr);
|
Chris@0
|
2704 }
|
matthiasm@42
|
2705
|
Chris@362
|
2706 getStatusLabel()->setText(m_myStatusMessage);
|
Chris@0
|
2707 }
|
Chris@0
|
2708
|
Chris@0
|
2709 void
|
Chris@0
|
2710 MainWindow::updatePositionStatusDisplays() const
|
Chris@0
|
2711 {
|
Chris@0
|
2712 if (!statusBar()->isVisible()) return;
|
Chris@0
|
2713
|
Chris@0
|
2714 }
|
Chris@0
|
2715
|
Chris@0
|
2716 void
|
Chris@0
|
2717 MainWindow::outputLevelsChanged(float left, float right)
|
Chris@0
|
2718 {
|
Chris@0
|
2719 m_fader->setPeakLeft(left);
|
Chris@0
|
2720 m_fader->setPeakRight(right);
|
Chris@0
|
2721 }
|
Chris@0
|
2722
|
Chris@0
|
2723 void
|
Chris@399
|
2724 MainWindow::sampleRateMismatch(sv_samplerate_t ,
|
Chris@399
|
2725 sv_samplerate_t ,
|
Chris@399
|
2726 bool )
|
Chris@0
|
2727 {
|
Chris@0
|
2728 updateDescriptionLabel();
|
Chris@0
|
2729 }
|
Chris@0
|
2730
|
Chris@0
|
2731 void
|
Chris@0
|
2732 MainWindow::audioOverloadPluginDisabled()
|
Chris@0
|
2733 {
|
Chris@0
|
2734 QMessageBox::information
|
Chris@0
|
2735 (this, tr("Audio processing overload"),
|
Chris@0
|
2736 tr("<b>Overloaded</b><p>Audio effects plugin auditioning has been disabled due to a processing overload."));
|
Chris@0
|
2737 }
|
Chris@0
|
2738
|
Chris@0
|
2739 void
|
Chris@0
|
2740 MainWindow::audioTimeStretchMultiChannelDisabled()
|
Chris@0
|
2741 {
|
Chris@0
|
2742 static bool shownOnce = false;
|
Chris@0
|
2743 if (shownOnce) return;
|
Chris@0
|
2744 QMessageBox::information
|
Chris@0
|
2745 (this, tr("Audio processing overload"),
|
Chris@0
|
2746 tr("<b>Overloaded</b><p>Audio playback speed processing has been reduced to a single channel, due to a processing overload."));
|
Chris@0
|
2747 shownOnce = true;
|
Chris@0
|
2748 }
|
Chris@0
|
2749
|
Chris@0
|
2750 void
|
Chris@0
|
2751 MainWindow::layerRemoved(Layer *layer)
|
Chris@0
|
2752 {
|
Chris@0
|
2753 MainWindowBase::layerRemoved(layer);
|
Chris@0
|
2754 }
|
Chris@0
|
2755
|
Chris@0
|
2756 void
|
Chris@0
|
2757 MainWindow::layerInAView(Layer *layer, bool inAView)
|
Chris@0
|
2758 {
|
Chris@0
|
2759 MainWindowBase::layerInAView(layer, inAView);
|
Chris@0
|
2760 }
|
Chris@0
|
2761
|
Chris@0
|
2762 void
|
Chris@0
|
2763 MainWindow::modelAdded(Model *model)
|
Chris@0
|
2764 {
|
Chris@0
|
2765 MainWindowBase::modelAdded(model);
|
Chris@3
|
2766 DenseTimeValueModel *dtvm = qobject_cast<DenseTimeValueModel *>(model);
|
Chris@0
|
2767 if (dtvm) {
|
Chris@70
|
2768 cerr << "A dense time-value model (such as an audio file) has been loaded" << endl;
|
Chris@0
|
2769 }
|
Chris@0
|
2770 }
|
Chris@0
|
2771
|
Chris@0
|
2772 void
|
Chris@0
|
2773 MainWindow::modelAboutToBeDeleted(Model *model)
|
Chris@0
|
2774 {
|
Chris@0
|
2775 MainWindowBase::modelAboutToBeDeleted(model);
|
Chris@0
|
2776 }
|
Chris@0
|
2777
|
Chris@0
|
2778 void
|
Chris@0
|
2779 MainWindow::mainModelChanged(WaveFileModel *model)
|
Chris@0
|
2780 {
|
Chris@0
|
2781 m_panLayer->setModel(model);
|
Chris@0
|
2782
|
Chris@0
|
2783 MainWindowBase::mainModelChanged(model);
|
Chris@0
|
2784
|
Chris@0
|
2785 if (m_playTarget) {
|
Chris@0
|
2786 connect(m_fader, SIGNAL(valueChanged(float)),
|
Chris@0
|
2787 m_playTarget, SLOT(setOutputGain(float)));
|
Chris@0
|
2788 }
|
Chris@259
|
2789 }
|
Chris@259
|
2790
|
Chris@259
|
2791 void
|
Chris@323
|
2792 MainWindow::analyseNow()
|
Chris@323
|
2793 {
|
Chris@323
|
2794 cerr << "analyseNow called" << endl;
|
Chris@325
|
2795 if (!m_analyser) return;
|
Chris@325
|
2796
|
Chris@325
|
2797 CommandHistory::getInstance()->startCompoundOperation
|
Chris@325
|
2798 (tr("Analyse Audio"), true);
|
Chris@325
|
2799
|
Chris@325
|
2800 QString error = m_analyser->analyseExistingFile();
|
Chris@325
|
2801
|
Chris@325
|
2802 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@325
|
2803
|
Chris@325
|
2804 if (error != "") {
|
Chris@325
|
2805 QMessageBox::warning
|
Chris@325
|
2806 (this,
|
Chris@325
|
2807 tr("Failed to analyse audio"),
|
Chris@325
|
2808 tr("<b>Analysis failed</b><p>%1</p>").arg(error),
|
Chris@325
|
2809 QMessageBox::Ok);
|
Chris@325
|
2810 }
|
Chris@323
|
2811 }
|
Chris@323
|
2812
|
Chris@323
|
2813 void
|
Chris@259
|
2814 MainWindow::analyseNewMainModel()
|
Chris@259
|
2815 {
|
Chris@259
|
2816 WaveFileModel *model = getMainModel();
|
Chris@260
|
2817
|
Chris@260
|
2818 cerr << "MainWindow::analyseNewMainModel: main model is " << model << endl;
|
Chris@260
|
2819
|
Chris@260
|
2820 cerr << "(document is " << m_document << ", it says main model is " << m_document->getMainModel() << ")" << endl;
|
Chris@259
|
2821
|
Chris@324
|
2822 if (!model) {
|
Chris@324
|
2823 cerr << "no main model!" << endl;
|
Chris@324
|
2824 return;
|
Chris@324
|
2825 }
|
Chris@324
|
2826
|
Chris@324
|
2827 if (!m_paneStack) {
|
Chris@324
|
2828 cerr << "no pane stack!" << endl;
|
Chris@324
|
2829 return;
|
Chris@324
|
2830 }
|
Chris@324
|
2831
|
Chris@324
|
2832 int pc = m_paneStack->getPaneCount();
|
Chris@324
|
2833 Pane *pane = 0;
|
Chris@324
|
2834 Pane *selectionStrip = 0;
|
Chris@324
|
2835
|
Chris@324
|
2836 if (pc < 2) {
|
Chris@324
|
2837 pane = m_paneStack->addPane();
|
Chris@324
|
2838 selectionStrip = m_paneStack->addPane();
|
Chris@324
|
2839 m_document->addLayerToView
|
Chris@324
|
2840 (selectionStrip,
|
Chris@324
|
2841 m_document->createMainModelLayer(LayerFactory::TimeRuler));
|
Chris@324
|
2842 } else {
|
Chris@324
|
2843 pane = m_paneStack->getPane(0);
|
Chris@324
|
2844 selectionStrip = m_paneStack->getPane(1);
|
Chris@324
|
2845 }
|
Chris@324
|
2846
|
Chris@362
|
2847 pane->setPlaybackFollow(PlaybackScrollPage);
|
Chris@362
|
2848
|
Chris@324
|
2849 if (selectionStrip) {
|
Chris@362
|
2850 selectionStrip->setPlaybackFollow(PlaybackScrollPage);
|
Chris@324
|
2851 selectionStrip->setFixedHeight(26);
|
Chris@324
|
2852 m_paneStack->sizePanesEqually();
|
Chris@324
|
2853 m_viewManager->clearToolModeOverrides();
|
Chris@324
|
2854 m_viewManager->setToolModeFor(selectionStrip,
|
Chris@324
|
2855 ViewManager::SelectMode);
|
Chris@324
|
2856 }
|
Chris@324
|
2857
|
Chris@324
|
2858 if (pane) {
|
Chris@324
|
2859
|
Chris@324
|
2860 disconnect(pane, SIGNAL(regionOutlined(QRect)),
|
Chris@324
|
2861 pane, SLOT(zoomToRegion(QRect)));
|
Chris@324
|
2862 connect(pane, SIGNAL(regionOutlined(QRect)),
|
Chris@324
|
2863 this, SLOT(regionOutlined(QRect)));
|
Chris@324
|
2864
|
Chris@324
|
2865 QString error = m_analyser->newFileLoaded
|
Chris@324
|
2866 (m_document, getMainModel(), m_paneStack, pane);
|
Chris@324
|
2867 if (error != "") {
|
Chris@324
|
2868 QMessageBox::warning
|
Chris@324
|
2869 (this,
|
Chris@324
|
2870 tr("Failed to analyse audio"),
|
Chris@324
|
2871 tr("<b>Analysis failed</b><p>%1</p>").arg(error),
|
Chris@324
|
2872 QMessageBox::Ok);
|
Chris@72
|
2873 }
|
Chris@72
|
2874 }
|
matthiasm@366
|
2875
|
matthiasm@366
|
2876 if (!m_withSpectrogram)
|
matthiasm@366
|
2877 {
|
matthiasm@366
|
2878 m_analyser->setVisible(Analyser::Spectrogram, false);
|
matthiasm@366
|
2879 }
|
matthiasm@366
|
2880
|
matthiasm@366
|
2881 if (!m_withSonification)
|
matthiasm@366
|
2882 {
|
matthiasm@366
|
2883 m_analyser->setAudible(Analyser::PitchTrack, false);
|
matthiasm@366
|
2884 m_analyser->setAudible(Analyser::Notes, false);
|
matthiasm@366
|
2885 }
|
Chris@0
|
2886 }
|
Chris@0
|
2887
|
Chris@0
|
2888 void
|
Chris@0
|
2889 MainWindow::modelGenerationFailed(QString transformName, QString message)
|
Chris@0
|
2890 {
|
Chris@0
|
2891 if (message != "") {
|
Chris@0
|
2892
|
Chris@0
|
2893 QMessageBox::warning
|
Chris@0
|
2894 (this,
|
Chris@0
|
2895 tr("Failed to generate layer"),
|
Chris@0
|
2896 tr("<b>Layer generation failed</b><p>Failed to generate derived layer.<p>The layer transform \"%1\" failed:<p>%2")
|
Chris@0
|
2897 .arg(transformName).arg(message),
|
Chris@0
|
2898 QMessageBox::Ok);
|
Chris@0
|
2899 } else {
|
Chris@0
|
2900 QMessageBox::warning
|
Chris@0
|
2901 (this,
|
Chris@0
|
2902 tr("Failed to generate layer"),
|
Chris@0
|
2903 tr("<b>Layer generation failed</b><p>Failed to generate a derived layer.<p>The layer transform \"%1\" failed.<p>No error information is available.")
|
Chris@0
|
2904 .arg(transformName),
|
Chris@0
|
2905 QMessageBox::Ok);
|
Chris@0
|
2906 }
|
Chris@0
|
2907 }
|
Chris@0
|
2908
|
Chris@0
|
2909 void
|
Chris@355
|
2910 MainWindow::modelGenerationWarning(QString /* transformName */, QString message)
|
Chris@0
|
2911 {
|
Chris@0
|
2912 QMessageBox::warning
|
Chris@0
|
2913 (this, tr("Warning"), message, QMessageBox::Ok);
|
Chris@0
|
2914 }
|
Chris@0
|
2915
|
Chris@0
|
2916 void
|
Chris@0
|
2917 MainWindow::modelRegenerationFailed(QString layerName,
|
Chris@399
|
2918 QString transformName,
|
Chris@399
|
2919 QString message)
|
Chris@0
|
2920 {
|
Chris@0
|
2921 if (message != "") {
|
Chris@0
|
2922
|
Chris@0
|
2923 QMessageBox::warning
|
Chris@0
|
2924 (this,
|
Chris@0
|
2925 tr("Failed to regenerate layer"),
|
Chris@0
|
2926 tr("<b>Layer generation failed</b><p>Failed to regenerate derived layer \"%1\" using new data model as input.<p>The layer transform \"%2\" failed:<p>%3")
|
Chris@0
|
2927 .arg(layerName).arg(transformName).arg(message),
|
Chris@0
|
2928 QMessageBox::Ok);
|
Chris@0
|
2929 } else {
|
Chris@0
|
2930 QMessageBox::warning
|
Chris@0
|
2931 (this,
|
Chris@0
|
2932 tr("Failed to regenerate layer"),
|
Chris@0
|
2933 tr("<b>Layer generation failed</b><p>Failed to regenerate derived layer \"%1\" using new data model as input.<p>The layer transform \"%2\" failed.<p>No error information is available.")
|
Chris@0
|
2934 .arg(layerName).arg(transformName),
|
Chris@0
|
2935 QMessageBox::Ok);
|
Chris@0
|
2936 }
|
Chris@0
|
2937 }
|
Chris@0
|
2938
|
Chris@0
|
2939 void
|
Chris@0
|
2940 MainWindow::modelRegenerationWarning(QString layerName,
|
Chris@355
|
2941 QString /* transformName */,
|
Chris@355
|
2942 QString message)
|
Chris@0
|
2943 {
|
Chris@0
|
2944 QMessageBox::warning
|
Chris@0
|
2945 (this, tr("Warning"), tr("<b>Warning when regenerating layer</b><p>When regenerating the derived layer \"%1\" using new data model as input:<p>%2").arg(layerName).arg(message), QMessageBox::Ok);
|
Chris@0
|
2946 }
|
Chris@0
|
2947
|
Chris@0
|
2948 void
|
Chris@0
|
2949 MainWindow::alignmentFailed(QString transformName, QString message)
|
Chris@0
|
2950 {
|
Chris@0
|
2951 QMessageBox::warning
|
Chris@0
|
2952 (this,
|
Chris@0
|
2953 tr("Failed to calculate alignment"),
|
Chris@0
|
2954 tr("<b>Alignment calculation failed</b><p>Failed to calculate an audio alignment using transform \"%1\":<p>%2")
|
Chris@0
|
2955 .arg(transformName).arg(message),
|
Chris@0
|
2956 QMessageBox::Ok);
|
Chris@0
|
2957 }
|
Chris@0
|
2958
|
Chris@0
|
2959 void
|
Chris@0
|
2960 MainWindow::rightButtonMenuRequested(Pane *pane, QPoint position)
|
Chris@0
|
2961 {
|
Chris@70
|
2962 // cerr << "MainWindow::rightButtonMenuRequested(" << pane << ", " << position.x() << ", " << position.y() << ")" << endl;
|
Chris@0
|
2963 m_paneStack->setCurrentPane(pane);
|
Chris@0
|
2964 m_rightButtonMenu->popup(position);
|
Chris@0
|
2965 }
|
Chris@0
|
2966
|
Chris@0
|
2967 void
|
Chris@355
|
2968 MainWindow::handleOSCMessage(const OSCMessage &)
|
Chris@0
|
2969 {
|
Chris@70
|
2970 cerr << "MainWindow::handleOSCMessage: Not implemented" << endl;
|
Chris@0
|
2971 }
|
Chris@0
|
2972
|
Chris@0
|
2973 void
|
Chris@0
|
2974 MainWindow::mouseEnteredWidget()
|
Chris@0
|
2975 {
|
Chris@3
|
2976 QWidget *w = qobject_cast<QWidget *>(sender());
|
Chris@0
|
2977 if (!w) return;
|
Chris@0
|
2978
|
Chris@0
|
2979 if (w == m_fader) {
|
Chris@0
|
2980 contextHelpChanged(tr("Adjust the master playback level"));
|
Chris@0
|
2981 } else if (w == m_playSpeed) {
|
Chris@0
|
2982 contextHelpChanged(tr("Adjust the master playback speed"));
|
Chris@0
|
2983 } else if (w == m_playSharpen && w->isEnabled()) {
|
Chris@0
|
2984 contextHelpChanged(tr("Toggle transient sharpening for playback time scaling"));
|
Chris@0
|
2985 } else if (w == m_playMono && w->isEnabled()) {
|
Chris@0
|
2986 contextHelpChanged(tr("Toggle mono mode for playback time scaling"));
|
Chris@0
|
2987 }
|
Chris@0
|
2988 }
|
Chris@0
|
2989
|
Chris@0
|
2990 void
|
Chris@0
|
2991 MainWindow::mouseLeftWidget()
|
Chris@0
|
2992 {
|
Chris@0
|
2993 contextHelpChanged("");
|
Chris@0
|
2994 }
|
Chris@0
|
2995
|
Chris@0
|
2996 void
|
Chris@0
|
2997 MainWindow::website()
|
Chris@0
|
2998 {
|
Chris@4
|
2999 //!!! todo: URL!
|
Chris@4
|
3000 openHelpUrl(tr("http://code.soundsoftware.ac.uk/projects/tony/"));
|
Chris@0
|
3001 }
|
Chris@0
|
3002
|
Chris@0
|
3003 void
|
Chris@0
|
3004 MainWindow::help()
|
Chris@0
|
3005 {
|
Chris@4
|
3006 //!!! todo: help URL!
|
matthiasm@369
|
3007 openHelpUrl(tr("http://code.soundsoftware.ac.uk/projects/tony/wiki/Reference"));
|
Chris@0
|
3008 }
|
Chris@0
|
3009
|
Chris@0
|
3010 void
|
Chris@0
|
3011 MainWindow::about()
|
Chris@0
|
3012 {
|
Chris@0
|
3013 bool debug = false;
|
Chris@0
|
3014 QString version = "(unknown version)";
|
Chris@0
|
3015
|
Chris@0
|
3016 #ifdef BUILD_DEBUG
|
Chris@0
|
3017 debug = true;
|
Chris@0
|
3018 #endif
|
Chris@0
|
3019 version = tr("Release %1").arg(TONY_VERSION);
|
Chris@0
|
3020
|
Chris@0
|
3021 QString aboutText;
|
Chris@0
|
3022
|
Chris@0
|
3023 aboutText += tr("<h3>About Tony</h3>");
|
Chris@0
|
3024 aboutText += tr("<p>Tony is a program for interactive note and pitch analysis and annotation.</p>");
|
Chris@0
|
3025 aboutText += tr("<p>%1 : %2 configuration</p>")
|
Chris@0
|
3026 .arg(version)
|
Chris@0
|
3027 .arg(debug ? tr("Debug") : tr("Release"));
|
Chris@212
|
3028 aboutText += tr("<p>Using Qt framework version %1.</p>")
|
Chris@206
|
3029 .arg(QT_VERSION_STR);
|
Chris@0
|
3030
|
Chris@0
|
3031 aboutText +=
|
Chris@266
|
3032 "<p>Copyright © 2005–2014 Chris Cannam, Queen Mary University of London, and the Tony project authors: Matthias Mauch, George Fazekas, Justin Salamon, and Rachel Bittner.</p>"
|
Chris@212
|
3033 "<p>pYIN analysis plugin written by Matthias Mauch.</p>"
|
Chris@90
|
3034 "<p>This program is free software; you can redistribute it and/or "
|
Chris@90
|
3035 "modify it under the terms of the GNU General Public License as "
|
Chris@90
|
3036 "published by the Free Software Foundation; either version 2 of the "
|
Chris@0
|
3037 "License, or (at your option) any later version.<br>See the file "
|
Chris@0
|
3038 "COPYING included with this distribution for more information.</p>";
|
Chris@0
|
3039
|
Chris@0
|
3040 QMessageBox::about(this, tr("About %1").arg(QApplication::applicationName()), aboutText);
|
Chris@0
|
3041 }
|
Chris@0
|
3042
|
Chris@0
|
3043 void
|
Chris@0
|
3044 MainWindow::keyReference()
|
Chris@0
|
3045 {
|
Chris@0
|
3046 m_keyReference->show();
|
Chris@0
|
3047 }
|
Chris@0
|
3048
|
Chris@231
|
3049 void
|
Chris@231
|
3050 MainWindow::newerVersionAvailable(QString version)
|
Chris@231
|
3051 {
|
Chris@231
|
3052 //!!! nicer URL would be nicer
|
Chris@231
|
3053 QSettings settings;
|
Chris@231
|
3054 settings.beginGroup("NewerVersionWarning");
|
Chris@231
|
3055 QString tag = QString("version-%1-available-show").arg(version);
|
Chris@231
|
3056 if (settings.value(tag, true).toBool()) {
|
Chris@231
|
3057 QString title(tr("Newer version available"));
|
Chris@231
|
3058 QString text(tr("<h3>Newer version available</h3><p>You are using version %1 of Tony, but version %2 is now available.</p><p>Please see the <a href=\"http://code.soundsoftware.ac.uk/projects/tony/\">Tony website</a> for more information.</p>").arg(TONY_VERSION).arg(version));
|
Chris@231
|
3059 QMessageBox::information(this, title, text);
|
Chris@231
|
3060 settings.setValue(tag, false);
|
Chris@231
|
3061 }
|
Chris@231
|
3062 settings.endGroup();
|
Chris@231
|
3063 }
|
Chris@231
|
3064
|
matthiasm@356
|
3065 void
|
matthiasm@356
|
3066 MainWindow::ffwd()
|
matthiasm@356
|
3067 {
|
matthiasm@356
|
3068 if (!getMainModel()) return;
|
matthiasm@356
|
3069
|
Chris@403
|
3070 sv_frame_t frame = m_viewManager->getPlaybackFrame();
|
matthiasm@356
|
3071 ++frame;
|
matthiasm@356
|
3072
|
Chris@403
|
3073 sv_samplerate_t sr = getMainModel()->getSampleRate();
|
matthiasm@356
|
3074
|
matthiasm@356
|
3075 // The step is supposed to scale and be as wide as a step of
|
matthiasm@357
|
3076 // m_defaultFfwdRwdStep seconds at zoom level 720 and sr = 44100
|
Chris@403
|
3077 int framesPerPixel = m_viewManager->getGlobalZoom();
|
Chris@403
|
3078
|
Chris@403
|
3079 double defaultZoom = (720 * 44100) / sr;
|
Chris@403
|
3080 double scaler = framesPerPixel / defaultZoom;
|
Chris@403
|
3081 RealTime step = m_defaultFfwdRwdStep * scaler;
|
Chris@403
|
3082
|
matthiasm@356
|
3083 frame = RealTime::realTime2Frame
|
Chris@403
|
3084 (RealTime::frame2RealTime(frame, sr) + step, sr);
|
Chris@403
|
3085
|
Chris@403
|
3086 if (frame > getMainModel()->getEndFrame()) {
|
matthiasm@356
|
3087 frame = getMainModel()->getEndFrame();
|
matthiasm@356
|
3088 }
|
Chris@403
|
3089
|
matthiasm@356
|
3090 if (frame < 0) frame = 0;
|
matthiasm@356
|
3091
|
matthiasm@356
|
3092 if (m_viewManager->getPlaySelectionMode()) {
|
Chris@403
|
3093 frame = m_viewManager->constrainFrameToSelection(frame);
|
matthiasm@356
|
3094 }
|
matthiasm@356
|
3095
|
matthiasm@356
|
3096 m_viewManager->setPlaybackFrame(frame);
|
matthiasm@356
|
3097
|
Chris@403
|
3098 if (frame == getMainModel()->getEndFrame() &&
|
matthiasm@356
|
3099 m_playSource &&
|
matthiasm@356
|
3100 m_playSource->isPlaying() &&
|
matthiasm@356
|
3101 !m_viewManager->getPlayLoopMode()) {
|
matthiasm@356
|
3102 stop();
|
matthiasm@356
|
3103 }
|
matthiasm@356
|
3104 }
|
matthiasm@356
|
3105
|
matthiasm@356
|
3106 void
|
matthiasm@356
|
3107 MainWindow::rewind()
|
matthiasm@356
|
3108 {
|
matthiasm@356
|
3109 if (!getMainModel()) return;
|
matthiasm@356
|
3110
|
Chris@403
|
3111 sv_frame_t frame = m_viewManager->getPlaybackFrame();
|
matthiasm@356
|
3112 if (frame > 0) --frame;
|
matthiasm@356
|
3113
|
Chris@403
|
3114 sv_samplerate_t sr = getMainModel()->getSampleRate();
|
matthiasm@356
|
3115
|
matthiasm@356
|
3116 // The step is supposed to scale and be as wide as a step of
|
matthiasm@357
|
3117 // m_defaultFfwdRwdStep seconds at zoom level 720 and sr = 44100
|
Chris@403
|
3118 int framesPerPixel = m_viewManager->getGlobalZoom();
|
Chris@403
|
3119
|
Chris@403
|
3120 double defaultZoom = (720 * 44100) / sr;
|
Chris@403
|
3121 double scaler = framesPerPixel / defaultZoom;
|
Chris@403
|
3122 RealTime step = m_defaultFfwdRwdStep * scaler;
|
Chris@403
|
3123
|
matthiasm@356
|
3124 frame = RealTime::realTime2Frame
|
Chris@403
|
3125 (RealTime::frame2RealTime(frame, sr) - step, sr);
|
Chris@403
|
3126
|
Chris@403
|
3127 if (frame < getMainModel()->getStartFrame()) {
|
matthiasm@356
|
3128 frame = getMainModel()->getStartFrame();
|
matthiasm@356
|
3129 }
|
matthiasm@356
|
3130
|
matthiasm@356
|
3131 if (frame < 0) frame = 0;
|
matthiasm@356
|
3132
|
matthiasm@356
|
3133 if (m_viewManager->getPlaySelectionMode()) {
|
Chris@403
|
3134 frame = m_viewManager->constrainFrameToSelection(frame);
|
matthiasm@356
|
3135 }
|
matthiasm@356
|
3136
|
matthiasm@356
|
3137 m_viewManager->setPlaybackFrame(frame);
|
matthiasm@356
|
3138 }
|