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