annotate plugin/RealTimePluginInstance.h @ 248:084ae1c213ee

* Add display of selection extents in status bar when dragging a selection * Some build fixes after that i18n update
author Chris Cannam
date Wed, 07 Mar 2007 18:00:49 +0000
parents 71f869dac40b
children 13e5870040e6
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.
Chris@0 19 */
Chris@0 20
Chris@0 21 #ifndef _REALTIME_PLUGIN_INSTANCE_H_
Chris@0 22 #define _REALTIME_PLUGIN_INSTANCE_H_
Chris@0 23
Chris@66 24 #include "vamp-sdk/PluginBase.h"
Chris@66 25 #include "vamp-sdk/RealTime.h"
Chris@51 26
Chris@0 27 #include <QString>
Chris@0 28 #include <QStringList>
Chris@0 29 #include <vector>
Chris@51 30 #include <string>
Chris@75 31 #include <map>
Chris@0 32
Chris@0 33 class RealTimePluginFactory;
Chris@0 34
Chris@0 35 /**
Chris@60 36 * RealTimePluginInstance is an interface that an audio process can
Chris@60 37 * use to refer to an instance of a plugin without needing to know
Chris@60 38 * what type of plugin it is.
Chris@0 39 *
Chris@0 40 * The audio code calls run() on an instance that has been passed to
Chris@0 41 * it, and assumes that the passing code has already initialised the
Chris@0 42 * plugin, connected its inputs and outputs and so on, and that there
Chris@0 43 * is an understanding in place about the sizes of the buffers in use
Chris@0 44 * by the plugin. All of this depends on the subclass implementation.
Chris@51 45 *
Chris@51 46 * The PluginInstance base class includes additional abstract methods
Chris@51 47 * which the subclass of RealTimePluginInstance must implement.
Chris@0 48 */
Chris@0 49
Chris@60 50 /*
Chris@60 51 * N.B. RealTimePluginInstance, RealTimePluginFactory and their
Chris@60 52 * subclasses are terrible code. They've been reused, cut and pasted
Chris@60 53 * and mangled too many times to fit too many different uses, and
Chris@60 54 * could do with a good tidy.
Chris@60 55 */
Chris@60 56
Chris@0 57 // These names are taken from LADSPA, but the values are not
Chris@0 58 // guaranteed to match
Chris@0 59
Chris@0 60 namespace PortType { // ORable
Chris@0 61 static const int Input = 1;
Chris@0 62 static const int Output = 2;
Chris@0 63 static const int Control = 4;
Chris@0 64 static const int Audio = 8;
Chris@0 65 }
Chris@0 66
Chris@0 67 namespace PortHint { // ORable
Chris@0 68 static const int NoHint = 0;
Chris@0 69 static const int Toggled = 1;
Chris@0 70 static const int Integer = 2;
Chris@0 71 static const int Logarithmic = 4;
Chris@0 72 static const int SampleRate = 8;
Chris@0 73 }
Chris@0 74
Chris@66 75 class RealTimePluginInstance : public Vamp::PluginBase
Chris@0 76 {
Chris@0 77 public:
Chris@0 78 typedef float sample_t;
Chris@0 79
Chris@0 80 virtual ~RealTimePluginInstance();
Chris@0 81
Chris@0 82 virtual bool isOK() const = 0;
Chris@0 83
Chris@237 84 virtual QString getPluginIdentifier() const = 0;
Chris@0 85
Chris@0 86 /**
Chris@0 87 * Run for one block, starting at the given time. The start time
Chris@0 88 * may be of interest to synths etc that may have queued events
Chris@0 89 * waiting. Other plugins can ignore it.
Chris@0 90 */
Chris@66 91 virtual void run(const Vamp::RealTime &blockStartTime) = 0;
Chris@0 92
Chris@0 93 virtual size_t getBufferSize() const = 0;
Chris@0 94
Chris@0 95 virtual size_t getAudioInputCount() const = 0;
Chris@0 96 virtual size_t getAudioOutputCount() const = 0;
Chris@0 97
Chris@0 98 virtual sample_t **getAudioInputBuffers() = 0;
Chris@0 99 virtual sample_t **getAudioOutputBuffers() = 0;
Chris@0 100
Chris@60 101 // Control inputs are known as parameters here
Chris@60 102 virtual size_t getControlOutputCount() const = 0;
Chris@60 103 virtual float getControlOutputValue(size_t n) const = 0;
Chris@60 104
Chris@51 105 // virtual QStringList getPrograms() const { return QStringList(); }
Chris@51 106 // virtual QString getCurrentProgram() const { return QString(); }
Chris@51 107 virtual std::string getProgram(int /* bank */, int /* program */) const { return std::string(); }
Chris@51 108 // virtual unsigned long getProgram(QString /* name */) const { return 0; } // bank << 16 + program
Chris@51 109 // virtual void selectProgram(QString) { }
Chris@0 110
Chris@0 111 virtual unsigned int getParameterCount() const = 0;
Chris@0 112 virtual void setParameterValue(unsigned int parameter, float value) = 0;
Chris@0 113 virtual float getParameterValue(unsigned int parameter) const = 0;
Chris@0 114 virtual float getParameterDefault(unsigned int parameter) const = 0;
Chris@0 115
Chris@51 116 virtual std::string configure(std::string /* key */, std::string /* value */) { return std::string(); }
Chris@0 117
Chris@66 118 virtual void sendEvent(const Vamp::RealTime & /* eventTime */,
Chris@0 119 const void * /* event */) { }
Chris@10 120 virtual void clearEvents() { }
Chris@0 121
Chris@0 122 virtual bool isBypassed() const = 0;
Chris@0 123 virtual void setBypassed(bool value) = 0;
Chris@0 124
Chris@0 125 // This should be called after setup, but while not actually playing.
Chris@0 126 virtual size_t getLatency() = 0;
Chris@0 127
Chris@0 128 virtual void silence() = 0;
Chris@0 129 virtual void discardEvents() { }
Chris@0 130 virtual void setIdealChannelCount(size_t channels) = 0; // must also silence(); may also re-instantiate
Chris@0 131
Chris@0 132 void setFactory(RealTimePluginFactory *f) { m_factory = f; } // ew
Chris@0 133
Chris@57 134 virtual std::string getType() const { return "Real-Time Plugin"; }
Chris@57 135
Chris@75 136 virtual std::map<std::string, std::string> getConfigurePairs() {
Chris@75 137 return m_configurationData;
Chris@75 138 }
Chris@75 139
Chris@0 140 protected:
Chris@0 141 RealTimePluginInstance(RealTimePluginFactory *factory, QString identifier) :
Chris@0 142 m_factory(factory), m_identifier(identifier) { }
Chris@0 143
Chris@0 144 RealTimePluginFactory *m_factory;
Chris@0 145 QString m_identifier;
Chris@0 146
Chris@75 147 std::map<std::string, std::string> m_configurationData;
Chris@75 148
Chris@0 149 friend class PluginFactory;
Chris@0 150 };
Chris@0 151
Chris@0 152
Chris@0 153 #endif