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