MonitorProcessor::MonitorProcessor (Session& s)
: Processor (s, X_("MonitorOut"))
, solo_cnt (0)
MonitorProcessor::MonitorProcessor (Session& s)
: Processor (s, X_("MonitorOut"))
, solo_cnt (0)
, _dim_all_ptr (new MPControl<bool> (false, _("monitor dim"), Controllable::Toggle))
, _cut_all_ptr (new MPControl<bool> (false, _("monitor cut"), Controllable::Toggle))
, _mono_ptr (new MPControl<bool> (false, _("monitor mono"), Controllable::Toggle))
, _dim_all_ptr (new MPControl<bool> (false, _("monitor dim"), Controllable::Toggle))
, _cut_all_ptr (new MPControl<bool> (false, _("monitor cut"), Controllable::Toggle))
, _mono_ptr (new MPControl<bool> (false, _("monitor mono"), Controllable::Toggle))
- (dB_to_coefficient(-12.0), _("monitor dim level"), Controllable::Flag (0),
+ (dB_to_coefficient(-12.0), _("monitor dim level"), Controllable::Flag (0),
- (dB_to_coefficient(0.0), _("monitor solo boost level"), Controllable::Flag (0),
+ (dB_to_coefficient(0.0), _("monitor solo boost level"), Controllable::Flag (0),
dB_to_coefficient(0.0), dB_to_coefficient(10.0)))
, _dim_all_control (_dim_all_ptr)
, _cut_all_control (_cut_all_ptr)
dB_to_coefficient(0.0), dB_to_coefficient(10.0)))
, _dim_all_control (_dim_all_ptr)
, _cut_all_control (_cut_all_ptr)
- if ((prop = node.property (X_("dim-level"))) != 0) {
- gain_t val = atof (prop->value());
+ // need to check that these conversions are working as expected
+ gain_t val;
+ if (node.get_property (X_("dim-level"), val)) {
}
for (XMLNodeList::const_iterator i = node.children().begin(); i != node.children().end(); ++i) {
if ((*i)->name() == X_("Channel")) {
}
for (XMLNodeList::const_iterator i = node.children().begin(); i != node.children().end(); ++i) {
if ((*i)->name() == X_("Channel")) {
-
- if (sscanf (prop->value().c_str(), "%u", &chn) != 1) {
- error << string_compose (X_("programming error: %1"), X_("MonitorProcessor XML settings has an unreadable channel ID"))
+ if (!(*i)->get_property (X_("id"), chn)) {
+ error << string_compose (X_("programming error: %1"), X_("MonitorProcessor XML settings are missing an ID"))
- if ((prop = (*i)->property ("cut")) != 0) {
- if (string_is_affirmative (prop->value())){
- cr.cut = 0.0f;
+ bool gain_coeff_zero;
+ if ((*i)->get_property ("cut", gain_coeff_zero)) {
+ if (gain_coeff_zero) {
+ cr.cut = GAIN_COEFF_ZERO;
- node.add_property (X_("type"), X_("monitor"));
-
- snprintf (buf, sizeof(buf), "%.12g", _dim_level.val());
- node.add_property (X_("dim-level"), buf);
+ node.set_property (X_("type"), X_("monitor"));
- snprintf (buf, sizeof(buf), "%.12g", _solo_boost_level.val());
- node.add_property (X_("solo-boost-level"), buf);
+ node.set_property (X_ ("dim-level"), (float)_dim_level.val ());
+ node.set_property (X_ ("solo-boost-level"), (float)_solo_boost_level.val ());
- node.add_property (X_("cut-all"), (_cut_all ? "yes" : "no"));
- node.add_property (X_("dim-all"), (_dim_all ? "yes" : "no"));
- node.add_property (X_("mono"), (_mono ? "yes" : "no"));
+ node.set_property (X_("cut-all"), _cut_all.val());
+ node.set_property (X_("dim-all"), _dim_all.val());
+ node.set_property (X_("mono"), _mono.val());
- snprintf (buf, sizeof (buf), "%u", chn);
- chn_node->add_property ("id", buf);
+ // implicitly cast these to bool
+ chn_node->set_property (X_("cut"), (*x)->cut != GAIN_COEFF_UNITY);
+ chn_node->set_property (X_("invert"), (*x)->polarity != GAIN_COEFF_UNITY);
+ chn_node->set_property (X_("dim"), (*x)->dim == true);
+ chn_node->set_property (X_("solo"), (*x)->soloed == true);
- chn_node->add_property (X_("cut"), (*x)->cut == 1.0f ? "no" : "yes");
- chn_node->add_property (X_("invert"), (*x)->polarity == 1.0f ? "no" : "yes");
- chn_node->add_property (X_("dim"), (*x)->dim ? "yes" : "no");
- chn_node->add_property (X_("solo"), (*x)->soloed ? "yes" : "no");
+ node.add_child_nocopy (*chn_node);
+ }
-MonitorProcessor::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /*end_frame*/, pframes_t nframes, bool /*result_required*/)
+MonitorProcessor::run (BufferSet& bufs, samplepos_t /*start_sample*/, samplepos_t /*end_sample*/, double /*speed*/, pframes_t nframes, bool /*result_required*/)
- gain_t global_cut = (_cut_all ? 0.0f : 1.0f);
- gain_t global_dim = (_dim_all ? dim_level_this_time : 1.0);
+ gain_t global_cut = (_cut_all ? GAIN_COEFF_ZERO : GAIN_COEFF_UNITY);
+ gain_t global_dim = (_dim_all ? dim_level_this_time : GAIN_COEFF_UNITY);
}
for (BufferSet::audio_iterator b = bufs.audio_begin(); b != bufs.audio_end(); ++b) {
/* don't double-scale by both track dim and global dim coefficients */
}
for (BufferSet::audio_iterator b = bufs.audio_begin(); b != bufs.audio_end(); ++b) {
/* don't double-scale by both track dim and global dim coefficients */
if (_channels[chn]->soloed) {
target_gain = _channels[chn]->polarity * _channels[chn]->cut * dim_level * global_cut * global_dim * solo_boost;
} else {
if (solo_cnt == 0) {
target_gain = _channels[chn]->polarity * _channels[chn]->cut * dim_level * global_cut * global_dim * solo_boost;
} else {
if (_channels[chn]->soloed) {
target_gain = _channels[chn]->polarity * _channels[chn]->cut * dim_level * global_cut * global_dim * solo_boost;
} else {
if (solo_cnt == 0) {
target_gain = _channels[chn]->polarity * _channels[chn]->cut * dim_level * global_cut * global_dim * solo_boost;
} else {
- Amp::apply_gain (*b, nframes, _channels[chn]->current_gain, target_gain);
- _channels[chn]->current_gain = target_gain;
+ _channels[chn]->current_gain = Amp::apply_gain (*b, _session.nominal_sample_rate(), nframes, _channels[chn]->current_gain, target_gain);
- if (invert) {
- _channels[chn]->polarity = -1.0f;
- } else {
- _channels[chn]->polarity = 1.0f;
- }
+ if (invert) {
+ _channels[chn]->polarity = -1.0f;
+ } else {
+ _channels[chn]->polarity = 1.0f;
+ }
+ update_monitor_state ();
- if (yn) {
- _channels[chn]->cut = 0.0f;
- } else {
- _channels[chn]->cut = 1.0f;
- }
+ if (yn) {
+ _channels[chn]->cut = GAIN_COEFF_ZERO;
+ } else {
+ _channels[chn]->cut = GAIN_COEFF_UNITY;
+ }
+ update_monitor_state ();
- if (solo != _channels[chn]->soloed) {
- _channels[chn]->soloed = solo;
-
- if (solo) {
- solo_cnt++;
- } else {
- if (solo_cnt > 0) {
- solo_cnt--;
- }
- }
- }
+ if (solo != _channels[chn]->soloed) {
+ _channels[chn]->soloed = solo;
+
+ if (solo) {
+ solo_cnt++;
+ } else {
+ if (solo_cnt > 0) {
+ solo_cnt--;
+ }
+ }
+ }
+ update_monitor_state ();
+void
+MonitorProcessor::update_monitor_state ()
+{
+ bool en = false;
+
+ if (_cut_all || _dim_all || _mono) {
+ en = true;
+ }
+
+ const uint32_t nchans = _channels.size();
+ for (uint32_t i = 0; i < nchans && !en; ++i) {
+ if (cut (i) || dimmed (i) || soloed (i) || inverted (i)) {
+ en = true;
+ break;
+ }
+ }
+
+ if (_monitor_active != en) {
+ _monitor_active = en;
+ _session.MonitorChanged();
+ }
+}
+
, cut_ptr (new MPControl<gain_t> (1.0, string_compose (_("cut control %1"), chn), PBD::Controllable::GainLike))
, dim_ptr (new MPControl<bool> (false, string_compose (_("dim control"), chn), PBD::Controllable::Toggle))
, polarity_ptr (new MPControl<gain_t> (1.0, string_compose (_("polarity control"), chn), PBD::Controllable::Toggle, -1, 1))
, cut_ptr (new MPControl<gain_t> (1.0, string_compose (_("cut control %1"), chn), PBD::Controllable::GainLike))
, dim_ptr (new MPControl<bool> (false, string_compose (_("dim control"), chn), PBD::Controllable::Toggle))
, polarity_ptr (new MPControl<gain_t> (1.0, string_compose (_("polarity control"), chn), PBD::Controllable::Toggle, -1, 1))