RealTimePluginInstance.h

Go to the documentation of this file.
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-sdk/PluginBase.h"
00025 #include "vamp-sdk/RealTime.h"
00026 
00027 #include <QString>
00028 #include <QStringList>
00029 #include <vector>
00030 #include <string>
00031 #include <map>
00032 
00033 class RealTimePluginFactory;
00034         
00050 /*
00051  * N.B. RealTimePluginInstance, RealTimePluginFactory and their
00052  * subclasses are terrible code.  They've been reused, cut and pasted
00053  * and mangled too many times to fit too many different uses, and
00054  * could do with a good tidy.
00055  */
00056 
00057 // These names are taken from LADSPA, but the values are not
00058 // guaranteed to match
00059 
00060 namespace PortType { // ORable
00061     static const int Input   = 1;
00062     static const int Output  = 2;
00063     static const int Control = 4;
00064     static const int Audio   = 8;
00065 }
00066 
00067 namespace PortHint { // ORable
00068     static const int NoHint  = 0;
00069     static const int Toggled = 1;
00070     static const int Integer = 2;
00071     static const int Logarithmic = 4;
00072     static const int SampleRate = 8;
00073 }
00074 
00075 class RealTimePluginInstance : public Vamp::PluginBase
00076 {
00077 public:
00078     typedef float sample_t;
00079 
00080     virtual ~RealTimePluginInstance();
00081 
00082     virtual bool isOK() const = 0;
00083 
00084     virtual QString getPluginIdentifier() const = 0;
00085 
00091     virtual void run(const Vamp::RealTime &blockStartTime) = 0;
00092     
00093     virtual size_t getBufferSize() const = 0;
00094 
00095     virtual size_t getAudioInputCount() const = 0;
00096     virtual size_t getAudioOutputCount() const = 0;
00097 
00098     virtual sample_t **getAudioInputBuffers() = 0;
00099     virtual sample_t **getAudioOutputBuffers() = 0;
00100 
00101     // Control inputs are known as parameters here
00102     virtual size_t getControlOutputCount() const = 0;
00103     virtual float getControlOutputValue(size_t n) const = 0;
00104 
00105 //     virtual QStringList getPrograms() const { return QStringList(); }
00106 //     virtual QString getCurrentProgram() const { return QString(); }
00107     virtual std::string getProgram(int /* bank */, int /* program */) const { return std::string(); }
00108 //     virtual unsigned long getProgram(QString /* name */) const { return 0; } // bank << 16 + program
00109 //     virtual void selectProgram(QString) { }
00110 
00111     virtual unsigned int getParameterCount() const = 0;
00112     virtual void setParameterValue(unsigned int parameter, float value) = 0;
00113     virtual float getParameterValue(unsigned int parameter) const = 0;
00114     virtual float getParameterDefault(unsigned int parameter) const = 0;
00115     virtual int getParameterDisplayHint(unsigned int parameter) const = 0;
00116 
00117     virtual std::string configure(std::string /* key */, std::string /* value */) { return std::string(); }
00118 
00119     virtual void sendEvent(const Vamp::RealTime & /* eventTime */,
00120                            const void * /* event */) { }
00121     virtual void clearEvents() { }
00122 
00123     virtual bool isBypassed() const = 0;
00124     virtual void setBypassed(bool value) = 0;
00125 
00126     // This should be called after setup, but while not actually playing.
00127     virtual size_t getLatency() = 0;
00128 
00129     virtual void silence() = 0;
00130     virtual void discardEvents() { }
00131     virtual void setIdealChannelCount(size_t channels) = 0; // must also silence(); may also re-instantiate
00132 
00133     void setFactory(RealTimePluginFactory *f) { m_factory = f; } // ew
00134 
00135     virtual std::string getType() const { return "Real-Time Plugin"; }
00136 
00137     typedef std::map<std::string, std::string> ConfigurationPairMap;
00138     virtual ConfigurationPairMap getConfigurePairs() {
00139         return m_configurationData;
00140     }
00141 
00142 protected:
00143     RealTimePluginInstance(RealTimePluginFactory *factory, QString identifier) :
00144         m_factory(factory), m_identifier(identifier) { }
00145 
00146     RealTimePluginFactory *m_factory;
00147     QString m_identifier;
00148 
00149     ConfigurationPairMap m_configurationData;
00150 
00151     friend class PluginFactory;
00152 };
00153 
00154 
00155 #endif

Generated on Wed Feb 20 15:45:27 2008 for SonicVisualiser by  doxygen 1.5.1