Mercurial > hg > vamp-plugin-sdk
changeset 70:fd58037b4a7b
* use m_impl for channel and input domain adapters as well
author | cannam |
---|---|
date | Wed, 06 Jun 2007 10:00:36 +0000 |
parents | 3456fe86d385 |
children | 64697dca0d48 |
files | vamp-sdk/hostext/PluginChannelAdapter.cpp vamp-sdk/hostext/PluginChannelAdapter.h vamp-sdk/hostext/PluginInputDomainAdapter.cpp vamp-sdk/hostext/PluginInputDomainAdapter.h |
diffstat | 4 files changed, 150 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- a/vamp-sdk/hostext/PluginChannelAdapter.cpp Wed Jun 06 09:49:50 2007 +0000 +++ b/vamp-sdk/hostext/PluginChannelAdapter.cpp Wed Jun 06 10:00:36 2007 +0000 @@ -40,8 +40,51 @@ namespace HostExt { +class PluginChannelAdapter::Impl +{ +public: + Impl(Plugin *plugin); + ~Impl(); + + bool initialise(size_t channels, size_t stepSize, size_t blockSize); + + FeatureSet process(const float *const *inputBuffers, RealTime timestamp); + +protected: + Plugin *m_plugin; + size_t m_blockSize; + size_t m_inputChannels; + size_t m_pluginChannels; + float **m_buffer; + const float **m_forwardPtrs; +}; + PluginChannelAdapter::PluginChannelAdapter(Plugin *plugin) : - PluginWrapper(plugin), + PluginWrapper(plugin) +{ + m_impl = new Impl(plugin); +} + +PluginChannelAdapter::~PluginChannelAdapter() +{ + delete m_impl; +} + +bool +PluginChannelAdapter::initialise(size_t channels, size_t stepSize, size_t blockSize) +{ + return m_impl->initialise(channels, stepSize, blockSize); +} + +PluginChannelAdapter::FeatureSet +PluginChannelAdapter::process(const float *const *inputBuffers, + RealTime timestamp) +{ + return m_impl->process(inputBuffers, timestamp); +} + +PluginChannelAdapter::Impl::Impl(Plugin *plugin) : + m_plugin(plugin), m_blockSize(0), m_inputChannels(0), m_pluginChannels(0), @@ -50,8 +93,10 @@ { } -PluginChannelAdapter::~PluginChannelAdapter() +PluginChannelAdapter::Impl::~Impl() { + // the adapter will delete the plugin + if (m_buffer) { if (m_inputChannels > m_pluginChannels) { delete[] m_buffer[0]; @@ -71,7 +116,7 @@ } bool -PluginChannelAdapter::initialise(size_t channels, size_t stepSize, size_t blockSize) +PluginChannelAdapter::Impl::initialise(size_t channels, size_t stepSize, size_t blockSize) { m_blockSize = blockSize; @@ -129,8 +174,8 @@ } PluginChannelAdapter::FeatureSet -PluginChannelAdapter::process(const float *const *inputBuffers, - RealTime timestamp) +PluginChannelAdapter::Impl::process(const float *const *inputBuffers, + RealTime timestamp) { // std::cerr << "PluginChannelAdapter::process: " << m_inputChannels << " -> " << m_pluginChannels << " channels" << std::endl;
--- a/vamp-sdk/hostext/PluginChannelAdapter.h Wed Jun 06 09:49:50 2007 +0000 +++ b/vamp-sdk/hostext/PluginChannelAdapter.h Wed Jun 06 10:00:36 2007 +0000 @@ -113,11 +113,8 @@ FeatureSet process(const float *const *inputBuffers, RealTime timestamp); protected: - size_t m_blockSize; - size_t m_inputChannels; - size_t m_pluginChannels; - float **m_buffer; - const float **m_forwardPtrs; + class Impl; + Impl *m_impl; }; }
--- a/vamp-sdk/hostext/PluginInputDomainAdapter.cpp Wed Jun 06 09:49:50 2007 +0000 +++ b/vamp-sdk/hostext/PluginInputDomainAdapter.cpp Wed Jun 06 10:00:36 2007 +0000 @@ -42,20 +42,102 @@ namespace HostExt { +class PluginInputDomainAdapter::Impl +{ +public: + Impl(Plugin *plugin, float inputSampleRate); + ~Impl(); + + bool initialise(size_t channels, size_t stepSize, size_t blockSize); + + size_t getPreferredStepSize() const; + size_t getPreferredBlockSize() const; + + FeatureSet process(const float *const *inputBuffers, RealTime timestamp); + +protected: + Plugin *m_plugin; + float m_inputSampleRate; + size_t m_channels; + size_t m_blockSize; + float **m_freqbuf; + double *m_ri; + double *m_ro; + double *m_io; + + void fft(unsigned int n, bool inverse, + double *ri, double *ii, double *ro, double *io); + + size_t makeBlockSizeAcceptable(size_t) const; +}; + PluginInputDomainAdapter::PluginInputDomainAdapter(Plugin *plugin) : - PluginWrapper(plugin), + PluginWrapper(plugin) +{ + m_impl = new Impl(plugin, m_inputSampleRate); +} + +PluginInputDomainAdapter::~PluginInputDomainAdapter() +{ + delete m_impl; +} + +bool +PluginInputDomainAdapter::initialise(size_t channels, size_t stepSize, size_t blockSize) +{ + return m_impl->initialise(channels, stepSize, blockSize); +} + +Plugin::InputDomain +PluginInputDomainAdapter::getInputDomain() const +{ + return TimeDomain; +} + +size_t +PluginInputDomainAdapter::getPreferredStepSize() const +{ + return m_impl->getPreferredStepSize(); +} + +size_t +PluginInputDomainAdapter::getPreferredBlockSize() const +{ + return m_impl->getPreferredBlockSize(); +} + +Plugin::FeatureSet +PluginInputDomainAdapter::process(const float *const *inputBuffers, RealTime timestamp) +{ + return m_impl->process(inputBuffers, timestamp); +} + + PluginInputDomainAdapter::Impl::Impl(Plugin *plugin, float inputSampleRate) : + m_plugin(plugin), + m_inputSampleRate(inputSampleRate), m_channels(0), m_blockSize(0), m_freqbuf(0) { } -PluginInputDomainAdapter::~PluginInputDomainAdapter() +PluginInputDomainAdapter::Impl::~Impl() { + // the adapter will delete the plugin + + if (m_channels > 0) { + for (size_t c = 0; c < m_channels; ++c) { + delete[] m_freqbuf[c]; + } + delete[] m_freqbuf; + delete[] m_ri; + delete[] m_ro; + delete[] m_io; + } } bool -PluginInputDomainAdapter::initialise(size_t channels, size_t stepSize, size_t blockSize) +PluginInputDomainAdapter::Impl::initialise(size_t channels, size_t stepSize, size_t blockSize) { if (m_plugin->getInputDomain() == TimeDomain) { @@ -66,12 +148,12 @@ } if (blockSize < 2) { - std::cerr << "ERROR: Vamp::HostExt::PluginInputDomainAdapter::initialise: blocksize < 2 not supported" << std::endl; + std::cerr << "ERROR: Vamp::HostExt::PluginInputDomainAdapter::Impl::initialise: blocksize < 2 not supported" << std::endl; return false; } if (blockSize & (blockSize-1)) { - std::cerr << "ERROR: Vamp::HostExt::PluginInputDomainAdapter::initialise: non-power-of-two\nblocksize " << blockSize << " not supported" << std::endl; + std::cerr << "ERROR: Vamp::HostExt::PluginInputDomainAdapter::Impl::initialise: non-power-of-two\nblocksize " << blockSize << " not supported" << std::endl; return false; } @@ -99,14 +181,8 @@ return m_plugin->initialise(channels, stepSize, blockSize); } -Plugin::InputDomain -PluginInputDomainAdapter::getInputDomain() const -{ - return TimeDomain; -} - size_t -PluginInputDomainAdapter::getPreferredStepSize() const +PluginInputDomainAdapter::Impl::getPreferredStepSize() const { size_t step = m_plugin->getPreferredStepSize(); @@ -118,7 +194,7 @@ } size_t -PluginInputDomainAdapter::getPreferredBlockSize() const +PluginInputDomainAdapter::Impl::getPreferredBlockSize() const { size_t block = m_plugin->getPreferredBlockSize(); @@ -134,11 +210,11 @@ } size_t -PluginInputDomainAdapter::makeBlockSizeAcceptable(size_t blockSize) const +PluginInputDomainAdapter::Impl::makeBlockSizeAcceptable(size_t blockSize) const { if (blockSize < 2) { - std::cerr << "WARNING: Vamp::HostExt::PluginInputDomainAdapter::initialise: blocksize < 2 not" << std::endl + std::cerr << "WARNING: Vamp::HostExt::PluginInputDomainAdapter::Impl::initialise: blocksize < 2 not" << std::endl << "supported, increasing from " << blockSize << " to 2" << std::endl; blockSize = 2; @@ -163,7 +239,7 @@ nearest = nearest*2; } - std::cerr << "WARNING: Vamp::HostExt::PluginInputDomainAdapter::initialise: non-power-of-two\nblocksize " << blockSize << " not supported, using blocksize " << nearest << " instead" << std::endl; + std::cerr << "WARNING: Vamp::HostExt::PluginInputDomainAdapter::Impl::initialise: non-power-of-two\nblocksize " << blockSize << " not supported, using blocksize " << nearest << " instead" << std::endl; blockSize = nearest; } @@ -176,7 +252,8 @@ #endif Plugin::FeatureSet -PluginInputDomainAdapter::process(const float *const *inputBuffers, RealTime timestamp) +PluginInputDomainAdapter::Impl::process(const float *const *inputBuffers, + RealTime timestamp) { if (m_plugin->getInputDomain() == TimeDomain) { return m_plugin->process(inputBuffers, timestamp); @@ -259,8 +336,8 @@ } void -PluginInputDomainAdapter::fft(unsigned int n, bool inverse, - double *ri, double *ii, double *ro, double *io) +PluginInputDomainAdapter::Impl::fft(unsigned int n, bool inverse, + double *ri, double *ii, double *ro, double *io) { if (!ri || !ro || !io) return;
--- a/vamp-sdk/hostext/PluginInputDomainAdapter.h Wed Jun 06 09:49:50 2007 +0000 +++ b/vamp-sdk/hostext/PluginInputDomainAdapter.h Wed Jun 06 10:00:36 2007 +0000 @@ -88,17 +88,8 @@ FeatureSet process(const float *const *inputBuffers, RealTime timestamp); protected: - size_t m_channels; - size_t m_blockSize; - float **m_freqbuf; - double *m_ri; - double *m_ro; - double *m_io; - - void fft(unsigned int n, bool inverse, - double *ri, double *ii, double *ro, double *io); - - size_t makeBlockSizeAcceptable(size_t) const; + class Impl; + Impl *m_impl; }; }