00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef GAIN_ENVELOPE_H
00024 #define GAIN_ENVELOPE_H
00025
00026 #include "Plugin.h"
00027 #include "Curve.h"
00028 #include "Mixer.h"
00029
00030 class Sheet;
00031
00032 class GainEnvelope : public Plugin
00033 {
00034 Q_OBJECT
00035
00036 public:
00037 GainEnvelope(Sheet* sheet);
00038 ~GainEnvelope(){};
00039
00040 QDomNode get_state(QDomDocument doc);
00041 int set_state(const QDomNode & node );
00042 void process(AudioBus* bus, unsigned long nframes);
00043 void process_gain(audio_sample_t** buffer, const TimeRef& startlocation, const TimeRef& endlocation, nframes_t nframes, uint channels);
00044
00045 void set_sheet(Sheet* sheet);
00046 void set_gain(float gain) {m_gain = gain;}
00047
00048 float get_gain() const {return m_gain;}
00049 Curve* get_curve() const;
00050 QString get_name();
00051
00052 private:
00053 float m_gain;
00054 };
00055
00056
00057 inline void GainEnvelope::process_gain(audio_sample_t** buffer, const TimeRef& startlocation, const TimeRef& endlocation, nframes_t nframes, uint channels)
00058 {
00059 PluginControlPort* port = m_controlPorts.at(0);
00060
00061 if (port->use_automation()) {
00062 port->get_curve()->process(buffer, startlocation, endlocation, nframes, channels, m_gain);
00063 } else {
00064 for (uint chan=0; chan<channels; ++chan) {
00065 Mixer::apply_gain_to_buffer(buffer[chan], nframes, m_gain);
00066 }
00067 }
00068 }
00069
00070
00071 #endif
00072