annotate plugin/LADSPAPluginInstance.h @ 51:c2913298cf94

* Make RealTimePluginInstances also provide the PluginInstance interface
author Chris Cannam
date Mon, 20 Mar 2006 13:48:58 +0000
parents 39ae3dee27b9
children d397ea0a79f5
rev   line source
Chris@49 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@0 2
Chris@0 3 /*
Chris@0 4 A waveform viewer and audio annotation editor.
Chris@2 5 Chris Cannam, Queen Mary University of London, 2005-2006
Chris@0 6
Chris@0 7 This is experimental software. Not for distribution.
Chris@0 8 */
Chris@0 9
Chris@0 10 /*
Chris@0 11 This is a modified version of a source file from the
Chris@0 12 Rosegarden MIDI and audio sequencer and notation editor.
Chris@17 13 This file copyright 2000-2006 Chris Cannam and Richard Bown.
Chris@0 14 */
Chris@0 15
Chris@0 16 #ifndef _LADSPAPLUGININSTANCE_H_
Chris@0 17 #define _LADSPAPLUGININSTANCE_H_
Chris@0 18
Chris@0 19 #include <vector>
Chris@0 20 #include <set>
Chris@0 21 #include <QString>
Chris@0 22
Chris@0 23 #include "api/ladspa.h"
Chris@0 24 #include "RealTimePluginInstance.h"
Chris@0 25
Chris@0 26 // LADSPA plugin instance. LADSPA is a variable block size API, but
Chris@0 27 // for one reason and another it's more convenient to use a fixed
Chris@0 28 // block size in this wrapper.
Chris@0 29 //
Chris@0 30 class LADSPAPluginInstance : public RealTimePluginInstance
Chris@0 31 {
Chris@0 32 public:
Chris@0 33 virtual ~LADSPAPluginInstance();
Chris@0 34
Chris@0 35 virtual bool isOK() const { return m_instanceHandles.size() != 0; }
Chris@0 36
Chris@0 37 int getClientId() const { return m_client; }
Chris@0 38 virtual QString getIdentifier() const { return m_identifier; }
Chris@0 39 int getPosition() const { return m_position; }
Chris@0 40
Chris@51 41 virtual std::string getName() const;
Chris@51 42 virtual std::string getDescription() const;
Chris@51 43 virtual std::string getMaker() const;
Chris@51 44 virtual int getPluginVersion() const;
Chris@51 45 virtual std::string getCopyright() const;
Chris@51 46
Chris@0 47 virtual void run(const RealTime &rt);
Chris@0 48
Chris@0 49 virtual unsigned int getParameterCount() const;
Chris@0 50 virtual void setParameterValue(unsigned int parameter, float value);
Chris@0 51 virtual float getParameterValue(unsigned int parameter) const;
Chris@0 52 virtual float getParameterDefault(unsigned int parameter) const;
Chris@51 53
Chris@51 54 virtual ParameterList getParameterDescriptors() const;
Chris@51 55 virtual float getParameter(std::string) const;
Chris@51 56 virtual void setParameter(std::string, float);
Chris@0 57
Chris@0 58 virtual size_t getBufferSize() const { return m_blockSize; }
Chris@0 59 virtual size_t getAudioInputCount() const { return m_instanceCount * m_audioPortsIn.size(); }
Chris@0 60 virtual size_t getAudioOutputCount() const { return m_instanceCount * m_audioPortsOut.size(); }
Chris@0 61 virtual sample_t **getAudioInputBuffers() { return m_inputBuffers; }
Chris@0 62 virtual sample_t **getAudioOutputBuffers() { return m_outputBuffers; }
Chris@0 63
Chris@0 64 virtual bool isBypassed() const { return m_bypassed; }
Chris@0 65 virtual void setBypassed(bool bypassed) { m_bypassed = bypassed; }
Chris@0 66
Chris@0 67 virtual size_t getLatency();
Chris@0 68
Chris@0 69 virtual void silence();
Chris@0 70 virtual void setIdealChannelCount(size_t channels); // may re-instantiate
Chris@0 71
Chris@0 72 protected:
Chris@0 73 // To be constructed only by LADSPAPluginFactory
Chris@0 74 friend class LADSPAPluginFactory;
Chris@0 75
Chris@0 76 // Constructor that creates the buffers internally
Chris@0 77 //
Chris@0 78 LADSPAPluginInstance(RealTimePluginFactory *factory,
Chris@0 79 int client,
Chris@0 80 QString identifier,
Chris@0 81 int position,
Chris@0 82 unsigned long sampleRate,
Chris@0 83 size_t blockSize,
Chris@0 84 int idealChannelCount,
Chris@0 85 const LADSPA_Descriptor* descriptor);
Chris@0 86
Chris@0 87 void init(int idealChannelCount = 0);
Chris@0 88 void instantiate(unsigned long sampleRate);
Chris@0 89 void cleanup();
Chris@0 90 void activate();
Chris@0 91 void deactivate();
Chris@0 92
Chris@0 93 // Connection of data (and behind the scenes control) ports
Chris@0 94 //
Chris@0 95 void connectPorts();
Chris@0 96
Chris@0 97 int m_client;
Chris@0 98 int m_position;
Chris@0 99 std::vector<LADSPA_Handle> m_instanceHandles;
Chris@0 100 size_t m_instanceCount;
Chris@0 101 const LADSPA_Descriptor *m_descriptor;
Chris@0 102
Chris@0 103 std::vector<std::pair<unsigned long, LADSPA_Data*> > m_controlPortsIn;
Chris@0 104 std::vector<std::pair<unsigned long, LADSPA_Data*> > m_controlPortsOut;
Chris@0 105
Chris@0 106 std::vector<int> m_audioPortsIn;
Chris@0 107 std::vector<int> m_audioPortsOut;
Chris@0 108
Chris@0 109 size_t m_blockSize;
Chris@0 110 sample_t **m_inputBuffers;
Chris@0 111 sample_t **m_outputBuffers;
Chris@0 112 bool m_ownBuffers;
Chris@0 113 size_t m_sampleRate;
Chris@0 114 float *m_latencyPort;
Chris@0 115 bool m_run;
Chris@0 116
Chris@0 117 bool m_bypassed;
Chris@0 118 };
Chris@0 119
Chris@0 120 #endif // _LADSPAPLUGININSTANCE_H_
Chris@0 121