changeset 197:fe30a25ee4f8

* Add processInterleaved to PluginChannelAdapter
author cannam
date Tue, 07 Oct 2008 21:07:04 +0000
parents 5c202da82a46
children e3e61b7e9661
files vamp-sdk/PluginHostAdapter.cpp vamp-sdk/hostext/PluginChannelAdapter.cpp vamp-sdk/hostext/PluginChannelAdapter.h vamp-sdk/hostext/PluginSummarisingAdapter.h
diffstat 4 files changed, 60 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/vamp-sdk/PluginHostAdapter.cpp	Tue Oct 07 20:07:17 2008 +0000
+++ b/vamp-sdk/PluginHostAdapter.cpp	Tue Oct 07 21:07:04 2008 +0000
@@ -127,7 +127,11 @@
 void
 PluginHostAdapter::reset()
 {
-    if (!m_handle) return;
+    if (!m_handle) {
+//        std::cerr << "PluginHostAdapter::reset: no handle" << std::endl;
+        return;
+    }
+//    std::cerr << "PluginHostAdapter::reset(" << m_handle << ")" << std::endl;
     m_descriptor->reset(m_handle);
 }
 
--- a/vamp-sdk/hostext/PluginChannelAdapter.cpp	Tue Oct 07 20:07:17 2008 +0000
+++ b/vamp-sdk/hostext/PluginChannelAdapter.cpp	Tue Oct 07 21:07:04 2008 +0000
@@ -49,6 +49,7 @@
     bool initialise(size_t channels, size_t stepSize, size_t blockSize);
 
     FeatureSet process(const float *const *inputBuffers, RealTime timestamp);
+    FeatureSet processInterleaved(const float *inputBuffers, RealTime timestamp);
 
 protected:
     Plugin *m_plugin;
@@ -56,6 +57,7 @@
     size_t m_inputChannels;
     size_t m_pluginChannels;
     float **m_buffer;
+    float **m_deinterleave;
     const float **m_forwardPtrs;
 };
 
@@ -83,12 +85,20 @@
     return m_impl->process(inputBuffers, timestamp);
 }
 
+PluginChannelAdapter::FeatureSet
+PluginChannelAdapter::processInterleaved(const float *inputBuffers,
+                                         RealTime timestamp)
+{
+    return m_impl->processInterleaved(inputBuffers, timestamp);
+}
+
 PluginChannelAdapter::Impl::Impl(Plugin *plugin) :
     m_plugin(plugin),
     m_blockSize(0),
     m_inputChannels(0),
     m_pluginChannels(0),
     m_buffer(0),
+    m_deinterleave(0),
     m_forwardPtrs(0)
 {
 }
@@ -109,6 +119,14 @@
         m_buffer = 0;
     }
 
+    if (m_deinterleave) {
+        for (size_t i = 0; i < m_inputChannels; ++i) {
+            delete[] m_deinterleave[i];
+        }
+        delete[] m_deinterleave;
+        m_deinterleave = 0;
+    }
+
     if (m_forwardPtrs) {
         delete[] m_forwardPtrs;
         m_forwardPtrs = 0;
@@ -174,6 +192,26 @@
 }
 
 PluginChannelAdapter::FeatureSet
+PluginChannelAdapter::Impl::processInterleaved(const float *inputBuffers,
+                                               RealTime timestamp)
+{
+    if (!m_deinterleave) {
+        m_deinterleave = new float *[m_inputChannels];
+        for (size_t i = 0; i < m_inputChannels; ++i) {
+            m_deinterleave[i] = new float[m_blockSize];
+        }
+    }
+
+    for (size_t i = 0; i < m_inputChannels; ++i) {
+        for (size_t j = 0; j < m_blockSize; ++j) {
+            m_deinterleave[i][j] = inputBuffers[j * m_inputChannels + i];
+        }
+    }
+
+    return process(m_deinterleave, timestamp);
+}
+
+PluginChannelAdapter::FeatureSet
 PluginChannelAdapter::Impl::process(const float *const *inputBuffers,
                                     RealTime timestamp)
 {
--- a/vamp-sdk/hostext/PluginChannelAdapter.h	Tue Oct 07 20:07:17 2008 +0000
+++ b/vamp-sdk/hostext/PluginChannelAdapter.h	Tue Oct 07 21:07:04 2008 +0000
@@ -116,6 +116,17 @@
 
     FeatureSet process(const float *const *inputBuffers, RealTime timestamp);
 
+    /**
+     * Call process(), providing interleaved audio data with the
+     * number of channels passed to initialise().  The adapter will
+     * de-interleave into temporary buffers as appropriate before
+     * calling process().
+     *
+     * \note This function was introduced in version 1.4 of the Vamp
+     * plugin SDK.
+     */
+    FeatureSet processInterleaved(const float *inputBuffer, RealTime timestamp);
+
 protected:
     class Impl;
     Impl *m_impl;
--- a/vamp-sdk/hostext/PluginSummarisingAdapter.h	Tue Oct 07 20:07:17 2008 +0000
+++ b/vamp-sdk/hostext/PluginSummarisingAdapter.h	Tue Oct 07 21:07:04 2008 +0000
@@ -45,6 +45,12 @@
 
 namespace HostExt {
 
+/**
+ * \class PluginSummarisingAdapter PluginSummarisingAdapter.h <vamp-sdk/hostext/PluginSummarisingAdapter.h>
+ *
+ * \note This class was introduced in version 1.1 of the Vamp plugin SDK.
+ */
+
 class PluginSummarisingAdapter : public PluginWrapper
 {
 public: