1 /*
2 Copyright (C) 2007 Remon Sijrier
3
4 This file is part of Traverso
5
6 Traverso is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19
20 */
21
22
23 #ifndef GAIN_ENVELOPE_H
24 #define GAIN_ENVELOPE_H
25
26 #include "Plugin.h"
27 #include "Curve.h"
28 #include "Mixer.h"
29
30 class Sheet;
31
32 class GainEnvelope : public Plugin
33 {
34 Q_OBJECT
35
36 public:
37 GainEnvelope(Sheet* sheet);
~GainEnvelope()38 ~GainEnvelope(){};
39
40 QDomNode get_state(QDomDocument doc);
41 int set_state(const QDomNode & node );
42 void process(AudioBus* bus, unsigned long nframes);
43 void process_gain(audio_sample_t** buffer, const TimeRef& startlocation, const TimeRef& endlocation, nframes_t nframes, uint channels);
44
45 void set_sheet(Sheet* sheet);
set_gain(float gain)46 void set_gain(float gain) {m_gain = gain;}
47
get_gain()48 float get_gain() const {return m_gain;}
49 Curve* get_curve() const;
50 QString get_name();
51
52 private:
53 float m_gain;
54 };
55
56
process_gain(audio_sample_t ** buffer,const TimeRef & startlocation,const TimeRef & endlocation,nframes_t nframes,uint channels)57 inline void GainEnvelope::process_gain(audio_sample_t** buffer, const TimeRef& startlocation, const TimeRef& endlocation, nframes_t nframes, uint channels)
58 {
59 PluginControlPort* port = m_controlPorts.at(0);
60
61 if (port->use_automation()) {
62 port->get_curve()->process(buffer, startlocation, endlocation, nframes, channels, m_gain);
63 } else {
64 for (uint chan=0; chan<channels; ++chan) {
65 Mixer::apply_gain_to_buffer(buffer[chan], nframes, m_gain);
66 }
67 }
68 }
69
70
71 #endif
72
73