changeset 1407:582e2b40be9c 3.0-integration

Merge from branch bqresample
author Chris Cannam
date Fri, 09 Dec 2016 18:01:55 +0000 (2016-12-09)
parents 032bf0b11de9 (current diff) 026c1e7f3359 (diff)
children 35c374cadfc4
files .hgsubstate
diffstat 5 files changed, 173 insertions(+), 49 deletions(-) [+]
line wrap: on
line diff
--- a/.hgsubstate	Mon Dec 05 16:39:03 2016 +0000
+++ b/.hgsubstate	Fri Dec 09 18:01:55 2016 +0000
@@ -1,13 +1,13 @@
-da88a268a477c7d24d715ce5cc041157ce4907ac bqaudioio
-f8f6b66b9875e6a9f153c1692b9f6cb241d51bf0 bqfft
-6b0cbfca8fb7cf64f89b0a0026b63bc212b156af bqresample
-68f8e88d6d76fc4ca074166cb80979ccbfc2b6c9 bqvec
+e0f39e5e3b2026683e818bfe0d447663ddb44382 bqaudioio
+048fd8ba184040d217f33a9ea3cbdc5676a2876f bqfft
+1735a488ded2bbd0f1a60cd33c4c26b3672e49a2 bqresample
+bce0791a62fe3dac4717a1a90aa03dc5cea7ccb4 bqvec
 1eefc20919cd080b684b2bbbc0af7270b8facb54 checker
 3768bdde6fdf866aa63fff5bde8d9fa64a8979ef dataquay
 c37b5598a4beb570417716e30aa649c78312169f icons/scalable
 3257ddb6fff110cc88f3ffeaeefa0f29d5eb3b6f piper-cpp
 5f67a29f0fc7f1b908f7cde4866173a7af337862 sv-dependency-builds
-167d37937436f87a1836c0933d51404767ecd6ce svapp
-ea28ee929034977f941b9713e82583fc3d9b1312 svcore
-db90fee630bc756c3c64a6f904b551acb13e000f svgui
+4be200469a9c0a23987970f49e452bd61a216828 svapp
+e939a365e4d21169464274df3e66f929854e0942 svcore
+6605984fa98f40534b2706555979a16592733850 svgui
 0eebd22a081a824067bf3d5de65326696feab653 vamp-plugin-sdk
--- a/bq-files.pri	Mon Dec 05 16:39:03 2016 +0000
+++ b/bq-files.pri	Fri Dec 09 18:01:55 2016 +0000
@@ -15,18 +15,14 @@
 	bqaudioio/bqaudioio/ApplicationPlaybackSource.h \
 	bqaudioio/bqaudioio/ApplicationRecordTarget.h \
 	bqaudioio/bqaudioio/AudioFactory.h \
+	bqaudioio/bqaudioio/ResamplerWrapper.h \
 	bqaudioio/bqaudioio/SystemAudioIO.h \
 	bqaudioio/bqaudioio/SystemPlaybackTarget.h \
 	bqaudioio/bqaudioio/SystemRecordSource.h \
 	bqaudioio/src/DynamicJACK.h \
 	bqaudioio/src/JACKAudioIO.h \
-	bqaudioio/src/JACKPlaybackTarget.h \
-	bqaudioio/src/JACKRecordSource.h \
 	bqaudioio/src/PortAudioIO.h \
-	bqaudioio/src/PortAudioPlaybackTarget.h \
-	bqaudioio/src/PortAudioRecordSource.h \
-	bqaudioio/src/PulseAudioIO.h \
-	bqaudioio/src/PulseAudioPlaybackTarget.h
+	bqaudioio/src/PulseAudioIO.h
 
 BQ_SOURCES += \
 	bqvec/src/Allocators.cpp \
@@ -36,13 +32,9 @@
 	bqresample/src/Resampler.cpp \
 	bqaudioio/src/AudioFactory.cpp \
 	bqaudioio/src/JACKAudioIO.cpp \
-	bqaudioio/src/JACKPlaybackTarget.cpp \
-	bqaudioio/src/JACKRecordSource.cpp \
 	bqaudioio/src/PortAudioIO.cpp \
