00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef PLUGIN_H
00024 #define PLUGIN_H
00025
00026 #include "ContextItem.h"
00027 #include <QString>
00028 #include <QDomNode>
00029
00030 #include "defines.h"
00031
00032 class AudioBus;
00033 class PluginChain;
00034 class PluginControlPort;
00035 class AudioInputPort;
00036 class AudioOutputPort;
00037 class Curve;
00038 class Sheet;
00039
00040 struct PluginInfo {
00041 PluginInfo() {
00042 audioPortInCount = 0;
00043 audioPortOutCount = 0;
00044 }
00045 int audioPortInCount;
00046 int audioPortOutCount;
00047 QString type;
00048 QString name;
00049 QString uri;
00050 };
00051
00052 class Plugin : public ContextItem
00053 {
00054 Q_OBJECT
00055 Q_CLASSINFO("toggle_bypass", tr("Bypass: On/Off"))
00056
00057 public:
00058 Plugin(Sheet* sheet = 0);
00059 virtual ~Plugin(){};
00060
00061 virtual int init() {return 1;}
00062 virtual QDomNode get_state(QDomDocument doc);
00063 virtual int set_state(const QDomNode & node );
00064 virtual void process(AudioBus* bus, unsigned long nframes) = 0;
00065 virtual QString get_name() = 0;
00066
00067 PluginControlPort* get_control_port_by_index(int index) const;
00068 QList<PluginControlPort* > get_control_ports() const { return m_controlPorts; }
00069
00070 Plugin* get_slave() const {return m_slave;}
00071 Sheet* get_sheet() const {return m_sheet;}
00072 bool is_bypassed() const {return m_bypass;}
00073
00074 void automate_port(int index, bool automate);
00075
00076 protected:
00077 Plugin* m_slave;
00078 Sheet* m_sheet;
00079 QList<PluginControlPort* > m_controlPorts;
00080 QList<AudioInputPort* > m_audioInputPorts;
00081 QList<AudioOutputPort* > m_audioOutputPorts;
00082
00083 bool m_bypass;
00084
00085
00086 signals:
00087 void bypassChanged();
00088
00089 public slots:
00090 Command* toggle_bypass();
00091 };
00092
00093
00094 class PluginPort : public QObject
00095 {
00096
00097 public:
00098 PluginPort(QObject* parent, int index) : QObject(parent), m_index(index), m_hint(FLOAT_CONTROL) {};
00099 PluginPort(QObject* parent) : QObject(parent), m_hint(FLOAT_CONTROL) {};
00100 virtual ~PluginPort(){};
00101
00102 virtual QDomNode get_state(QDomDocument doc);
00103 virtual int set_state( const QDomNode & node ) = 0;
00104
00105 enum PortHint {
00106 FLOAT_CONTROL,
00107 INT_CONTROL,
00108 LOG_CONTROL
00109 };
00110
00111 int get_index() const {return m_index;}
00112 int get_hint() const {return m_hint;}
00113
00114 void set_index(int index) {m_index = index;}
00115
00116 protected:
00117 int m_index;
00118 int m_hint;
00119 };
00120
00121
00122 class PluginControlPort : public PluginPort
00123 {
00124 Q_OBJECT
00125
00126 public:
00127 PluginControlPort(Plugin* parent, int index, float value);
00128 PluginControlPort(Plugin* parent, const QDomNode node);
00129 virtual ~PluginControlPort(){}
00130
00131 virtual float get_control_value() {return m_value; }
00132 virtual float get_min_control_value() {return m_min;}
00133 virtual float get_max_control_value() {return m_max;}
00134 virtual float get_default_value() {return m_default;}
00135
00136 void set_min(float min) {m_min = min;}
00137 void set_max(float max) {m_max = max;}
00138 void set_default(float def) {m_default = def;}
00139 void set_use_automation(bool automation);
00140
00141 bool use_automation();
00142 Curve* get_curve() const {return m_curve;}
00143
00144 virtual QDomNode get_state(QDomDocument doc);
00145
00146 virtual QString get_description();
00147 virtual QString get_symbol();
00148
00149 protected:
00150 Curve* m_curve;
00151 Plugin* m_plugin;
00152 float m_value;
00153 float m_default;
00154 float m_min;
00155 float m_max;
00156 bool m_automation;
00157 QString m_description;
00158
00159 virtual int set_state( const QDomNode & node );
00160
00161 public slots:
00162 void set_control_value(float value);
00163 };
00164
00165
00166 class AudioInputPort : public PluginPort
00167 {
00168
00169 public:
00170 AudioInputPort(QObject* parent, int index);
00171 AudioInputPort(QObject* parent) : PluginPort(parent) {};
00172 virtual ~AudioInputPort(){};
00173
00174 QDomNode get_state(QDomDocument doc);
00175 int set_state( const QDomNode & node );
00176
00177 };
00178
00179
00180 class AudioOutputPort : public PluginPort
00181 {
00182
00183 public:
00184 AudioOutputPort(QObject* parent, int index);
00185 AudioOutputPort(QObject* parent) : PluginPort(parent) {};
00186 virtual ~AudioOutputPort(){};
00187
00188 QDomNode get_state(QDomDocument doc);
00189 int set_state( const QDomNode & node );
00190
00191 };
00192
00193
00194 #endif
00195
00196