save/restore monitor processor state; key handling in torn off monitor section window
[ardour.git] / libs / ardour / ardour / monitor_processor.h
1 /*
2     Copyright (C) 2010 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef __ardour_monitor_processor_h__
21 #define __ardour_monitor_processor_h__
22
23 #include <vector>
24
25 #include "pbd/signals.h"
26
27 #include "ardour/types.h"
28 #include "ardour/processor.h"
29
30 class XMLNode;
31
32 namespace ARDOUR {
33
34 class Session;
35
36 class MonitorProcessor : public Processor
37 {
38   public:
39         MonitorProcessor (Session&);
40         MonitorProcessor (Session&, const XMLNode& name);
41
42         bool display_to_user() const;
43
44         void run (BufferSet& /*bufs*/, sframes_t /*start_frame*/, sframes_t /*end_frame*/, nframes_t /*nframes*/, bool /*result_required*/);
45
46         XMLNode& state (bool full);
47         int set_state (const XMLNode&, int /* version */);
48
49         bool configure_io (ChanCount in, ChanCount out);
50         bool can_support_io_configuration (const ChanCount& in, ChanCount& out) const;
51
52         void set_cut_all (bool);
53         void set_dim_all (bool);
54         void set_polarity (uint32_t, bool invert);
55         void set_cut (uint32_t, bool cut);
56         void set_dim (uint32_t, bool dim);
57         void set_solo (uint32_t, bool);
58         void set_mono (bool);
59
60         void set_dim_level (gain_t);
61         void set_solo_boost_level (gain_t);
62
63         gain_t dim_level() const { return _dim_level; }
64         gain_t solo_boost_level() const { return _solo_boost_level; }
65
66         bool dimmed (uint32_t chn) const;
67         bool soloed (uint32_t chn) const;
68         bool inverted (uint32_t chn) const;
69         bool cut (uint32_t chn) const;
70         bool cut_all () const;
71         bool dim_all () const;
72         bool mono () const;
73
74         PBD::Signal0<void> Changed;
75         
76   private:
77         struct ChannelRecord { 
78             gain_t current_gain;
79             gain_t cut;
80             bool   dim;
81             gain_t polarity;
82             bool   soloed;
83
84             ChannelRecord () 
85             : current_gain(1.0), cut(1.0), dim(false), polarity(1.0), soloed (false) {}
86         };
87
88         std::vector<ChannelRecord> _channels;
89
90         uint32_t             solo_cnt;
91         bool                _dim_all;
92         bool                _cut_all;
93         bool                _mono;
94         volatile gain_t     _dim_level;
95         volatile gain_t     _solo_boost_level;
96
97         void allocate_channels (uint32_t);
98 };
99
100 } /* namespace */
101
102 #endif /* __ardour_monitor_processor_h__ */