diff options
author | Robin Gareus <robin@gareus.org> | 2015-04-24 21:44:52 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2015-04-24 22:37:03 +0200 |
commit | b07373fba2d1d0ad55ea2256b87a1256f3fcd887 (patch) | |
tree | 92b87c4de9294fad302a4ed38a97ffaf14979cbd /libs/ardour/amp.cc | |
parent | 6e66b0e9db35b4db6ea8167cc1b55e780e205512 (diff) |
Amp control: power-scale (fader) and dB-scale (knob)
Diffstat (limited to 'libs/ardour/amp.cc')
-rw-r--r-- | libs/ardour/amp.cc | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/libs/ardour/amp.cc b/libs/ardour/amp.cc index ac970fc581..f2381cdefb 100644 --- a/libs/ardour/amp.cc +++ b/libs/ardour/amp.cc @@ -34,17 +34,17 @@ using namespace ARDOUR; using namespace PBD; -using std::min; -Amp::Amp (Session& s) +Amp::Amp (Session& s, std::string type) : Processor(s, "Amp") , _apply_gain(true) , _apply_gain_automation(false) , _current_gain(GAIN_COEFF_UNITY) , _current_automation_frame (INT64_MAX) , _gain_automation_buffer(0) + , _type(type) { - Evoral::Parameter p (GainAutomation); + Evoral::Parameter p (_type == "trim" ? TrimAutomation : GainAutomation); boost::shared_ptr<AutomationList> gl (new AutomationList (p)); _gain_control = boost::shared_ptr<GainControl> (new GainControl (X_("gaincontrol"), s, this, p, gl)); _gain_control->set_flags (Controllable::GainLike); @@ -351,7 +351,7 @@ XMLNode& Amp::state (bool full_state) { XMLNode& node (Processor::state (full_state)); - node.add_property("type", "amp"); + node.add_property("type", _type); node.add_child_nocopy (_gain_control->get_state()); return node; @@ -374,20 +374,28 @@ Amp::set_state (const XMLNode& node, int version) void Amp::GainControl::set_value (double val) { - AutomationControl::set_value (min (val, (double) Config->get_max_gain())); + AutomationControl::set_value (std::max (std::min (val, (double)_desc.upper), (double)_desc.lower)); _amp->session().set_dirty (); } double Amp::GainControl::internal_to_interface (double v) const { - return gain_to_slider_position (v); + if (_desc.type == GainAutomation) { + return gain_to_slider_position (v); + } else { + return (accurate_coefficient_to_dB (v) - lower_db) / range_db; + } } double Amp::GainControl::interface_to_internal (double v) const { - return slider_position_to_gain (v); + if (_desc.type == GainAutomation) { + return slider_position_to_gain (v); + } else { + return dB_to_coefficient (lower_db + v * range_db); + } } double |