diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2016-01-12 14:09:24 -0500 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2016-01-18 12:11:08 -0500 |
commit | d1033819bd09d8a46ec602a586ddba0e10f803d6 (patch) | |
tree | 700a2d051b17f9f9b617166a158909b62045cffe /libs/ardour/amp.cc | |
parent | 19af86ece2d40729348b6ae6cb73d4e370115040 (diff) |
change ownership of the AutomationControl used by Amp.
It used to be owned by Amp. Now it is owned by Amp's owner
Diffstat (limited to 'libs/ardour/amp.cc')
-rw-r--r-- | libs/ardour/amp.cc | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/libs/ardour/amp.cc b/libs/ardour/amp.cc index 924a77e666..1d4ffc1cd7 100644 --- a/libs/ardour/amp.cc +++ b/libs/ardour/amp.cc @@ -38,23 +38,18 @@ using namespace PBD; // used for low-pass filter denormal protection #define GAIN_COEFF_TINY (1e-10) // -200dB -Amp::Amp (Session& s, std::string type) +Amp::Amp (Session& s, const std::string& name, boost::shared_ptr<AutomationControl> gc, bool control_midi_also) : Processor(s, "Amp") , _apply_gain(true) , _apply_gain_automation(false) , _current_gain(GAIN_COEFF_ZERO) , _current_automation_frame (INT64_MAX) + , _gain_control (gc) , _gain_automation_buffer(0) - , _type (type) - , _midi_amp (type != "trim") + , _midi_amp (control_midi_also) { - Evoral::Parameter p (_type == "trim" ? TrimAutomation : GainAutomation); - boost::shared_ptr<AutomationList> gl (new AutomationList (p)); - _gain_control = boost::shared_ptr<GainControl> (new GainControl ((_type == "trim") ? X_("trimcontrol") : X_("gaincontrol"), s, this, p, gl)); - _gain_control->set_flags (Controllable::GainLike); - - add_control(_gain_control); - set_display_name (_type == "trim" ? _("Trim") : _("Fader")); + set_display_name (name); + add_control (_gain_control); } bool @@ -375,8 +370,8 @@ XMLNode& Amp::state (bool full_state) { XMLNode& node (Processor::state (full_state)); - node.add_property("type", _type); - node.add_child_nocopy (_gain_control->get_state()); + node.add_property("type", _gain_control->parameter().type() == GainAutomation ? "amp" : "trim"); + node.add_child_nocopy (_gain_control->get_state()); return node; } @@ -395,6 +390,17 @@ Amp::set_state (const XMLNode& node, int version) return 0; } +Amp::GainControl::GainControl (Session& session, const Evoral::Parameter ¶m, boost::shared_ptr<AutomationList> al) + : AutomationControl (session, param, ParameterDescriptor(param), + al ? al : boost::shared_ptr<AutomationList> (new AutomationList (param)), + param.type() == GainAutomation ? X_("gaincontrol") : X_("trimcontrol")) { + + alist()->reset_default (1.0); + + lower_db = accurate_coefficient_to_dB (_desc.lower); + range_db = accurate_coefficient_to_dB (_desc.upper) - lower_db; +} + void Amp::GainControl::set_value (double val, PBD::Controllable::GroupControlDisposition /* group_override */) { @@ -407,7 +413,7 @@ void Amp::GainControl::set_value_unchecked (double val) { AutomationControl::set_value (std::max (std::min (val, (double)_desc.upper), (double)_desc.lower), Controllable::NoGroup); - _amp->session().set_dirty (); + _session.set_dirty (); } double |