3 #include "ardour/amp.h"
5 #include "ardour/monitor_processor.h"
6 #include "ardour/session.h"
10 using namespace ARDOUR;
13 MonitorProcessor::MonitorProcessor (Session& s)
14 : Processor (s, X_("MonitorOut"))
20 _solo_boost_level = 1.0;
23 MonitorProcessor::MonitorProcessor (Session& s, const XMLNode& node)
26 set_state (node, Stateful::loading_state_version);
30 MonitorProcessor::set_state (const XMLNode& node, int version)
32 return Processor::set_state (node, version);
36 MonitorProcessor::state (bool full)
38 XMLNode& node (Processor::state (full));
40 /* this replaces any existing "type" property */
42 node.add_property (X_("type"), X_("monitor"));
48 MonitorProcessor::run (BufferSet& bufs, sframes_t /*start_frame*/, sframes_t /*end_frame*/, nframes_t nframes, bool /*result_required*/)
52 gain_t dim_level_this_time = _dim_level;
53 gain_t global_cut = (_cut_all ? 0.0f : 1.0f);
54 gain_t global_dim = (_dim_all ? dim_level_this_time : 1.0f);
57 if (_session.listening() || _session.soloing()) {
58 solo_boost = _solo_boost_level;
63 for (BufferSet::audio_iterator b = bufs.audio_begin(); b != bufs.audio_end(); ++b) {
65 /* don't double-scale by both track dim and global dim coefficients */
67 gain_t dim_level = (global_dim == 1.0 ? (_dim[chn] ? dim_level_this_time : 1.0) : 1.0);
70 target_gain = _polarity[chn] * _cut[chn] * dim_level * global_cut * global_dim * solo_boost;
73 target_gain = _polarity[chn] * _cut[chn] * dim_level * global_cut * global_dim * solo_boost;
79 if (target_gain != current_gain[chn] || target_gain != 1.0f) {
81 Amp::apply_gain (*b, nframes, current_gain[chn], target_gain);
82 current_gain[chn] = target_gain;
90 MonitorProcessor::configure_io (ChanCount in, ChanCount out)
92 uint32_t needed = in.n_audio();
94 while (current_gain.size() > needed) {
95 current_gain.pop_back ();
98 _polarity.pop_back ();
100 if (_soloed.back()) {
109 while (current_gain.size() < needed) {
110 current_gain.push_back (1.0);
111 _dim.push_back (false);
112 _cut.push_back (1.0);
113 _polarity.push_back (1.0);
114 _soloed.push_back (false);
117 return Processor::configure_io (in, out);
121 MonitorProcessor::can_support_io_configuration (const ChanCount& in, ChanCount& out) const
127 MonitorProcessor::set_polarity (uint32_t chn, bool invert)
130 _polarity[chn] = -1.0f;
132 _polarity[chn] = 1.0f;
137 MonitorProcessor::set_dim (uint32_t chn, bool yn)
143 MonitorProcessor::set_cut (uint32_t chn, bool yn)
153 MonitorProcessor::set_solo (uint32_t chn, bool solo)
167 MonitorProcessor::set_cut_all (bool yn)
173 MonitorProcessor::set_dim_all (bool yn)
179 MonitorProcessor::display_to_user () const
185 MonitorProcessor::set_dim_level (gain_t val)
191 MonitorProcessor::set_solo_boost_level (gain_t val)
193 _solo_boost_level = val;
197 MonitorProcessor::soloed (uint32_t chn) const
204 MonitorProcessor::inverted (uint32_t chn) const
206 return _polarity[chn] < 0.0f;
211 MonitorProcessor::cut (uint32_t chn) const
213 return _cut[chn] == 0.0f;
217 MonitorProcessor::dimmed (uint32_t chn) const