LADSPAPluginInstance.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2 of the
11  License, or (at your option) any later version. See the file
12  COPYING included with this distribution for more information.
13 */
14 
15 /*
16  This is a modified version of a source file from the
17  Rosegarden MIDI and audio sequencer and notation editor.
18  This file copyright 2000-2006 Chris Cannam and Richard Bown.
19 */
20 
21 #ifndef SV_LADSPAPLUGININSTANCE_H
22 #define SV_LADSPAPLUGININSTANCE_H
23 
24 #include <vector>
25 #include <set>
26 #include <QString>
27 
28 #include "api/ladspa.h"
29 #include "RealTimePluginInstance.h"
30 #include "base/BaseTypes.h"
31 
32 // LADSPA plugin instance. LADSPA is a variable block size API, but
33 // for one reason and another it's more convenient to use a fixed
34 // block size in this wrapper.
35 //
37 {
38 public:
39  virtual ~LADSPAPluginInstance();
40 
41  bool isOK() const override { return m_instanceHandles.size() != 0; }
42 
43  int getClientId() const { return m_client; }
44  QString getPluginIdentifier() const override { return m_identifier; }
45  int getPosition() const { return m_position; }
46 
47  std::string getIdentifier() const override;
48  std::string getName() const override;
49  std::string getDescription() const override;
50  std::string getMaker() const override;
51  int getPluginVersion() const override;
52  std::string getCopyright() const override;
53 
54  void run(const RealTime &rt, int count = 0) override;
55 
56  int getParameterCount() const override;
57  void setParameterValue(int parameter, float value) override;
58  float getParameterValue(int parameter) const override;
59  float getParameterDefault(int parameter) const override;
60  int getParameterDisplayHint(int parameter) const override;
61 
62  ParameterList getParameterDescriptors() const override;
63  float getParameter(std::string) const override;
64  void setParameter(std::string, float) override;
65 
66  int getBufferSize() const override { return m_blockSize; }
67  int getAudioInputCount() const override { return int(m_instanceCount * m_audioPortsIn.size()); }
68  int getAudioOutputCount() const override { return int(m_instanceCount * m_audioPortsOut.size()); }
69  sample_t **getAudioInputBuffers() override { return m_inputBuffers; }
71 
72  int getControlOutputCount() const override { return int(m_controlPortsOut.size()); }
73  float getControlOutputValue(int n) const override;
74 
75  bool isBypassed() const override { return m_bypassed; }
76  void setBypassed(bool bypassed) override { m_bypassed = bypassed; }
77 
78  sv_frame_t getLatency() override;
79 
80  void silence() override;
81  void setIdealChannelCount(int channels) override; // may re-instantiate
82 
83  std::string getType() const override { return "LADSPA Real-Time Plugin"; }
84 
85 protected:
86  // To be constructed only by LADSPAPluginFactory
87  friend class LADSPAPluginFactory;
88 
89  // Constructor that creates the buffers internally
90  //
92  int client,
93  QString identifier,
94  int position,
95  sv_samplerate_t sampleRate,
96  int blockSize,
97  int idealChannelCount,
98  const LADSPA_Descriptor* descriptor);
99 
100  void init(int idealChannelCount = 0);
101  void instantiate(sv_samplerate_t sampleRate);
102  void cleanup();
103  void activate();
104  void deactivate();
105 
106  // Connection of data (and behind the scenes control) ports
107  //
108  void connectPorts();
109 
110  int m_client;
112  std::vector<LADSPA_Handle> m_instanceHandles;
114  const LADSPA_Descriptor *m_descriptor;
115 
116  std::vector<std::pair<int, LADSPA_Data*> > m_controlPortsIn;
117  std::vector<std::pair<int, LADSPA_Data*> > m_controlPortsOut;
118 
119  std::vector<int> m_audioPortsIn;
120  std::vector<int> m_audioPortsOut;
121 
128  bool m_run;
129 
131 };
132 
133 #endif // _LADSPAPLUGININSTANCE_H_
134 
float getControlOutputValue(int n) const override
double sv_samplerate_t
Sample rate.
Definition: BaseTypes.h:51
float getParameterValue(int parameter) const override
int getPluginVersion() const override
sample_t ** getAudioInputBuffers() override
std::vector< std::pair< int, LADSPA_Data * > > m_controlPortsOut
std::string getDescription() const override
bool isOK() const override
int getParameterCount() const override
int64_t sv_frame_t
Frame index, the unit of our time axis.
Definition: BaseTypes.h:31
std::vector< LADSPA_Handle > m_instanceHandles
sv_samplerate_t m_sampleRate
int getControlOutputCount() const override
LADSPAPluginInstance(RealTimePluginFactory *factory, int client, QString identifier, int position, sv_samplerate_t sampleRate, int blockSize, int idealChannelCount, const LADSPA_Descriptor *descriptor)
QString getPluginIdentifier() const override
sample_t ** getAudioOutputBuffers() override
std::string getIdentifier() const override
void setParameterValue(int parameter, float value) override
int getAudioInputCount() const override
int getParameterDisplayHint(int parameter) const override
bool isBypassed() const override
int getBufferSize() const override
sv_frame_t getLatency() override
void instantiate(sv_samplerate_t sampleRate)
void setBypassed(bool bypassed) override
float getParameterDefault(int parameter) const override
ParameterList getParameterDescriptors() const override
std::string getCopyright() const override
void setIdealChannelCount(int channels) override
void init(int idealChannelCount=0)
std::vector< int > m_audioPortsOut
std::vector< int > m_audioPortsIn
std::string getName() const override
void run(const RealTime &rt, int count=0) override
Run for one block, starting at the given time.
std::string getType() const override
int getAudioOutputCount() const override
std::string getMaker() const override
float getParameter(std::string) const override
const LADSPA_Descriptor * m_descriptor
std::vector< std::pair< int, LADSPA_Data * > > m_controlPortsIn
RealTime represents time values to nanosecond precision with accurate arithmetic and frame-rate conve...
Definition: RealTime.h:42
void setParameter(std::string, float) override