2 Copyright (C) 2006 Paul Davis
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)
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
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.
19 #ifndef __ardour_amp_h__
20 #define __ardour_amp_h__
22 #include "ardour/types.h"
23 #include "ardour/chan_count.h"
24 #include "ardour/processor.h"
25 #include "ardour/automation_control.h"
32 /** Applies a declick operation to all audio inputs, passing the same number of
33 * audio outputs, and passing through any other types unchanged.
35 class Amp : public Processor {
39 std::string display_name() const;
41 bool visible () const;
43 bool can_support_io_configuration (const ChanCount& in, ChanCount& out) const;
44 bool configure_io (ChanCount in, ChanCount out);
46 void run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframes_t nframes, bool);
48 bool apply_gain () const { return _apply_gain; }
49 void apply_gain (bool yn) { _apply_gain = yn; }
51 void setup_gain_automation (framepos_t start_frame, framepos_t end_frame, framecnt_t nframes);
53 bool apply_gain_automation() const { return _apply_gain_automation; }
54 void apply_gain_automation(bool yn) { _apply_gain_automation = yn; }
56 XMLNode& state (bool full);
57 int set_state (const XMLNode&, int version);
59 static void apply_gain (BufferSet& bufs, framecnt_t nframes, gain_t initial, gain_t target);
60 static void apply_simple_gain(BufferSet& bufs, framecnt_t nframes, gain_t target);
62 static void apply_gain (AudioBuffer& buf, framecnt_t nframes, gain_t initial, gain_t target);
63 static void apply_simple_gain(AudioBuffer& buf, framecnt_t nframes, gain_t target);
65 static void declick (BufferSet& bufs, framecnt_t nframes, int dir);
67 gain_t gain () const { return _gain_control->get_value(); }
69 void set_gain (gain_t g, void *src);
70 void inc_gain (gain_t delta, void *src);
72 static void update_meters();
76 struct GainControl : public AutomationControl {
77 GainControl (std::string name, Session& session, Amp* a, const Evoral::Parameter ¶m,
78 boost::shared_ptr<AutomationList> al = boost::shared_ptr<AutomationList>() )
79 : AutomationControl (session, param, al, name)
81 set_flags (Controllable::Flag (flags() | Controllable::GainLike));
84 void set_value (double val);
86 double internal_to_interface (double) const;
87 double interface_to_internal (double) const;
88 double internal_to_user (double) const;
93 boost::shared_ptr<GainControl> gain_control() {
97 boost::shared_ptr<const GainControl> gain_control() const {
101 std::string value_as_string (boost::shared_ptr<AutomationControl>) const;
104 bool _denormal_protection;
106 bool _apply_gain_automation;
109 boost::shared_ptr<GainControl> _gain_control;
113 } // namespace ARDOUR
115 #endif // __ardour_amp_h__