-	bqaudioio/src/PortAudioPlaybackTarget.cpp \
-	bqaudioio/src/PortAudioRecordSource.cpp \
 	bqaudioio/src/PulseAudioIO.cpp \
-	bqaudioio/src/PulseAudioPlaybackTarget.cpp \
+	bqaudioio/src/ResamplerWrapper.cpp \
 	bqaudioio/src/SystemPlaybackTarget.cpp \
 	bqaudioio/src/SystemRecordSource.cpp
 
--- a/main/MainWindow.cpp	Mon Dec 05 16:39:03 2016 +0000
+++ b/main/MainWindow.cpp	Fri Dec 09 18:01:55 2016 +0000
@@ -2404,9 +2404,11 @@
 
     QString description;
 
+//!!!???
+    
     sv_samplerate_t ssr = getMainModel()->getSampleRate();
     sv_samplerate_t tsr = ssr;
-    if (m_playSource) tsr = m_playSource->getTargetSampleRate();
+    if (m_playSource) tsr = m_playSource->getDeviceSampleRate();
 
     if (ssr != tsr) {
 	description = tr("%1Hz (resampling to %2Hz)").arg(ssr).arg(tsr);
--- a/main/PreferencesDialog.cpp	Mon Dec 05 16:39:03 2016 +0000
+++ b/main/PreferencesDialog.cpp	Fri Dec 09 18:01:55 2016 +0000
@@ -42,13 +42,17 @@
 #include "base/ResourceFinder.h"
 #include "layer/ColourMapper.h"
 
-//#include "audioio/AudioTargetFactory.h"
+#include "bqaudioio/AudioFactory.h"
 
 #include "version.h"
 
+using namespace std;
+
 PreferencesDialog::PreferencesDialog(QWidget *parent) :
     QDialog(parent),
-    m_audioDevice(0),
+    m_audioImplementation(0),
+    m_audioPlaybackDevice(0),
+    m_audioRecordDevice(0),
     m_changesOnRestart(false)
 {
     setWindowTitle(tr("Sonic Visualiser: Application Preferences"));
@@ -184,24 +188,38 @@
     connect(octaveSystem, SIGNAL(currentIndexChanged(int)),
             this, SLOT(octaveSystemChanged(int)));
 
-    /*!!! restore
-    QComboBox *audioDevice = new QComboBox;
-    std::vector<QString> devices =
-        AudioTargetFactory::getInstance()->getCallbackTargetNames();
-    
     settings.beginGroup("Preferences");
-    QString targetName = settings.value("audio-target", "").toString();
+
+    QComboBox *audioImplementation = new QComboBox;
+    connect(audioImplementation, SIGNAL(currentIndexChanged(int)),
+            this, SLOT(audioImplementationChanged(int)));
+
+    m_audioPlaybackDeviceCombo = new QComboBox;
+    connect(m_audioPlaybackDeviceCombo, SIGNAL(currentIndexChanged(int)),
+            this, SLOT(audioPlaybackDeviceChanged(int)));
+
+    m_audioRecordDeviceCombo = new QComboBox;
+    connect(m_audioRecordDeviceCombo, SIGNAL(currentIndexChanged(int)),
+            this, SLOT(audioRecordDeviceChanged(int)));
+
+    vector<string> names = breakfastquay::AudioFactory::getImplementationNames();
+    QString implementationName = settings.value("audio-target", "").toString();
+    if (implementationName == "auto") implementationName = "";
+    audioImplementation->addItem(tr("(auto)"));
+    m_audioImplementation = 0;
+    for (int i = 0; in_range_for(names, i); ++i) {
+        audioImplementation->addItem
+            (breakfastquay::AudioFactory::getImplementationDescription(names[i]).
+             c_str());
+        if (implementationName.toStdString() == names[i]) {
+            audioImplementation->setCurrentIndex(i+1);
+            m_audioImplementation = i+1;
+        }
+    }
     settings.endGroup();
 
-    for (int i = 0; i < (int)devices.size(); ++i) {
-        audioDevice->addItem(AudioTargetFactory::getInstance()
-                             ->getCallbackTargetDescription(devices[i]));
-        if (targetName == devices[i]) audioDevice->setCurrentIndex(i);
-    }
-
-    connect(audioDevice, SIGNAL(currentIndexChanged(int)),
-            this, SLOT(audioDeviceChanged(int)));
-    */
+    rebuildDeviceCombos();
+    m_changesOnRestart = false; // the rebuild will have changed this
 
     QCheckBox *resampleOnLoad = new QCheckBox;
     m_resampleOnLoad = prefs->getResampleOnLoad();
@@ -369,8 +387,14 @@
                        row, 0);
     subgrid->addWidget(gaplessMode, row++, 1, 1, 1);
 
-//!!!    subgrid->addWidget(new QLabel(tr("Playback audio device:")), row, 0);
-//!!!    subgrid->addWidget(audioDevice, row++, 1, 1, 2);
+    subgrid->addWidget(new QLabel(tr("Audio service:")), row, 0);
+    subgrid->addWidget(audioImplementation, row++, 1, 1, 2);
+
+    subgrid->addWidget(new QLabel(tr("Audio playback device:")), row, 0);
+    subgrid->addWidget(m_audioPlaybackDeviceCombo, row++, 1, 1, 2);
+
+    subgrid->addWidget(new QLabel(tr("Audio record device:")), row, 0);
+    subgrid->addWidget(m_audioRecordDeviceCombo, row++, 1, 1, 2);
 
     subgrid->setRowStretch(row, 10);
     
@@ -510,7 +534,7 @@
 
     QStringList templates = ResourceFinder().getResourceFiles("templates", "svt");
 
-    std::set<QString> byName;
+    set<QString> byName;
     foreach (QString t, templates) {
         byName.insert(QFileInfo(t).baseName());
     }
@@ -550,6 +574,57 @@
 }
 
 void
