svcore
1.9
|
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 00002 00003 /* 00004 Sonic Visualiser 00005 An audio file viewer and annotation editor. 00006 Centre for Digital Music, Queen Mary, University of London. 00007 00008 This program is free software; you can redistribute it and/or 00009 modify it under the terms of the GNU General Public License as 00010 published by the Free Software Foundation; either version 2 of the 00011 License, or (at your option) any later version. See the file 00012 COPYING included with this distribution for more information. 00013 */ 00014 00015 /* 00016 This is a modified version of a source file from the 00017 Rosegarden MIDI and audio sequencer and notation editor. 00018 This file copyright 2000-2006 Chris Cannam. 00019 */ 00020 00021 #ifndef _REALTIME_PLUGIN_INSTANCE_H_ 00022 #define _REALTIME_PLUGIN_INSTANCE_H_ 00023 00024 #include <vamp-hostsdk/PluginBase.h> 00025 #include <vamp-hostsdk/RealTime.h> 00026 00027 #include <QString> 00028 #include <QStringList> 00029 #include <vector> 00030 #include <string> 00031 #include <map> 00032 00033 #include "base/AudioPlaySource.h" 00034 00035 class RealTimePluginFactory; 00036 00052 /* 00053 * N.B. RealTimePluginInstance, RealTimePluginFactory and their 00054 * subclasses are terrible code. They've been reused, cut and pasted 00055 * and mangled too many times to fit too many different uses, and 00056 * could do with a good tidy. 00057 */ 00058 00059 // These names are taken from LADSPA, but the values are not 00060 // guaranteed to match 00061 00062 namespace PortType { // ORable 00063 static const int Input = 1; 00064 static const int Output = 2; 00065 static const int Control = 4; 00066 static const int Audio = 8; 00067 } 00068 00069 namespace PortHint { // ORable 00070 static const int NoHint = 0; 00071 static const int Toggled = 1; 00072 static const int Integer = 2; 00073 static const int Logarithmic = 4; 00074 static const int SampleRate = 8; 00075 } 00076 00077 class RealTimePluginInstance : public Vamp::PluginBase, public Auditionable 00078 { 00079 public: 00080 typedef float sample_t; 00081 00082 virtual ~RealTimePluginInstance(); 00083 00084 virtual bool isOK() const = 0; 00085 00086 virtual QString getPluginIdentifier() const = 0; 00087 00094 virtual void run(const Vamp::RealTime &blockStartTime, 00095 size_t count = 0) = 0; 00096 00097 virtual size_t getBufferSize() const = 0; 00098 00099 virtual size_t getAudioInputCount() const = 0; 00100 virtual size_t getAudioOutputCount() const = 0; 00101 00102 virtual sample_t **getAudioInputBuffers() = 0; 00103 virtual sample_t **getAudioOutputBuffers() = 0; 00104 00105 // Control inputs are known as parameters here 00106 virtual size_t getControlOutputCount() const = 0; 00107 virtual float getControlOutputValue(size_t n) const = 0; 00108 00109 // virtual QStringList getPrograms() const { return QStringList(); } 00110 // virtual QString getCurrentProgram() const { return QString(); } 00111 virtual std::string getProgram(int /* bank */, int /* program */) const { return std::string(); } 00112 // virtual unsigned long getProgram(QString /* name */) const { return 0; } // bank << 16 + program 00113 // virtual void selectProgram(QString) { } 00114 00115 virtual unsigned int getParameterCount() const = 0; 00116 virtual void setParameterValue(unsigned int parameter, float value) = 0; 00117 virtual float getParameterValue(unsigned int parameter) const = 0; 00118 virtual float getParameterDefault(unsigned int parameter) const = 0; 00119 virtual int getParameterDisplayHint(unsigned int parameter) const = 0; 00120 00121 virtual std::string configure(std::string /* key */, std::string /* value */) { return std::string(); } 00122 00123 virtual void sendEvent(const Vamp::RealTime & /* eventTime */, 00124 const void * /* event */) { } 00125 virtual void clearEvents() { } 00126 00127 virtual bool isBypassed() const = 0; 00128 virtual void setBypassed(bool value) = 0; 00129 00130 // This should be called after setup, but while not actually playing. 00131 virtual size_t getLatency() = 0; 00132 00133 virtual void silence() = 0; 00134 virtual void discardEvents() { } 00135 virtual void setIdealChannelCount(size_t channels) = 0; // must also silence(); may also re-instantiate 00136 00137 void setFactory(RealTimePluginFactory *f) { m_factory = f; } // ew 00138 00139 virtual std::string getType() const { return "Real-Time Plugin"; } 00140 00141 typedef std::map<std::string, std::string> ConfigurationPairMap; 00142 virtual ConfigurationPairMap getConfigurePairs() { 00143 return m_configurationData; 00144 } 00145 00146 protected: 00147 RealTimePluginInstance(RealTimePluginFactory *factory, QString identifier) : 00148 m_factory(factory), m_identifier(identifier) { } 00149 00150 RealTimePluginFactory *m_factory; 00151 QString m_identifier; 00152 00153 ConfigurationPairMap m_configurationData; 00154 00155 friend class PluginFactory; 00156 }; 00157 00158 00159 #endif