annotate plugin/LADSPAPluginInstance.h @ 295:a2dc34ce146a

* Window should be centred on its nominal time. I'm not sure what the reasoning was behind the previous formulations of these two lines.
author Chris Cannam
date Thu, 06 Sep 2007 15:14:47 +0000
parents 71f869dac40b
children ca3b91119482
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@52 4 Sonic Visualiser
Chris@52 5 An audio file viewer and annotation editor.
Chris@52 6 Centre for Digital Music, Queen Mary, University of London.
Chris@0 7
Chris@52 8 This program is free software; you can redistribute it and/or
Chris@52 9 modify it under the terms of the GNU General Public License as
Chris@52 10 published by the Free Software Foundation; either version 2 of the
Chris@52 11 License, or (at your option) any later version. See the file
Chris@52 12 COPYING included with this distribution for more information.
Chris@0 13 */
Chris@0 14
Chris@0 15 /*
Chris@0 16 This is a modified version of a source file from the
Chris@0 17 Rosegarden MIDI and audio sequencer and notation editor.
Chris@17 18 This file copyright 2000-2006 Chris Cannam and Richard Bown.
Chris@0 19 */
Chris@0 20
Chris@0 21 #ifndef _LADSPAPLUGININSTANCE_H_
Chris@0 22 #define _LADSPAPLUGININSTANCE_H_
Chris@0 23
Chris@0 24 #include <vector>
Chris@0 25 #include <set>
Chris@0 26 #include <QString>
Chris@0 27
Chris@0 28 #include "api/ladspa.h"
Chris@0 29 #include "RealTimePluginInstance.h"
Chris@0 30
Chris@0 31 // LADSPA plugin instance. LADSPA is a variable block size API, but
Chris@0 32 // for one reason and another it's more convenient to use a fixed
Chris@0 33 // block size in this wrapper.
Chris@0 34 //
Chris@0 35 class LADSPAPluginInstance : public RealTimePluginInstance
Chris@0 36 {
Chris@0 37 public:
Chris@0 38 virtual ~LADSPAPluginInstance();
Chris@0 39
Chris@0 40 virtual bool isOK() const { return m_instanceHandles.size() != 0; }
Chris@0 41
Chris@0 42 int getClientId() const { return m_client; }
Chris@237 43 virtual QString getPluginIdentifier() const { return m_identifier; }
Chris@0 44 int getPosition() const { return m_position; }
Chris@0 45
Chris@239 46 virtual std::string getIdentifier() const;
Chris@51 47 virtual std::string getName() const;
Chris@51 48 virtual std::string getDescription() const;
Chris@51 49 virtual std::string getMaker() const;
Chris@51 50 virtual int getPluginVersion() const;
Chris@51 51 virtual std::string getCopyright() const;
Chris@51 52
Chris@66 53 virtual void run(const Vamp::RealTime &rt);
Chris@0 54
Chris@0 55 virtual unsigned int getParameterCount() const;
Chris@0 56 virtual void setParameterValue(unsigned int parameter, float value);
Chris@0 57 virtual float getParameterValue(unsigned int parameter) const;
Chris@0 58 virtual float getParameterDefault(unsigned int parameter) const;
Chris@51 59
Chris@51 60 virtual ParameterList getParameterDescriptors() const;
Chris@51 61 virtual float getParameter(std::string) const;
Chris@51 62 virtual void setParameter(std::string, float);
Chris@0 63
Chris@0 64 virtual size_t getBufferSize() const { return m_blockSize; }
Chris@0 65 virtual size_t getAudioInputCount() const { return m_instanceCount * m_audioPortsIn.size(); }
Chris@0 66 virtual size_t getAudioOutputCount() const { return m_instanceCount * m_audioPortsOut.size(); }
Chris@0 67 virtual sample_t **getAudioInputBuffers() { return m_inputBuffers; }
Chris@0 68 virtual sample_t **getAudioOutputBuffers() { return m_outputBuffers; }
Chris@0 69
Chris@60 70 virtual size_t getControlOutputCount() const { return m_controlPortsOut.size(); }
Chris@60 71 virtual float getControlOutputValue(size_t n) const;
Chris@60 72
Chris@0 73 virtual bool isBypassed() const { return m_bypassed; }
Chris@0 74 virtual void setBypassed(bool bypassed) { m_bypassed = bypassed; }
Chris@0 75
Chris@0 76 virtual size_t getLatency();
Chris@0 77
Chris@0 78 virtual void silence();
Chris@0 79 virtual void setIdealChannelCount(size_t channels); // may re-instantiate
Chris@0 80
Chris@57 81 virtual std::string getType() const { return "LADSPA Real-Time Plugin"; }
Chris@57 82
Chris@0 83 protected:
Chris@0 84 // To be constructed only by LADSPAPluginFactory
Chris@0 85 friend class LADSPAPluginFactory;
Chris@0 86
Chris@0 87 // Constructor that creates the buffers internally
Chris@0 88 //
Chris@0 89 LADSPAPluginInstance(RealTimePluginFactory *factory,
Chris@0 90 int client,
Chris@0 91 QString identifier,
Chris@0 92 int position,
Chris@0 93 unsigned long sampleRate,
Chris@0 94 size_t blockSize,
Chris@0 95 int idealChannelCount,
Chris@0 96 const LADSPA_Descriptor* descriptor);
Chris@0 97
Chris@0 98 void init(int idealChannelCount = 0);
Chris@0 99 void instantiate(unsigned long sampleRate);
Chris@0 100 void cleanup();
Chris@0 101 void activate();
Chris@0 102 void deactivate();
Chris@0 103
Chris@0 104 // Connection of data (and behind the scenes control) ports
Chris@0 105 //
Chris@0 106 void connectPorts();
Chris@0 107
Chris@0 108 int m_client;
Chris@0 109 int m_position;
Chris@0 110 std::vector<LADSPA_Handle> m_instanceHandles;
Chris@0 111 size_t m_instanceCount;
Chris@0 112 const LADSPA_Descriptor *m_descriptor;
Chris@0 113
Chris@0 114 std::vector<std::pair<unsigned long, LADSPA_Data*> > m_controlPortsIn;
Chris@0 115 std::vector<std::pair<unsigned long, LADSPA_Data*> > m_controlPortsOut;
Chris@0 116
Chris@0 117 std::vector<int> m_audioPortsIn;
Chris@0 118 std::vector<int> m_audioPortsOut;
Chris@0 119
Chris@0 120 size_t m_blockSize;
Chris@0 121 sample_t **m_inputBuffers;
Chris@0 122 sample_t **m_outputBuffers;
Chris@0 123 bool m_ownBuffers;
Chris@0 124 size_t m_sampleRate;
Chris@0 125 float *m_latencyPort;
Chris@0 126 bool m_run;
Chris@0 127
Chris@0 128 bool m_bypassed;
Chris@0 129 };
Chris@0 130
Chris@0 131 #endif // _LADSPAPLUGININSTANCE_H_
Chris@0 132