only push note-on information into the step edit ringbuffer
[ardour.git] / libs / ardour / ardour / amp.h
1 /*
2     Copyright (C) 2006 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify it
5     under the terms of the GNU General Public License as published by the Free
6     Software Foundation; either version 2 of the License, or (at your option)
7     any later version.
8
9     This program is distributed in the hope that it will be useful, but WITHOUT
10     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12     for more details.
13
14     You should have received a copy of the GNU General Public License along
15     with this program; if not, write to the Free Software Foundation, Inc.,
16     675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18
19 #ifndef __ardour_amp_h__
20 #define __ardour_amp_h__
21
22 #include "ardour/types.h"
23 #include "ardour/chan_count.h"
24 #include "ardour/processor.h"
25 #include "ardour/automation_control.h"
26
27 namespace ARDOUR {
28
29 class BufferSet;
30 class IO;
31
32 /** Applies a declick operation to all audio inputs, passing the same number of
33  * audio outputs, and passing through any other types unchanged.
34  */
35 class Amp : public Processor {
36 public:
37         Amp(Session& s);
38
39         std::string display_name() const;
40
41         bool visible () const;
42
43         bool can_support_io_configuration (const ChanCount& in, ChanCount& out) const;
44         bool configure_io (ChanCount in, ChanCount out);
45
46         void run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes, bool);
47
48         bool apply_gain() const  { return _apply_gain; }
49         void apply_gain(bool yn) { _apply_gain = yn; }
50
51         void setup_gain_automation (sframes_t start_frame, sframes_t end_frame, nframes_t nframes);
52
53         bool apply_gain_automation() const  { return _apply_gain_automation; }
54         void apply_gain_automation(bool yn) { _apply_gain_automation = yn; }
55
56         XMLNode& state (bool full);
57         int set_state (const XMLNode&, int version);
58
59         static void apply_gain (BufferSet& bufs, nframes_t nframes, gain_t initial, gain_t target);
60         static void apply_simple_gain(BufferSet& bufs, nframes_t nframes, gain_t target);
61         
62         static void apply_gain (AudioBuffer& buf, nframes_t nframes, gain_t initial, gain_t target);
63         static void apply_simple_gain(AudioBuffer& buf, nframes_t nframes, gain_t target);
64
65         gain_t         gain () const { return _gain_control->user_float(); }
66
67         virtual void   set_gain (gain_t g, void *src);
68         void           inc_gain (gain_t delta, void *src);
69
70         static void update_meters();
71
72         /* automation */
73
74         struct GainControl : public AutomationControl {
75                 GainControl (std::string name, Session& session, Amp* a, const Evoral::Parameter &param,
76                                 boost::shared_ptr<AutomationList> al = boost::shared_ptr<AutomationList>() )
77                         : AutomationControl (session, param, al, name)
78                         , _amp (a) {
79                         set_flags (Controllable::Flag (flags() | Controllable::GainLike));
80                 }
81
82                 void set_value (float val);
83                 float get_value (void) const;
84
85                 Amp* _amp;
86         };
87
88         boost::shared_ptr<GainControl> gain_control() {
89                 return _gain_control;
90         }
91
92         boost::shared_ptr<const GainControl> gain_control() const {
93                 return _gain_control;
94         }
95
96 private:
97         bool   _denormal_protection;
98         bool   _apply_gain;
99         bool   _apply_gain_automation;
100         float  _current_gain;
101
102         boost::shared_ptr<GainControl> _gain_control;
103 };
104
105
106 } // namespace ARDOUR
107
108 #endif // __ardour_amp_h__