more work on the new all-Processor-all-The-Time redesign of Route - LOTS OF BREAKAGE...
[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
26 namespace ARDOUR {
27
28 class BufferSet;
29 class IO;
30
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, IO& io);
38
39         bool can_support_io_configuration (const ChanCount& in, ChanCount& out) const;
40         bool configure_io (ChanCount in, ChanCount out);
41         
42         void run_in_place (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes);
43
44         bool apply_gain() const  { return _apply_gain; }
45         void apply_gain(bool yn) { _apply_gain = yn; }
46
47         bool apply_gain_automation() const  { return _apply_gain_automation; }
48         void apply_gain_automation(bool yn) { _apply_gain_automation = yn; }
49
50         void muute(bool yn) { _mute = yn; }
51
52         void set_gain(float current, float desired) {
53                 _current_gain = current;
54                 _desired_gain = desired;
55         }
56         
57         void apply_mute(bool yn, float current=1.0, float desired=0.0) {
58                 _mute = yn;
59                 _current_mute_gain = current;
60                 _desired_mute_gain = desired;
61         }
62
63         XMLNode& state (bool full);
64
65         static void apply_gain (BufferSet& bufs, nframes_t nframes,
66                         gain_t initial, gain_t target, bool invert_polarity);
67
68         static void apply_simple_gain(BufferSet& bufs, nframes_t nframes, gain_t target);
69
70 private:
71         IO&   _io;
72         bool  _mute;
73         bool  _apply_gain;
74         bool  _apply_gain_automation;
75         float _current_gain;
76         float _desired_gain;
77         float _current_mute_gain;
78         float _desired_mute_gain;
79 };
80
81
82 } // namespace ARDOUR
83
84 #endif // __ardour_amp_h__