changeset 551:b9d8c7a690d6 bqresample

Add a ResamplerWrapper
author Chris Cannam
date Wed, 07 Dec 2016 13:57:45 +0000
parents c732251237b1
children 8c11ca1ebc39
files audio/AudioCallbackPlaySource.cpp audio/AudioCallbackPlaySource.h framework/MainWindowBase.cpp framework/MainWindowBase.h
diffstat 4 files changed, 30 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/audio/AudioCallbackPlaySource.cpp	Wed Dec 07 12:04:41 2016 +0000
+++ b/audio/AudioCallbackPlaySource.cpp	Wed Dec 07 13:57:45 2016 +0000
@@ -28,6 +28,7 @@
 #include "plugin/RealTimePluginInstance.h"
 
 #include "bqaudioio/SystemPlaybackTarget.h"
+#include "bqaudioio/ResamplerWrapper.h"
 
 #include <rubberband/RubberBandStretcher.h>
 using namespace RubberBand;
@@ -77,7 +78,8 @@
     m_stretcherInputCount(0),
     m_stretcherInputs(0),
     m_stretcherInputSizes(0),
-    m_fillThread(0)
+    m_fillThread(0),
+    m_resamplerWrapper(0)
 {
     m_viewManager->setAudioPlaySource(this);
 
@@ -573,6 +575,12 @@
 }
 
 void
+AudioCallbackPlaySource::setResamplerWrapper(breakfastquay::ResamplerWrapper *w)
+{
+    m_resamplerWrapper = w;
+}
+
+void
 AudioCallbackPlaySource::setSystemPlaybackBlockSize(int size)
 {
     cout << "AudioCallbackPlaySource::setTarget: Block size -> " << size << endl;
--- a/audio/AudioCallbackPlaySource.h	Wed Dec 07 12:04:41 2016 +0000
+++ b/audio/AudioCallbackPlaySource.h	Wed Dec 07 13:57:45 2016 +0000
@@ -40,7 +40,7 @@
 }
 
 namespace breakfastquay {
-    class Resampler;
+    class ResamplerWrapper;
 }
 
 class Model;
@@ -125,6 +125,11 @@
     virtual void setSystemPlaybackTarget(breakfastquay::SystemPlaybackTarget *);
 
     /**
+     * Set the resampler wrapper, if one is in use.
+     */
+    virtual void setResamplerWrapper(breakfastquay::ResamplerWrapper *);
+    
+    /**
      * Set the block size of the target audio device.  This should be
      * called by the target class.
      */
@@ -400,6 +405,7 @@
     QMutex m_mutex;
     QWaitCondition m_condition;
     FillThread *m_fillThread;
+    breakfastquay::ResamplerWrapper *m_resamplerWrapper; // I don't own this
 };
 
 #endif
--- a/framework/MainWindowBase.cpp	Wed Dec 07 12:04:41 2016 +0000
+++ b/framework/MainWindowBase.cpp	Wed Dec 07 13:57:45 2016 +0000
@@ -76,6 +76,7 @@
 #include <bqaudioio/SystemPlaybackTarget.h>
 #include <bqaudioio/SystemAudioIO.h>
 #include <bqaudioio/AudioFactory.h>
+#include <bqaudioio/ResamplerWrapper.h>
 
 #include <QApplication>
 #include <QMessageBox>
@@ -141,6 +142,7 @@
     m_soundOptions(options),
     m_playSource(0),
     m_recordTarget(0),
+    m_resamplerWrapper(0),
     m_playTarget(0),
     m_audioIO(0),
     m_oscQueue(0),
@@ -303,6 +305,7 @@
     delete m_playTarget;
 
     // Then delete the Application objects.
+    delete m_resamplerWrapper;
     delete m_playSource;
     delete m_recordTarget;
     
@@ -2328,16 +2331,21 @@
     SVCERR << "createAudioIO: Preferred record device = \""
             << preference.recordDevice << "\"" << endl;
 
+    if (!m_resamplerWrapper) {
+        m_resamplerWrapper = new breakfastquay::ResamplerWrapper(m_playSource);
+        m_playSource->setResamplerWrapper(m_resamplerWrapper);
+    }
+    
     if (m_soundOptions & WithAudioInput) {
         m_audioIO = breakfastquay::AudioFactory::
-            createCallbackIO(m_recordTarget, m_playSource, preference);
+            createCallbackIO(m_recordTarget, m_resamplerWrapper, preference);
         if (m_audioIO) {
             m_audioIO->suspend(); // start in suspended state
             m_playSource->setSystemPlaybackTarget(m_audioIO);
         }
     } else {
         m_playTarget = breakfastquay::AudioFactory::
-            createCallbackPlayTarget(m_playSource, preference);
+            createCallbackPlayTarget(m_resamplerWrapper, preference);
         if (m_playTarget) {
             m_playTarget->suspend(); // start in suspended state
             m_playSource->setSystemPlaybackTarget(m_playTarget);
--- a/framework/MainWindowBase.h	Wed Dec 07 12:04:41 2016 +0000
+++ b/framework/MainWindowBase.h	Wed Dec 07 13:57:45 2016 +0000
@@ -65,8 +65,9 @@
 class AlignmentModel;
 
 namespace breakfastquay {
-class SystemPlaybackTarget;
-class SystemAudioIO;
+    class SystemPlaybackTarget;
+    class SystemAudioIO;
+    class ResamplerWrapper;
 }
 
 /**
@@ -343,6 +344,7 @@
 
     AudioCallbackPlaySource *m_playSource;
     AudioRecordTarget       *m_recordTarget;
+    breakfastquay::ResamplerWrapper *m_resamplerWrapper;
     breakfastquay::SystemPlaybackTarget *m_playTarget; // only one of this...
     breakfastquay::SystemAudioIO *m_audioIO;           // ... and this exists