Mercurial > hg > tony
comparison src/MainWindow.cpp @ 474:7665cc683dd1 2.0-integration
Merge through to branch for Tony 2.0
author | Chris Cannam |
---|---|
date | Thu, 20 Aug 2015 14:54:21 +0100 |
parents | 12f2c987e2b5 |
children | bc48192e8307 30b304e22610 |
comparison
equal
deleted
inserted
replaced
473:ceecc71eeb20 | 474:7665cc683dd1 |
---|---|
40 #include "view/Overview.h" | 40 #include "view/Overview.h" |
41 #include "widgets/AudioDial.h" | 41 #include "widgets/AudioDial.h" |
42 #include "widgets/IconLoader.h" | 42 #include "widgets/IconLoader.h" |
43 #include "widgets/KeyReference.h" | 43 #include "widgets/KeyReference.h" |
44 #include "widgets/LevelPanToolButton.h" | 44 #include "widgets/LevelPanToolButton.h" |
45 #include "audioio/AudioCallbackPlaySource.h" | 45 #include "audio/AudioCallbackPlaySource.h" |
46 #include "audioio/AudioCallbackPlayTarget.h" | 46 #include "audio/AudioRecordTarget.h" |
47 #include "audioio/PlaySpeedRangeMapper.h" | 47 #include "audio/PlaySpeedRangeMapper.h" |
48 #include "base/Profiler.h" | 48 #include "base/Profiler.h" |
49 #include "base/UnitDatabase.h" | 49 #include "base/UnitDatabase.h" |
50 #include "layer/ColourDatabase.h" | 50 #include "layer/ColourDatabase.h" |
51 #include "base/Selection.h" | 51 #include "base/Selection.h" |
52 | 52 |
63 // For version information | 63 // For version information |
64 #include "vamp/vamp.h" | 64 #include "vamp/vamp.h" |
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 | |
69 #include <bqaudioio/SystemPlaybackTarget.h> | |
68 | 70 |
69 #include <QApplication> | 71 #include <QApplication> |
70 #include <QMessageBox> | 72 #include <QMessageBox> |
71 #include <QGridLayout> | 73 #include <QGridLayout> |
72 #include <QLabel> | 74 #include <QLabel> |
89 #include <errno.h> | 91 #include <errno.h> |
90 | 92 |
91 using std::vector; | 93 using std::vector; |
92 | 94 |
93 | 95 |
94 MainWindow::MainWindow(bool withAudioOutput, bool withSonification, bool withSpectrogram) : | 96 MainWindow::MainWindow(SoundOptions options, bool withSonification, bool withSpectrogram) : |
95 MainWindowBase(withAudioOutput, false), | 97 MainWindowBase(options), |
96 m_overview(0), | 98 m_overview(0), |
97 m_mainMenusCreated(false), | 99 m_mainMenusCreated(false), |
98 m_playbackMenu(0), | 100 m_playbackMenu(0), |
99 m_recentFilesMenu(0), | 101 m_recentFilesMenu(0), |
100 m_rightButtonMenu(0), | 102 m_rightButtonMenu(0), |
232 m_playSpeed->setFixedHeight(24); | 234 m_playSpeed->setFixedHeight(24); |
233 m_playSpeed->setNotchesVisible(true); | 235 m_playSpeed->setNotchesVisible(true); |
234 m_playSpeed->setPageStep(10); | 236 m_playSpeed->setPageStep(10); |
235 m_playSpeed->setObjectName(tr("Playback Speedup")); | 237 m_playSpeed->setObjectName(tr("Playback Speedup")); |
236 m_playSpeed->setDefaultValue(100); | 238 m_playSpeed->setDefaultValue(100); |
237 m_playSpeed->setRangeMapper(new PlaySpeedRangeMapper(0, 200)); | 239 m_playSpeed->setRangeMapper(new PlaySpeedRangeMapper); |
238 m_playSpeed->setShowToolTip(true); | 240 m_playSpeed->setShowToolTip(true); |
239 connect(m_playSpeed, SIGNAL(valueChanged(int)), | 241 connect(m_playSpeed, SIGNAL(valueChanged(int)), |
240 this, SLOT(playSpeedChanged(int))); | 242 this, SLOT(playSpeedChanged(int))); |
241 connect(m_playSpeed, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); | 243 connect(m_playSpeed, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); |
242 connect(m_playSpeed, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); | 244 connect(m_playSpeed, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); |
368 IconLoader il; | 370 IconLoader il; |
369 QIcon icon; | 371 QIcon icon; |
370 QAction *action; | 372 QAction *action; |
371 | 373 |
372 icon = il.load("fileopen"); | 374 icon = il.load("fileopen"); |
373 icon.addPixmap(il.loadPixmap("fileopen-22")); | |
374 action = new QAction(icon, tr("&Open..."), this); | 375 action = new QAction(icon, tr("&Open..."), this); |
375 action->setShortcut(tr("Ctrl+O")); | 376 action->setShortcut(tr("Ctrl+O")); |
376 action->setStatusTip(tr("Open a session or audio file")); | 377 action->setStatusTip(tr("Open a session or audio file")); |
377 connect(action, SIGNAL(triggered()), this, SLOT(openFile())); | 378 connect(action, SIGNAL(triggered()), this, SLOT(openFile())); |
378 m_keyReference->registerShortcut(action); | 379 m_keyReference->registerShortcut(action); |
393 this, SLOT(setupRecentFilesMenu())); | 394 this, SLOT(setupRecentFilesMenu())); |
394 | 395 |
395 menu->addSeparator(); | 396 menu->addSeparator(); |
396 | 397 |
397 icon = il.load("filesave"); | 398 icon = il.load("filesave"); |
398 icon.addPixmap(il.loadPixmap("filesave-22")); | |
399 action = new QAction(icon, tr("&Save Session"), this); | 399 action = new QAction(icon, tr("&Save Session"), this); |
400 action->setShortcut(tr("Ctrl+S")); | 400 action->setShortcut(tr("Ctrl+S")); |
401 action->setStatusTip(tr("Save the current session into a %1 session file").arg(QApplication::applicationName())); | 401 action->setStatusTip(tr("Save the current session into a %1 session file").arg(QApplication::applicationName())); |
402 connect(action, SIGNAL(triggered()), this, SLOT(saveSession())); | 402 connect(action, SIGNAL(triggered()), this, SLOT(saveSession())); |
403 connect(this, SIGNAL(canSave(bool)), action, SLOT(setEnabled(bool))); | 403 connect(this, SIGNAL(canSave(bool)), action, SLOT(setEnabled(bool))); |
404 m_keyReference->registerShortcut(action); | 404 m_keyReference->registerShortcut(action); |
405 menu->addAction(action); | 405 menu->addAction(action); |
406 toolbar->addAction(action); | 406 toolbar->addAction(action); |
407 | 407 |
408 icon = il.load("filesaveas"); | 408 icon = il.load("filesaveas"); |
409 icon.addPixmap(il.loadPixmap("filesaveas-22")); | |
410 action = new QAction(icon, tr("Save Session &As..."), this); | 409 action = new QAction(icon, tr("Save Session &As..."), this); |
411 action->setShortcut(tr("Ctrl+Shift+S")); | 410 action->setShortcut(tr("Ctrl+Shift+S")); |
412 action->setStatusTip(tr("Save the current session into a new %1 session file").arg(QApplication::applicationName())); | 411 action->setStatusTip(tr("Save the current session into a new %1 session file").arg(QApplication::applicationName())); |
413 connect(action, SIGNAL(triggered()), this, SLOT(saveSessionAs())); | 412 connect(action, SIGNAL(triggered()), this, SLOT(saveSessionAs())); |
414 connect(this, SIGNAL(canSaveAs(bool)), action, SLOT(setEnabled(bool))); | 413 connect(this, SIGNAL(canSaveAs(bool)), action, SLOT(setEnabled(bool))); |
2638 } | 2637 } |
2639 | 2638 |
2640 void | 2639 void |
2641 MainWindow::playSpeedChanged(int position) | 2640 MainWindow::playSpeedChanged(int position) |
2642 { | 2641 { |
2643 PlaySpeedRangeMapper mapper(0, 200); | 2642 PlaySpeedRangeMapper mapper; |
2644 | 2643 |
2645 double percent = m_playSpeed->mappedValue(); | 2644 double percent = m_playSpeed->mappedValue(); |
2646 double factor = mapper.getFactorForValue(percent); | 2645 double factor = mapper.getFactorForValue(percent); |
2647 | 2646 |
2648 cerr << "speed = " << position << " percent = " << percent << " factor = " << factor << endl; | 2647 int centre = m_playSpeed->defaultValue(); |
2649 | 2648 |
2650 bool something = (position != 100); | 2649 // Percentage is shown to 0dp if >100, to 1dp if <100; factor is |
2651 | 2650 // shown to 3sf |
2652 int pc = int(lrint(percent)); | 2651 |
2653 | 2652 char pcbuf[30]; |
2654 if (!something) { | 2653 char facbuf[30]; |
2654 | |
2655 if (position == centre) { | |
2655 contextHelpChanged(tr("Playback speed: Normal")); | 2656 contextHelpChanged(tr("Playback speed: Normal")); |
2657 } else if (position < centre) { | |
2658 sprintf(pcbuf, "%.1f", percent); | |
2659 sprintf(facbuf, "%.3g", 1.0 / factor); | |
2660 contextHelpChanged(tr("Playback speed: %1% (%2x slower)") | |
2661 .arg(pcbuf) | |
2662 .arg(facbuf)); | |
2656 } else { | 2663 } else { |
2657 contextHelpChanged(tr("Playback speed: %1%2%") | 2664 sprintf(pcbuf, "%.0f", percent); |
2658 .arg(position > 100 ? "+" : "") | 2665 sprintf(facbuf, "%.3g", factor); |
2659 .arg(pc)); | 2666 contextHelpChanged(tr("Playback speed: %1% (%2x faster)") |
2660 } | 2667 .arg(pcbuf) |
2661 | 2668 .arg(facbuf)); |
2662 m_playSource->setTimeStretch(factor); | 2669 } |
2670 | |
2671 m_playSource->setTimeStretch(1.0 / factor); // factor is a speedup | |
2663 | 2672 |
2664 updateMenuStates(); | 2673 updateMenuStates(); |
2665 } | 2674 } |
2666 | 2675 |
2667 void | 2676 void |
2908 | 2917 |
2909 MainWindowBase::mainModelChanged(model); | 2918 MainWindowBase::mainModelChanged(model); |
2910 | 2919 |
2911 if (m_playTarget) { | 2920 if (m_playTarget) { |
2912 connect(m_fader, SIGNAL(valueChanged(float)), | 2921 connect(m_fader, SIGNAL(valueChanged(float)), |
2913 m_playTarget, SLOT(setOutputGain(float))); | 2922 this, SLOT(mainModelGainChanged(float))); |
2923 } | |
2924 } | |
2925 | |
2926 void | |
2927 MainWindow::mainModelGainChanged(float gain) | |
2928 { | |
2929 if (m_playTarget) { | |
2930 m_playTarget->setOutputGain(gain); | |
2914 } | 2931 } |
2915 } | 2932 } |
2916 | 2933 |
2917 void | 2934 void |
2918 MainWindow::analyseNow() | 2935 MainWindow::analyseNow() |