comparison src/MainWindow.cpp @ 494:ffb9df50a761 2.0-integration

Merge from recording branch
author Chris Cannam
date Mon, 12 Oct 2015 14:06:39 +0100
parents 9fd236af50c0
children c337e3f74838
comparison
equal deleted inserted replaced
493:cb24473eadc5 494:ffb9df50a761
65 #include "vamp-sdk/PluginBase.h" 65 #include "vamp-sdk/PluginBase.h"
66 #include "plugin/api/ladspa.h" 66 #include "plugin/api/ladspa.h"
67 #include "plugin/api/dssi.h" 67 #include "plugin/api/dssi.h"
68 68
69 #include <bqaudioio/SystemPlaybackTarget.h> 69 #include <bqaudioio/SystemPlaybackTarget.h>
70 #include <bqaudioio/SystemAudioIO.h>
70 71
71 #include <QApplication> 72 #include <QApplication>
72 #include <QMessageBox> 73 #include <QMessageBox>
73 #include <QGridLayout> 74 #include <QGridLayout>
74 #include <QLabel> 75 #include <QLabel>
297 connect(this, SIGNAL(replacedDocument()), this, SLOT(documentReplaced())); 298 connect(this, SIGNAL(replacedDocument()), this, SLOT(documentReplaced()));
298 connect(this, SIGNAL(sessionLoaded()), this, SLOT(analyseNewMainModel())); 299 connect(this, SIGNAL(sessionLoaded()), this, SLOT(analyseNewMainModel()));
299 connect(this, SIGNAL(audioFileLoaded()), this, SLOT(analyseNewMainModel())); 300 connect(this, SIGNAL(audioFileLoaded()), this, SLOT(analyseNewMainModel()));
300 m_activityLog->hide(); 301 m_activityLog->hide();
301 302
303 setAudioRecordMode(RecordReplaceSession);
304
302 newSession(); 305 newSession();
303 306
304 settings.beginGroup("MainWindow"); 307 settings.beginGroup("MainWindow");
305 settings.setValue("zoom-default", 512); 308 settings.setValue("zoom-default", 512);
306 settings.endGroup(); 309 settings.endGroup();
412 connect(action, SIGNAL(triggered()), this, SLOT(saveSessionAs())); 415 connect(action, SIGNAL(triggered()), this, SLOT(saveSessionAs()));
413 connect(this, SIGNAL(canSaveAs(bool)), action, SLOT(setEnabled(bool))); 416 connect(this, SIGNAL(canSaveAs(bool)), action, SLOT(setEnabled(bool)));
414 menu->addAction(action); 417 menu->addAction(action);
415 toolbar->addAction(action); 418 toolbar->addAction(action);
416 419
417 action = new QAction(tr("Save Session to Audio &Path"), this); 420 action = new QAction(tr("Save Session to Audio File &Path"), this);
418 action->setShortcut(tr("Ctrl+Alt+S")); 421 action->setShortcut(tr("Ctrl+Alt+S"));
419 action->setStatusTip(tr("Save the current session into a %1 session file with the same filename as the audio but a .ton extension.").arg(QApplication::applicationName())); 422 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()));
420 connect(action, SIGNAL(triggered()), this, SLOT(saveSessionInAudioPath())); 423 connect(action, SIGNAL(triggered()), this, SLOT(saveSessionInAudioPath()));
421 connect(this, SIGNAL(canSaveAs(bool)), action, SLOT(setEnabled(bool))); 424 connect(this, SIGNAL(canSaveAs(bool)), action, SLOT(setEnabled(bool)));
422 menu->addAction(action); 425 menu->addAction(action);
440 connect(action, SIGNAL(triggered()), this, SLOT(exportNoteLayer())); 443 connect(action, SIGNAL(triggered()), this, SLOT(exportNoteLayer()));
441 connect(this, SIGNAL(canExportNotes(bool)), action, SLOT(setEnabled(bool))); 444 connect(this, SIGNAL(canExportNotes(bool)), action, SLOT(setEnabled(bool)));
442 menu->addAction(action); 445 menu->addAction(action);
443 446
444 menu->addSeparator(); 447 menu->addSeparator();
448
449 action = new QAction(tr("Browse Recorded Audio"), this);
450 action->setStatusTip(tr("Open the Recorded Audio folder in the system file browser"));
451 connect(action, SIGNAL(triggered()), this, SLOT(browseRecordedAudio()));
452 menu->addAction(action);
453
454 menu->addSeparator();
455
445 action = new QAction(il.load("exit"), tr("&Quit"), this); 456 action = new QAction(il.load("exit"), tr("&Quit"), this);
446 action->setShortcut(tr("Ctrl+Q")); 457 action->setShortcut(tr("Ctrl+Q"));
447 action->setStatusTip(tr("Exit %1").arg(QApplication::applicationName())); 458 action->setStatusTip(tr("Exit %1").arg(QApplication::applicationName()));
448 connect(action, SIGNAL(triggered()), this, SLOT(close())); 459 connect(action, SIGNAL(triggered()), this, SLOT(close()));
449 m_keyReference->registerShortcut(action); 460 m_keyReference->registerShortcut(action);
1018 ffwdEndAction->setShortcut(tr("End")); 1029 ffwdEndAction->setShortcut(tr("End"));
1019 ffwdEndAction->setStatusTip(tr("Fast-forward to the end")); 1030 ffwdEndAction->setStatusTip(tr("Fast-forward to the end"));
1020 connect(ffwdEndAction, SIGNAL(triggered()), this, SLOT(ffwdEnd())); 1031 connect(ffwdEndAction, SIGNAL(triggered()), this, SLOT(ffwdEnd()));
1021 connect(this, SIGNAL(canPlay(bool)), ffwdEndAction, SLOT(setEnabled(bool))); 1032 connect(this, SIGNAL(canPlay(bool)), ffwdEndAction, SLOT(setEnabled(bool)));
1022 1033
1034 QAction *recordAction = toolbar->addAction(il.load("record"),
1035 tr("Record"));
1036 recordAction->setCheckable(true);
1037 recordAction->setShortcut(tr("Ctrl+Space"));
1038 recordAction->setStatusTip(tr("Record a new audio file"));
1039 connect(recordAction, SIGNAL(triggered()), this, SLOT(record()));
1040 connect(m_recordTarget, SIGNAL(recordStatusChanged(bool)),
1041 recordAction, SLOT(setChecked(bool)));
1042 connect(this, SIGNAL(canRecord(bool)),
1043 recordAction, SLOT(setEnabled(bool)));
1044
1023 toolbar = addToolBar(tr("Play Mode Toolbar")); 1045 toolbar = addToolBar(tr("Play Mode Toolbar"));
1024 1046
1025 QAction *psAction = toolbar->addAction(il.load("playselection"), 1047 QAction *psAction = toolbar->addAction(il.load("playselection"),
1026 tr("Constrain Playback to Selection")); 1048 tr("Constrain Playback to Selection"));
1027 psAction->setCheckable(true); 1049 psAction->setCheckable(true);
1069 connect(this, SIGNAL(canScroll(bool)), selectOneRightAction, SLOT(setEnabled(bool))); 1091 connect(this, SIGNAL(canScroll(bool)), selectOneRightAction, SLOT(setEnabled(bool)));
1070 1092
1071 m_keyReference->registerShortcut(psAction); 1093 m_keyReference->registerShortcut(psAction);
1072 m_keyReference->registerShortcut(plAction); 1094 m_keyReference->registerShortcut(plAction);
1073 m_keyReference->registerShortcut(playAction); 1095 m_keyReference->registerShortcut(playAction);
1096 m_keyReference->registerShortcut(recordAction);
1074 m_keyReference->registerShortcut(m_rwdAction); 1097 m_keyReference->registerShortcut(m_rwdAction);
1075 m_keyReference->registerShortcut(m_ffwdAction); 1098 m_keyReference->registerShortcut(m_ffwdAction);
1076 m_keyReference->registerShortcut(rwdStartAction); 1099 m_keyReference->registerShortcut(rwdStartAction);
1077 m_keyReference->registerShortcut(ffwdEndAction); 1100 m_keyReference->registerShortcut(ffwdEndAction);
1101 m_keyReference->registerShortcut(recordAction);
1078 m_keyReference->registerShortcut(oneLeftAction); 1102 m_keyReference->registerShortcut(oneLeftAction);
1079 m_keyReference->registerShortcut(oneRightAction); 1103 m_keyReference->registerShortcut(oneRightAction);
1080 m_keyReference->registerShortcut(selectOneLeftAction); 1104 m_keyReference->registerShortcut(selectOneLeftAction);
1081 m_keyReference->registerShortcut(selectOneRightAction); 1105 m_keyReference->registerShortcut(selectOneRightAction);
1082 1106
1093 menu->addAction(oneLeftAction); 1117 menu->addAction(oneLeftAction);
1094 menu->addAction(oneRightAction); 1118 menu->addAction(oneRightAction);
1095 menu->addAction(selectOneLeftAction); 1119 menu->addAction(selectOneLeftAction);
1096 menu->addAction(selectOneRightAction); 1120 menu->addAction(selectOneRightAction);
1097 menu->addSeparator(); 1121 menu->addSeparator();
1122 menu->addAction(recordAction);
1123 menu->addSeparator();
1098 1124
1099 m_rightButtonPlaybackMenu->addAction(playAction); 1125 m_rightButtonPlaybackMenu->addAction(playAction);
1100 m_rightButtonPlaybackMenu->addAction(psAction); 1126 m_rightButtonPlaybackMenu->addAction(psAction);
1101 m_rightButtonPlaybackMenu->addAction(plAction); 1127 m_rightButtonPlaybackMenu->addAction(plAction);
1102 m_rightButtonPlaybackMenu->addSeparator(); 1128 m_rightButtonPlaybackMenu->addSeparator();
1109 m_rightButtonPlaybackMenu->addAction(oneLeftAction); 1135 m_rightButtonPlaybackMenu->addAction(oneLeftAction);
1110 m_rightButtonPlaybackMenu->addAction(oneRightAction); 1136 m_rightButtonPlaybackMenu->addAction(oneRightAction);
1111 m_rightButtonPlaybackMenu->addAction(selectOneLeftAction); 1137 m_rightButtonPlaybackMenu->addAction(selectOneLeftAction);
1112 m_rightButtonPlaybackMenu->addAction(selectOneRightAction); 1138 m_rightButtonPlaybackMenu->addAction(selectOneRightAction);
1113 m_rightButtonPlaybackMenu->addSeparator(); 1139 m_rightButtonPlaybackMenu->addSeparator();
1140 m_rightButtonPlaybackMenu->addAction(recordAction);
1141 m_rightButtonPlaybackMenu->addSeparator();
1114 1142
1115 QAction *fastAction = menu->addAction(tr("Speed Up")); 1143 QAction *fastAction = menu->addAction(tr("Speed Up"));
1116 fastAction->setShortcut(tr("Ctrl+PgUp")); 1144 fastAction->setShortcut(tr("Ctrl+PgUp"));
1117 fastAction->setStatusTip(tr("Time-stretch playback to speed it up without changing pitch")); 1145 fastAction->setStatusTip(tr("Time-stretch playback to speed it up without changing pitch"));
1118 connect(fastAction, SIGNAL(triggered()), this, SLOT(speedUpPlayback())); 1146 connect(fastAction, SIGNAL(triggered()), this, SLOT(speedUpPlayback()));
1359 if (currentPane) currentLayer = currentPane->getSelectedLayer(); 1387 if (currentPane) currentLayer = currentPane->getSelectedLayer();
1360 1388
1361 bool haveMainModel = 1389 bool haveMainModel =
1362 (getMainModel() != 0); 1390 (getMainModel() != 0);
1363 bool havePlayTarget = 1391 bool havePlayTarget =
1364 (m_playTarget != 0); 1392 (m_playTarget != 0 || m_audioIO != 0);
1365 bool haveCurrentPane = 1393 bool haveCurrentPane =
1366 (currentPane != 0); 1394 (currentPane != 0);
1367 bool haveCurrentLayer = 1395 bool haveCurrentLayer =
1368 (haveCurrentPane && 1396 (haveCurrentPane &&
1369 (currentLayer != 0)); 1397 (currentLayer != 0));
1398 1426
1399 emit canExportPitchTrack(havePitchTrack); 1427 emit canExportPitchTrack(havePitchTrack);
1400 emit canExportNotes(haveNotes); 1428 emit canExportNotes(haveNotes);
1401 emit canSnapNotes(haveSelection && haveNotes); 1429 emit canSnapNotes(haveSelection && haveNotes);
1402 1430
1431 cerr << "haveWaveform = " << haveWaveform << endl;
1432 cerr << "haveMainModel = " << haveMainModel << endl;
1433 cerr << "havePlayTarget = " << havePlayTarget << endl;
1434
1403 emit canPlayWaveform(haveWaveform && haveMainModel && havePlayTarget); 1435 emit canPlayWaveform(haveWaveform && haveMainModel && havePlayTarget);
1404 emit canPlayPitch(havePitchTrack && haveMainModel && havePlayTarget); 1436 emit canPlayPitch(havePitchTrack && haveMainModel && havePlayTarget);
1405 emit canPlayNotes(haveNotes && haveMainModel && havePlayTarget); 1437 emit canPlayNotes(haveNotes && haveMainModel && havePlayTarget);
1406 1438
1407 if (pitchCandidatesVisible) { 1439 if (pitchCandidatesVisible) {
2317 emit activity(tr("Export layer to \"%1\"").arg(path)); 2349 emit activity(tr("Export layer to \"%1\"").arg(path));
2318 } 2350 }
2319 } 2351 }
2320 2352
2321 void 2353 void
2354 MainWindow::browseRecordedAudio()
2355 {
2356 if (!m_recordTarget) return;
2357
2358 QString path = m_recordTarget->getRecordFolder();
2359 if (path == "") return;
2360
2361 openLocalFolder(path);
2362 }
2363
2364 void
2322 MainWindow::doubleClickSelectInvoked(sv_frame_t frame) 2365 MainWindow::doubleClickSelectInvoked(sv_frame_t frame)
2323 { 2366 {
2324 sv_frame_t f0, f1; 2367 sv_frame_t f0, f1;
2325 m_analyser->getEnclosingSelectionScope(frame, f0, f1); 2368 m_analyser->getEnclosingSelectionScope(frame, f0, f1);
2326 2369
2915 { 2958 {
2916 m_panLayer->setModel(model); 2959 m_panLayer->setModel(model);
2917 2960
2918 MainWindowBase::mainModelChanged(model); 2961 MainWindowBase::mainModelChanged(model);
2919 2962
2920 if (m_playTarget) { 2963 if (m_playTarget || m_audioIO) {
2921 connect(m_fader, SIGNAL(valueChanged(float)), 2964 connect(m_fader, SIGNAL(valueChanged(float)),
2922 this, SLOT(mainModelGainChanged(float))); 2965 this, SLOT(mainModelGainChanged(float)));
2923 } 2966 }
2924 } 2967 }
2925 2968
2926 void 2969 void
2927 MainWindow::mainModelGainChanged(float gain) 2970 MainWindow::mainModelGainChanged(float gain)
2928 { 2971 {
2929 if (m_playTarget) { 2972 if (m_playTarget) {
2930 m_playTarget->setOutputGain(gain); 2973 m_playTarget->setOutputGain(gain);
2974 } else if (m_audioIO) {
2975 m_audioIO->setOutputGain(gain);
2931 } 2976 }
2932 } 2977 }
2933 2978
2934 void 2979 void
2935 MainWindow::analyseNow() 2980 MainWindow::analyseNow()
3026 m_analyser->setAudible(Analyser::PitchTrack, false); 3071 m_analyser->setAudible(Analyser::PitchTrack, false);
3027 m_analyser->setAudible(Analyser::Notes, false); 3072 m_analyser->setAudible(Analyser::Notes, false);
3028 } 3073 }
3029 3074
3030 updateLayerStatuses(); 3075 updateLayerStatuses();
3076 documentRestored();
3031 } 3077 }
3032 3078
3033 void 3079 void
3034 MainWindow::modelGenerationFailed(QString transformName, QString message) 3080 MainWindow::modelGenerationFailed(QString transformName, QString message)
3035 { 3081 {