NO-OP: Consistent API name
[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/dB.h"
23 #include "ardour/libardour_visibility.h"
24 #include "ardour/types.h"
25 #include "ardour/chan_count.h"
26 #include "ardour/processor.h"
27 #include "ardour/automation_control.h"
28
29 namespace ARDOUR {
30
31 class BufferSet;
32 class GainControl;
33 class IO;
34
35 /** Applies a declick operation to all audio inputs, passing the same number of
36  * audio outputs, and passing through any other types unchanged.
37  */
38 class LIBARDOUR_API Amp : public Processor {
39 public:
40         Amp(Session& s, const std::string& display_name, boost::shared_ptr<GainControl> control, bool control_midi_also);
41
42         std::string display_name () const { return _display_name; }
43         void set_display_name (const std::string& name) { _display_name = name; }
44
45         bool visible () const;
46
47         bool can_support_io_configuration (const ChanCount& in, ChanCount& out);
48         bool configure_io (ChanCount in, ChanCount out);
49
50         void run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, double speed, pframes_t nframes, bool);
51
52         void set_gain_automation_buffer (gain_t *);
53
54         void setup_gain_automation (framepos_t start_frame, framepos_t end_frame, framecnt_t nframes);
55
56         bool apply_gain_automation() const  { return _apply_gain_automation; }
57         void apply_gain_automation(bool yn) { _apply_gain_automation = yn; }
58
59         XMLNode& state (bool full);
60         int set_state (const XMLNode&, int version);
61
62         static gain_t apply_gain (BufferSet& bufs, framecnt_t sample_rate, framecnt_t nframes, gain_t initial, gain_t target, bool midi_amp = true);
63         static void apply_simple_gain(BufferSet& bufs, framecnt_t nframes, gain_t target, bool midi_amp = true);
64
65         static gain_t apply_gain (AudioBuffer& buf, framecnt_t sample_rate, framecnt_t nframes, gain_t initial, gain_t target);
66         static void apply_simple_gain(AudioBuffer& buf, framecnt_t nframes, gain_t target);
67
68         static void declick (BufferSet& bufs, framecnt_t nframes, int dir);
69         static void update_meters();
70
71         boost::shared_ptr<GainControl> gain_control() {
72                 return _gain_control;
73         }
74
75         boost::shared_ptr<const GainControl> gain_control() const {
76                 return _gain_control;
77         }
78
79 private:
80         bool   _denormal_protection;
81         bool   _apply_gain_automation;
82         float  _current_gain;
83         framepos_t _current_automation_frame;
84
85         std::string _display_name;
86
87         boost::shared_ptr<GainControl> _gain_control;
88
89         /** Buffer that we should use for gain automation */
90         gain_t* _gain_automation_buffer;
91         bool _midi_amp;
92 };
93
94
95 } // namespace ARDOUR
96
97 #endif // __ardour_amp_h__