18c50e51043293af9ff045a2bf081dec2c2544dc
[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
41         bool display_to_user() const;
42
43         void run (BufferSet& /*bufs*/, sframes_t /*start_frame*/, sframes_t /*end_frame*/, nframes_t /*nframes*/, bool /*result_required*/);
44
45         XMLNode& state (bool full);
46         int set_state (const XMLNode&, int /* version */);
47
48         bool configure_io (ChanCount in, ChanCount out);
49         bool can_support_io_configuration (const ChanCount& in, ChanCount& out) const;
50
51         void set_cut_all (bool);
52         void set_dim_all (bool);
53         void set_polarity (uint32_t, bool invert);
54         void set_cut (uint32_t, bool cut);
55         void set_dim (uint32_t, bool dim);
56         void set_solo (uint32_t, bool);
57         void set_mono (bool);
58
59         void set_dim_level (gain_t);
60         void set_solo_boost_level (gain_t);
61
62         gain_t dim_level() const { return _dim_level; }
63         gain_t solo_boost_level() const { return _solo_boost_level; }
64
65         bool dimmed (uint32_t chn) const;
66         bool soloed (uint32_t chn) const;
67         bool inverted (uint32_t chn) const;
68         bool cut (uint32_t chn) const;
69         bool cut_all () const;
70         bool dim_all () const;
71         bool mono () const;
72
73         PBD::Signal0<void> Changed;
74         
75   private:
76         struct ChannelRecord { 
77             gain_t current_gain;
78             gain_t cut;
79             bool   dim;
80             gain_t polarity;
81             bool   soloed;
82
83             ChannelRecord () 
84             : current_gain(1.0), cut(1.0), dim(false), polarity(1.0), soloed (false) {}
85         };
86
87         std::vector<ChannelRecord> _channels;
88
89         uint32_t             solo_cnt;
90         bool                _dim_all;
91         bool                _cut_all;
92         bool                _mono;
93         volatile gain_t     _dim_level;
94         volatile gain_t     _solo_boost_level;
95
96         void allocate_channels (uint32_t);
97 };
98
99 } /* namespace */
100
101 #endif /* __ardour_monitor_processor_h__ */