cannam@92: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ cannam@92: cannam@92: /* cannam@92: Vamp cannam@92: cannam@92: An API for audio analysis and feature extraction plugins. cannam@92: cannam@92: Centre for Digital Music, Queen Mary, University of London. cannam@92: Copyright 2006-2007 Chris Cannam and QMUL. cannam@92: This file by Mark Levy, Copyright 2007 QMUL. cannam@92: cannam@92: Permission is hereby granted, free of charge, to any person cannam@92: obtaining a copy of this software and associated documentation cannam@92: files (the "Software"), to deal in the Software without cannam@92: restriction, including without limitation the rights to use, copy, cannam@92: modify, merge, publish, distribute, sublicense, and/or sell copies cannam@92: of the Software, and to permit persons to whom the Software is cannam@92: furnished to do so, subject to the following conditions: cannam@92: cannam@92: The above copyright notice and this permission notice shall be cannam@92: included in all copies or substantial portions of the Software. cannam@92: cannam@92: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, cannam@92: EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF cannam@92: MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND cannam@92: NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR cannam@92: ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF cannam@92: CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION cannam@92: WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. cannam@92: cannam@92: Except as contained in this notice, the names of the Centre for cannam@92: Digital Music; Queen Mary, University of London; and Chris Cannam cannam@92: shall not be used in advertising or otherwise to promote the sale, cannam@92: use or other dealings in this Software without prior written cannam@92: authorization. cannam@92: */ cannam@92: cannam@92: #ifndef _VAMP_PLUGIN_BUFFERING_ADAPTER_H_ cannam@92: #define _VAMP_PLUGIN_BUFFERING_ADAPTER_H_ cannam@92: cannam@92: #include "PluginWrapper.h" cannam@92: cannam@92: namespace Vamp { cannam@92: cannam@92: namespace HostExt { cannam@92: cannam@92: /** cannam@92: * \class PluginBufferingAdapter PluginBufferingAdapter.h cannam@92: * cannam@92: * PluginBufferingAdapter is a Vamp plugin adapter that allows plugins cannam@92: * to be used by a host supplying an audio stream in non-overlapping cannam@92: * buffers of arbitrary size. cannam@92: * cannam@92: * A host using PluginBufferingAdapter may ignore the preferred step cannam@92: * and block size reported by the plugin, and still expect the plugin cannam@92: * to run. The value of blockSize and stepSize passed to initialise cannam@92: * should be the size of the buffer which the host will supply; the cannam@92: * stepSize should be equal to the blockSize. cannam@92: * cannam@92: * If the internal step size used for the plugin differs from that cannam@92: * supplied by the host, the adapter will modify the sample rate cannam@92: * specifications for the plugin outputs (setting them all to cannam@92: * VariableSampleRate) and set timestamps on the output features for cannam@92: * outputs that formerly used a different sample rate specification. cannam@92: * This is necessary in order to obtain correct time stamping. cannam@92: * cannam@92: * In other respects, the PluginBufferingAdapter behaves identically cannam@92: * to the plugin that it wraps. The wrapped plugin will be deleted cannam@92: * when the wrapper is deleted. cannam@92: */ cannam@92: cannam@92: class PluginBufferingAdapter : public PluginWrapper cannam@92: { cannam@92: public: cannam@92: PluginBufferingAdapter(Plugin *plugin); // I take ownership of plugin cannam@92: virtual ~PluginBufferingAdapter(); cannam@92: cannam@92: bool initialise(size_t channels, size_t stepSize, size_t blockSize); cannam@92: cannam@92: size_t getPreferredStepSize() const; cannam@92: cannam@92: OutputList getOutputDescriptors() const; cannam@92: cannam@104: void reset(); cannam@104: cannam@92: FeatureSet process(const float *const *inputBuffers, RealTime timestamp); cannam@92: cannam@92: FeatureSet getRemainingFeatures(); cannam@92: cannam@92: protected: cannam@92: class Impl; cannam@92: Impl *m_impl; cannam@92: }; cannam@92: cannam@92: } cannam@92: cannam@92: } cannam@92: cannam@92: #endif