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_CHAIN_H
00024 #define PLUGIN_CHAIN_H
00025
00026 #include <ContextItem.h>
00027 #include <QList>
00028 #include <QDomNode>
00029 #include "Plugin.h"
00030 #include "GainEnvelope.h"
00031
00032 class Sheet;
00033 class AudioBus;
00034
00035 class PluginChain : public ContextItem
00036 {
00037 Q_OBJECT
00038
00039 public:
00040 PluginChain(ContextItem* parent);
00041 PluginChain(ContextItem* parent, Sheet* sheet);
00042 ~PluginChain();
00043
00044 QDomNode get_state(QDomDocument doc);
00045 int set_state(const QDomNode & node );
00046
00047 Command* add_plugin(Plugin* plugin, bool historable=true);
00048 Command* remove_plugin(Plugin* plugin, bool historable=true);
00049 void process_pre_fader(AudioBus* bus, unsigned long nframes);
00050 int process_post_fader(AudioBus* bus, unsigned long nframes);
00051
00052
00053 void set_sheet(Sheet* sheet);
00054
00055 QList<Plugin* > get_plugin_list() {return m_pluginList;}
00056 GainEnvelope* get_fader() const {return m_fader;}
00057
00058 private:
00059 QList<Plugin* > m_pluginList;
00060 GainEnvelope* m_fader;
00061 Sheet* m_sheet;
00062
00063 signals:
00064 void pluginAdded(Plugin* plugin);
00065 void pluginRemoved(Plugin* plugin);
00066
00067 private slots:
00068 void private_add_plugin(Plugin* plugin);
00069 void private_remove_plugin(Plugin* plugin);
00070
00071
00072 };
00073
00074 inline void PluginChain::process_pre_fader(AudioBus * bus, unsigned long nframes)
00075 {
00076 return;
00077 for (int i=0; i<m_pluginList.size(); ++i) {
00078 Plugin* plugin = m_pluginList.at(i);
00079 if (plugin == m_fader) return;
00080 plugin->process(bus, nframes);
00081 }
00082 }
00083
00084 inline int PluginChain::process_post_fader(AudioBus * bus, unsigned long nframes)
00085 {
00086 if (!m_pluginList.size()) {
00087 return 0;
00088 }
00089
00090 for (int i=0; i<m_pluginList.size(); ++i) {
00091 Plugin* plugin = m_pluginList.at(i);
00092
00093 plugin->process(bus, nframes);
00094 }
00095
00096 return 1;
00097 }
00098
00099 #endif
00100
00101