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