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/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"
35 /** Gain Stage (Fader, Trim). */
36 class LIBARDOUR_API Amp : public Processor {
38 Amp(Session& s, const std::string& display_name, boost::shared_ptr<GainControl> control, bool control_midi_also);
40 std::string display_name () const { return _display_name; }
41 void set_display_name (const std::string& name) { _display_name = name; }
43 bool visible () const;
45 bool can_support_io_configuration (const ChanCount& in, ChanCount& out);
46 bool configure_io (ChanCount in, ChanCount out);
48 void run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_sample, double speed, pframes_t nframes, bool);
50 void set_gain_automation_buffer (gain_t *);
52 void setup_gain_automation (samplepos_t start_sample, samplepos_t end_sample, samplecnt_t nframes);
55 int set_state (const XMLNode&, int version);
57 static gain_t apply_gain (BufferSet& bufs, samplecnt_t sample_rate, samplecnt_t nframes, gain_t initial, gain_t target, bool midi_amp = true);
58 static void apply_simple_gain(BufferSet& bufs, samplecnt_t nframes, gain_t target, bool midi_amp = true);
60 static gain_t apply_gain (AudioBuffer& buf, samplecnt_t sample_rate, samplecnt_t nframes, gain_t initial, gain_t target, sampleoffset_t offset = 0);
61 static void apply_simple_gain (AudioBuffer& buf, samplecnt_t nframes, gain_t target, sampleoffset_t offset = 0);
63 boost::shared_ptr<GainControl> gain_control() {
67 boost::shared_ptr<const GainControl> gain_control() const {
72 bool _denormal_protection;
73 bool _apply_gain_automation;
75 samplepos_t _current_automation_sample;
77 std::string _display_name;
79 boost::shared_ptr<GainControl> _gain_control;
81 /** Buffer that we should use for gain automation */
82 gain_t* _gain_automation_buffer;
89 #endif // __ardour_amp_h__