Chris@49: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@0: Chris@0: /* Chris@52: Sonic Visualiser Chris@52: An audio file viewer and annotation editor. Chris@52: Centre for Digital Music, Queen Mary, University of London. Chris@0: Chris@52: This program is free software; you can redistribute it and/or Chris@52: modify it under the terms of the GNU General Public License as Chris@52: published by the Free Software Foundation; either version 2 of the Chris@52: License, or (at your option) any later version. See the file Chris@52: COPYING included with this distribution for more information. Chris@0: */ Chris@0: Chris@0: /* Chris@0: This is a modified version of a source file from the Chris@0: Rosegarden MIDI and audio sequencer and notation editor. Chris@17: This file copyright 2000-2006 Chris Cannam and Richard Bown. Chris@0: */ Chris@0: Chris@0: #ifndef _LADSPAPLUGININSTANCE_H_ Chris@0: #define _LADSPAPLUGININSTANCE_H_ Chris@0: Chris@0: #include Chris@0: #include Chris@0: #include Chris@0: Chris@0: #include "api/ladspa.h" Chris@0: #include "RealTimePluginInstance.h" Chris@0: Chris@0: // LADSPA plugin instance. LADSPA is a variable block size API, but Chris@0: // for one reason and another it's more convenient to use a fixed Chris@0: // block size in this wrapper. Chris@0: // Chris@0: class LADSPAPluginInstance : public RealTimePluginInstance Chris@0: { Chris@0: public: Chris@0: virtual ~LADSPAPluginInstance(); Chris@0: Chris@0: virtual bool isOK() const { return m_instanceHandles.size() != 0; } Chris@0: Chris@0: int getClientId() const { return m_client; } Chris@237: virtual QString getPluginIdentifier() const { return m_identifier; } Chris@0: int getPosition() const { return m_position; } Chris@0: Chris@239: virtual std::string getIdentifier() const; Chris@51: virtual std::string getName() const; Chris@51: virtual std::string getDescription() const; Chris@51: virtual std::string getMaker() const; Chris@51: virtual int getPluginVersion() const; Chris@51: virtual std::string getCopyright() const; Chris@51: Chris@66: virtual void run(const Vamp::RealTime &rt); Chris@0: Chris@0: virtual unsigned int getParameterCount() const; Chris@0: virtual void setParameterValue(unsigned int parameter, float value); Chris@0: virtual float getParameterValue(unsigned int parameter) const; Chris@0: virtual float getParameterDefault(unsigned int parameter) const; Chris@383: virtual int getParameterDisplayHint(unsigned int parameter) const; Chris@51: Chris@51: virtual ParameterList getParameterDescriptors() const; Chris@51: virtual float getParameter(std::string) const; Chris@51: virtual void setParameter(std::string, float); Chris@0: Chris@0: virtual size_t getBufferSize() const { return m_blockSize; } Chris@0: virtual size_t getAudioInputCount() const { return m_instanceCount * m_audioPortsIn.size(); } Chris@0: virtual size_t getAudioOutputCount() const { return m_instanceCount * m_audioPortsOut.size(); } Chris@0: virtual sample_t **getAudioInputBuffers() { return m_inputBuffers; } Chris@0: virtual sample_t **getAudioOutputBuffers() { return m_outputBuffers; } Chris@0: Chris@60: virtual size_t getControlOutputCount() const { return m_controlPortsOut.size(); } Chris@60: virtual float getControlOutputValue(size_t n) const; Chris@60: Chris@0: virtual bool isBypassed() const { return m_bypassed; } Chris@0: virtual void setBypassed(bool bypassed) { m_bypassed = bypassed; } Chris@0: Chris@0: virtual size_t getLatency(); Chris@0: Chris@0: virtual void silence(); Chris@0: virtual void setIdealChannelCount(size_t channels); // may re-instantiate Chris@0: Chris@57: virtual std::string getType() const { return "LADSPA Real-Time Plugin"; } Chris@57: Chris@0: protected: Chris@0: // To be constructed only by LADSPAPluginFactory Chris@0: friend class LADSPAPluginFactory; Chris@0: Chris@0: // Constructor that creates the buffers internally Chris@0: // Chris@0: LADSPAPluginInstance(RealTimePluginFactory *factory, Chris@0: int client, Chris@0: QString identifier, Chris@0: int position, Chris@0: unsigned long sampleRate, Chris@0: size_t blockSize, Chris@0: int idealChannelCount, Chris@0: const LADSPA_Descriptor* descriptor); Chris@0: Chris@0: void init(int idealChannelCount = 0); Chris@0: void instantiate(unsigned long sampleRate); Chris@0: void cleanup(); Chris@0: void activate(); Chris@0: void deactivate(); Chris@0: Chris@0: // Connection of data (and behind the scenes control) ports Chris@0: // Chris@0: void connectPorts(); Chris@0: Chris@0: int m_client; Chris@0: int m_position; Chris@0: std::vector m_instanceHandles; Chris@0: size_t m_instanceCount; Chris@0: const LADSPA_Descriptor *m_descriptor; Chris@0: Chris@0: std::vector > m_controlPortsIn; Chris@0: std::vector > m_controlPortsOut; Chris@0: Chris@0: std::vector m_audioPortsIn; Chris@0: std::vector m_audioPortsOut; Chris@0: Chris@0: size_t m_blockSize; Chris@0: sample_t **m_inputBuffers; Chris@0: sample_t **m_outputBuffers; Chris@0: bool m_ownBuffers; Chris@0: size_t m_sampleRate; Chris@0: float *m_latencyPort; Chris@0: bool m_run; Chris@0: Chris@0: bool m_bypassed; Chris@0: }; Chris@0: Chris@0: #endif // _LADSPAPLUGININSTANCE_H_ Chris@0: