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