RealTimePluginInstance.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.
19 */
20 
21 #ifndef SV_REALTIME_PLUGIN_INSTANCE_H
22 #define SV_REALTIME_PLUGIN_INSTANCE_H
23 
24 #include <vamp-hostsdk/PluginBase.h>
25 
26 #include "base/RealTime.h"
27 #include "base/AudioPlaySource.h"
28 
29 #include <QString>
30 #include <QStringList>
31 #include <vector>
32 #include <string>
33 #include <map>
34 
36 
52 /*
53  * N.B. RealTimePluginInstance, RealTimePluginFactory and their
54  * subclasses are terrible code. They've been reused, cut and pasted
55  * and mangled too many times to fit too many different uses, and
56  * could do with a good tidy.
57  */
58 
59 // These names are taken from LADSPA, but the values are not
60 // guaranteed to match
61 
62 namespace PortType { // ORable
63  static const int Input = 1;
64  static const int Output = 2;
65  static const int Control = 4;
66  static const int Audio = 8;
67 }
68 
69 namespace PortHint { // ORable
70  static const int NoHint = 0;
71  static const int Toggled = 1;
72  static const int Integer = 2;
73  static const int Logarithmic = 4;
74  static const int SampleRate = 8;
75 }
76 
77 class RealTimePluginInstance : public Vamp::PluginBase, public Auditionable
78 {
79 public:
80  typedef float sample_t;
81 
82  virtual ~RealTimePluginInstance();
83 
84  virtual bool isOK() const = 0;
85 
86  virtual QString getPluginIdentifier() const = 0;
87 
94  virtual void run(const RealTime &blockStartTime,
95  int count = 0) = 0;
96 
97  virtual int getBufferSize() const = 0;
98 
99  virtual int getAudioInputCount() const = 0;
100  virtual int getAudioOutputCount() const = 0;
101 
102  virtual sample_t **getAudioInputBuffers() = 0;
103  virtual sample_t **getAudioOutputBuffers() = 0;
104 
105  // Control inputs are known as parameters here
106  virtual int getControlOutputCount() const = 0;
107  virtual float getControlOutputValue(int n) const = 0;
108 
109 // virtual QStringList getPrograms() const { return QStringList(); }
110 // virtual QString getCurrentProgram() const { return QString(); }
111  virtual std::string getProgram(int /* bank */, int /* program */) const { return std::string(); }
112 // virtual int getProgram(QString /* name */) const { return 0; } // bank << 16 + program
113 // virtual void selectProgram(QString) { }
114 
115  virtual int getParameterCount() const = 0;
116  virtual void setParameterValue(int parameter, float value) = 0;
117  virtual float getParameterValue(int parameter) const = 0;
118  virtual float getParameterDefault(int parameter) const = 0;
119  virtual int getParameterDisplayHint(int parameter) const = 0;
120 
121  virtual std::string configure(std::string /* key */, std::string /* value */) { return std::string(); }
122 
123  virtual void sendEvent(const RealTime & /* eventTime */,
124  const void * /* event */) { }
125  virtual void clearEvents() { }
126 
127  virtual bool isBypassed() const = 0;
128  virtual void setBypassed(bool value) = 0;
129 
130  // This should be called after setup, but while not actually playing.
131  virtual sv_frame_t getLatency() = 0;
132 
133  virtual void silence() = 0;
134  virtual void discardEvents() { }
135  virtual void setIdealChannelCount(int channels) = 0; // must also silence(); may also re-instantiate
136 
137  std::string getType() const override { return "Real-Time Plugin"; }
138 
139  typedef std::map<std::string, std::string> ConfigurationPairMap;
140  virtual ConfigurationPairMap getConfigurePairs() {
141  return m_configurationData;
142  }
143 
144 protected:
145  RealTimePluginInstance(RealTimePluginFactory *factory, QString identifier) :
146  m_factory(factory), m_identifier(identifier) { }
147 
149  QString m_identifier;
150 
151  ConfigurationPairMap m_configurationData;
152 };
153 
154 
155 #endif
virtual std::string configure(std::string, std::string)
int64_t sv_frame_t
Frame index, the unit of our time axis.
Definition: BaseTypes.h:31
static const int Input
static const int NoHint
static const int Toggled
ConfigurationPairMap m_configurationData
std::map< std::string, std::string > ConfigurationPairMap
static const int Audio
static const int Logarithmic
RealTimePluginFactory * m_factory
virtual std::string getProgram(int, int) const
static const int Integer
virtual ConfigurationPairMap getConfigurePairs()
static const int SampleRate
RealTimePluginInstance is an interface that an audio process can use to refer to an instance of a plu...
static const int Control
std::string getType() const override
virtual void sendEvent(const RealTime &, const void *)
RealTimePluginInstance(RealTimePluginFactory *factory, QString identifier)
static const int Output
RealTime represents time values to nanosecond precision with accurate arithmetic and frame-rate conve...
Definition: RealTime.h:42