Chris@0
|
1 /* -*- c-basic-offset: 4 -*- 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.
|
Chris@0
|
14 */
|
Chris@0
|
15
|
Chris@0
|
16 #ifndef _REALTIME_PLUGIN_INSTANCE_H_
|
Chris@0
|
17 #define _REALTIME_PLUGIN_INSTANCE_H_
|
Chris@0
|
18
|
Chris@0
|
19 #include <QString>
|
Chris@0
|
20 #include <QStringList>
|
Chris@0
|
21 #include <vector>
|
Chris@0
|
22
|
Chris@0
|
23 #include "base/RealTime.h"
|
Chris@0
|
24
|
Chris@0
|
25 class RealTimePluginFactory;
|
Chris@0
|
26
|
Chris@0
|
27 /**
|
Chris@0
|
28 * RealTimePluginInstance is a very trivial interface that an audio
|
Chris@0
|
29 * process can use to refer to an instance of a plugin without needing
|
Chris@0
|
30 * to know what type of plugin it is.
|
Chris@0
|
31 *
|
Chris@0
|
32 * The audio code calls run() on an instance that has been passed to
|
Chris@0
|
33 * it, and assumes that the passing code has already initialised the
|
Chris@0
|
34 * plugin, connected its inputs and outputs and so on, and that there
|
Chris@0
|
35 * is an understanding in place about the sizes of the buffers in use
|
Chris@0
|
36 * by the plugin. All of this depends on the subclass implementation.
|
Chris@0
|
37 */
|
Chris@0
|
38
|
Chris@0
|
39 // These names are taken from LADSPA, but the values are not
|
Chris@0
|
40 // guaranteed to match
|
Chris@0
|
41
|
Chris@0
|
42 namespace PortType { // ORable
|
Chris@0
|
43 static const int Input = 1;
|
Chris@0
|
44 static const int Output = 2;
|
Chris@0
|
45 static const int Control = 4;
|
Chris@0
|
46 static const int Audio = 8;
|
Chris@0
|
47 }
|
Chris@0
|
48
|
Chris@0
|
49 namespace PortHint { // ORable
|
Chris@0
|
50 static const int NoHint = 0;
|
Chris@0
|
51 static const int Toggled = 1;
|
Chris@0
|
52 static const int Integer = 2;
|
Chris@0
|
53 static const int Logarithmic = 4;
|
Chris@0
|
54 static const int SampleRate = 8;
|
Chris@0
|
55 }
|
Chris@0
|
56
|
Chris@0
|
57 class RealTimePluginInstance
|
Chris@0
|
58 {
|
Chris@0
|
59 public:
|
Chris@0
|
60 typedef float sample_t;
|
Chris@0
|
61
|
Chris@0
|
62 virtual ~RealTimePluginInstance();
|
Chris@0
|
63
|
Chris@0
|
64 virtual bool isOK() const = 0;
|
Chris@0
|
65
|
Chris@0
|
66 virtual QString getIdentifier() const = 0;
|
Chris@0
|
67
|
Chris@0
|
68 /**
|
Chris@0
|
69 * Run for one block, starting at the given time. The start time
|
Chris@0
|
70 * may be of interest to synths etc that may have queued events
|
Chris@0
|
71 * waiting. Other plugins can ignore it.
|
Chris@0
|
72 */
|
Chris@0
|
73 virtual void run(const RealTime &blockStartTime) = 0;
|
Chris@0
|
74
|
Chris@0
|
75 virtual size_t getBufferSize() const = 0;
|
Chris@0
|
76
|
Chris@0
|
77 virtual size_t getAudioInputCount() const = 0;
|
Chris@0
|
78 virtual size_t getAudioOutputCount() const = 0;
|
Chris@0
|
79
|
Chris@0
|
80 virtual sample_t **getAudioInputBuffers() = 0;
|
Chris@0
|
81 virtual sample_t **getAudioOutputBuffers() = 0;
|
Chris@0
|
82
|
Chris@0
|
83 virtual QStringList getPrograms() const { return QStringList(); }
|
Chris@0
|
84 virtual QString getCurrentProgram() const { return QString(); }
|
Chris@0
|
85 virtual QString getProgram(int /* bank */, int /* program */) const { return QString(); }
|
Chris@0
|
86 virtual unsigned long getProgram(QString /* name */) const { return 0; } // bank << 16 + program
|
Chris@0
|
87 virtual void selectProgram(QString) { }
|
Chris@0
|
88
|
Chris@0
|
89 virtual unsigned int getParameterCount() const = 0;
|
Chris@0
|
90 virtual void setParameterValue(unsigned int parameter, float value) = 0;
|
Chris@0
|
91 virtual float getParameterValue(unsigned int parameter) const = 0;
|
Chris@0
|
92 virtual float getParameterDefault(unsigned int parameter) const = 0;
|
Chris@0
|
93
|
Chris@0
|
94 virtual QString configure(QString /* key */, QString /* value */) { return QString(); }
|
Chris@0
|
95
|
Chris@0
|
96 virtual void sendEvent(const RealTime & /* eventTime */,
|
Chris@0
|
97 const void * /* event */) { }
|
Chris@10
|
98 virtual void clearEvents() { }
|
Chris@0
|
99
|
Chris@0
|
100 virtual bool isBypassed() const = 0;
|
Chris@0
|
101 virtual void setBypassed(bool value) = 0;
|
Chris@0
|
102
|
Chris@0
|
103 // This should be called after setup, but while not actually playing.
|
Chris@0
|
104 virtual size_t getLatency() = 0;
|
Chris@0
|
105
|
Chris@0
|
106 virtual void silence() = 0;
|
Chris@0
|
107 virtual void discardEvents() { }
|
Chris@0
|
108 virtual void setIdealChannelCount(size_t channels) = 0; // must also silence(); may also re-instantiate
|
Chris@0
|
109
|
Chris@0
|
110 void setFactory(RealTimePluginFactory *f) { m_factory = f; } // ew
|
Chris@0
|
111
|
Chris@0
|
112 protected:
|
Chris@0
|
113 RealTimePluginInstance(RealTimePluginFactory *factory, QString identifier) :
|
Chris@0
|
114 m_factory(factory), m_identifier(identifier) { }
|
Chris@0
|
115
|
Chris@0
|
116 RealTimePluginFactory *m_factory;
|
Chris@0
|
117 QString m_identifier;
|
Chris@0
|
118
|
Chris@0
|
119 friend class PluginFactory;
|
Chris@0
|
120 };
|
Chris@0
|
121
|
Chris@0
|
122
|
Chris@0
|
123 #endif
|