+PreferencesDialog::rebuildDeviceCombos()
+{
+    QSettings settings;
+    settings.beginGroup("Preferences");
+
+    vector<string> names = breakfastquay::AudioFactory::getImplementationNames();
+    string implementationName;
+    if (in_range_for(names, m_audioImplementation-1)) {
+        implementationName = names[m_audioImplementation-1];
+    }
+
+    m_audioPlaybackDeviceCombo->clear();
+    m_audioRecordDeviceCombo->clear();
+
+    QString suffix;
+    if (implementationName != "") {
+        suffix = "-" + QString(implementationName.c_str());
+    }
+    
+    names = breakfastquay::AudioFactory::getPlaybackDeviceNames(implementationName);
+    QString playbackDeviceName = settings.value
+        ("audio-playback-device" + suffix, "").toString();
+    m_audioPlaybackDeviceCombo->addItem(tr("(auto)"));
+    m_audioPlaybackDeviceCombo->setCurrentIndex(0);
+    m_audioPlaybackDevice = 0;
+    for (int i = 0; in_range_for(names, i); ++i) {
+        m_audioPlaybackDeviceCombo->addItem(names[i].c_str());
+        if (playbackDeviceName.toStdString() == names[i]) {
+            m_audioPlaybackDeviceCombo->setCurrentIndex(i+1);
+            m_audioPlaybackDevice = i+1;
+        }
+    }
+    
+    names = breakfastquay::AudioFactory::getRecordDeviceNames(implementationName);
+    QString recordDeviceName = settings.value
+        ("audio-record-device" + suffix, "").toString();
+    m_audioRecordDeviceCombo->addItem(tr("(auto)"));
+    m_audioRecordDeviceCombo->setCurrentIndex(0);
+    m_audioRecordDevice = 0;
+    for (int i = 0; in_range_for(names, i); ++i) {
+        m_audioRecordDeviceCombo->addItem(names[i].c_str());
+        if (recordDeviceName.toStdString() == names[i]) {
+            m_audioRecordDeviceCombo->setCurrentIndex(i+1);
+            m_audioRecordDevice = i+1;
+        }
+    }
+
+    settings.endGroup();
+}
+
+void
 PreferencesDialog::switchToTab(Tab t)
 {
     if (m_tabOrdering.contains(t)) {
@@ -614,11 +689,34 @@
 }
 
 void
-PreferencesDialog::audioDeviceChanged(int s)
+PreferencesDialog::audioImplementationChanged(int s)
 {
-    m_audioDevice = s;
-    m_applyButton->setEnabled(true);
-    m_changesOnRestart = true;
+    if (m_audioImplementation != s) {
+        m_audioImplementation = s;
+        rebuildDeviceCombos();
+        m_applyButton->setEnabled(true);
+        m_changesOnRestart = true;
+    }
+}
+
+void
+PreferencesDialog::audioPlaybackDeviceChanged(int s)
+{
+    if (m_audioPlaybackDevice != s) {
+        m_audioPlaybackDevice = s;
+        m_applyButton->setEnabled(true);
+        m_changesOnRestart = true;
+    }
+}
+
+void
+PreferencesDialog::audioRecordDeviceChanged(int s)
+{
+    if (m_audioRecordDevice != s) {
+        m_audioRecordDevice = s;
+        m_applyButton->setEnabled(true);
+        m_changesOnRestart = true;
+    }
 }
 
 void
@@ -769,14 +867,37 @@
     
     prefs->setProperty("Octave Numbering System", m_octaveSystem);
 
-//!!!    std::vector<QString> devices =
-//!!!        AudioTargetFactory::getInstance()->getCallbackTargetNames();
-
     QSettings settings;
     settings.beginGroup("Preferences");
     QString permishTag = QString("network-permission-%1").arg(SV_VERSION);
     settings.setValue(permishTag, m_networkPermission);
-//!!!    settings.setValue("audio-target", devices[m_audioDevice]);
+
+    vector<string> names = breakfastquay::AudioFactory::getImplementationNames();
+    string implementationName;
+    if (m_audioImplementation > 0) {
+        implementationName = names[m_audioImplementation-1];
+    }
+    settings.setValue("audio-target", implementationName.c_str());
+
+    QString suffix;
+    if (implementationName != "") {
+        suffix = "-" + QString(implementationName.c_str());
+    }
+    
+    names = breakfastquay::AudioFactory::getPlaybackDeviceNames(implementationName);
+    string deviceName;
+    if (m_audioPlaybackDevice > 0) {
+        deviceName = names[m_audioPlaybackDevice-1];
+    }
+    settings.setValue("audio-playback-device" + suffix, deviceName.c_str());
+
+    names = breakfastquay::AudioFactory::getRecordDeviceNames(implementationName);
+    deviceName = "";
+    if (m_audioRecordDevice > 0) {
+        deviceName = names[m_audioRecordDevice-1];
+    }
+    settings.setValue("audio-record-device" + suffix, deviceName.c_str());
+    
     settings.setValue("locale", m_currentLocale);
 #ifdef Q_OS_MAC
     settings.setValue("scaledHiDpi", m_retina);
--- a/main/PreferencesDialog.h	Mon Dec 05 16:39:03 2016 +0000
+++ b/main/PreferencesDialog.h	Fri Dec 09 18:01:55 2016 +0000
@@ -25,6 +25,7 @@
 class QPushButton;
 class QLineEdit;
 class QTabWidget;
+class QComboBox;
 
 class PreferencesDialog : public QDialog
 {
@@ -54,7 +55,9 @@
     void colour3DColourChanged(int state);
     void propertyLayoutChanged(int layout);
     void tuningFrequencyChanged(double freq);
-    void audioDeviceChanged(int device);
+    void audioImplementationChanged(int impl);
+    void audioPlaybackDeviceChanged(int device);
+    void audioRecordDeviceChanged(int device);
     void resampleOnLoadChanged(int state);
     void gaplessModeChanged(int state);
     void vampProcessSeparationChanged(int state);
@@ -85,6 +88,10 @@
 
     QLineEdit *m_tempDirRootEdit;
 
+    QComboBox *m_audioPlaybackDeviceCombo;
+    QComboBox *m_audioRecordDeviceCombo;
+    void rebuildDeviceCombos();
+    
     QString m_currentTemplate;
     QStringList m_templates;
 
@@ -99,7 +106,9 @@
     int m_colour3DColour;
     int m_propertyLayout;
     double m_tuningFrequency;
-    int m_audioDevice;
+    int m_audioImplementation;
+    int m_audioPlaybackDevice;
+    int m_audioRecordDevice;
     bool m_resampleOnLoad;
     bool m_gapless;
     bool m_runPluginsInProcess;