summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk2_ardour/gain_meter.cc6
-rw-r--r--libs/ardour/amp.cc19
-rw-r--r--libs/ardour/ardour/amp.h6
-rw-r--r--libs/ardour/ardour/route.h37
-rw-r--r--libs/ardour/audio_track.cc2
-rw-r--r--libs/ardour/internal_send.cc4
-rw-r--r--libs/ardour/route.cc65
-rw-r--r--libs/ardour/session_state.cc2
-rw-r--r--libs/surfaces/osc/osc.cc4
9 files changed, 77 insertions, 68 deletions
diff --git a/gtk2_ardour/gain_meter.cc b/gtk2_ardour/gain_meter.cc
index 4a7e75fcf7..7fa9bf88de 100644
--- a/gtk2_ardour/gain_meter.cc
+++ b/gtk2_ardour/gain_meter.cc
@@ -470,10 +470,10 @@ GainMeterBase::gain_activated ()
/* clamp to displayable values */
if (_data_type == DataType::AUDIO) {
f = min (f, 6.0f);
- _amp->set_gain (dB_to_coefficient(f), this);
+ _amp->gain_control()->set_value (dB_to_coefficient(f), Controllable::NoGroup);
} else {
f = min (fabs (f), 2.0f);
- _amp->set_gain (f, this);
+ _amp->gain_control()->set_value (f, Controllable::NoGroup);
}
if (gain_display.has_focus()) {
@@ -534,7 +534,7 @@ GainMeterBase::gain_adjusted ()
if (_route && _route->amp() == _amp) {
_route->set_gain (value, this);
} else {
- _amp->set_gain (value, this);
+ _amp->gain_control()->set_value (value, Controllable::NoGroup);
}
}
diff --git a/libs/ardour/amp.cc b/libs/ardour/amp.cc
index 8dac6d73fc..49570bb511 100644
--- a/libs/ardour/amp.cc
+++ b/libs/ardour/amp.cc
@@ -348,25 +348,6 @@ Amp::apply_simple_gain (AudioBuffer& buf, framecnt_t nframes, gain_t target)
}
}
-void
-Amp::inc_gain (gain_t factor, void *src)
-{
- float desired_gain = _gain_control->user_double();
-
- if (fabsf (desired_gain) < GAIN_COEFF_SMALL) {
- // really?! what's the idea here?
- set_gain (0.000001f + (0.000001f * factor), src);
- } else {
- set_gain (desired_gain + (desired_gain * factor), src);
- }
-}
-
-void
-Amp::set_gain (gain_t val, void *)
-{
- _gain_control->set_value (val, Controllable::NoGroup);
-}
-
XMLNode&
Amp::state (bool full_state)
{
diff --git a/libs/ardour/ardour/amp.h b/libs/ardour/ardour/amp.h
index bd4c8b1259..673ec2e3c3 100644
--- a/libs/ardour/ardour/amp.h
+++ b/libs/ardour/ardour/amp.h
@@ -70,14 +70,10 @@ public:
static void declick (BufferSet& bufs, framecnt_t nframes, int dir);
- gain_t gain () const { return _gain_control->get_value(); }
-
- void set_gain (gain_t g, void *src);
- void inc_gain (gain_t delta, void *src);
+ gain_t gain () const { return _gain_control->get_value(); }
static void update_meters();
-
boost::shared_ptr<AutomationControl> gain_control() {
return _gain_control;
}
diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h
index 9a0cf9ee0b..a57610ab98 100644
--- a/libs/ardour/ardour/route.h
+++ b/libs/ardour/ardour/route.h
@@ -41,6 +41,7 @@
#include "pbd/destructible.h"
#include "ardour/ardour.h"
+#include "ardour/gain_control.h"
#include "ardour/instrument_info.h"
#include "ardour/io.h"
#include "ardour/libardour_visibility.h"
@@ -145,7 +146,6 @@ class LIBARDOUR_API Route : public SessionObject, public Automatable, public Rou
void inc_gain (gain_t delta, void *src);
void set_trim (gain_t val, void *src);
- void inc_trim (gain_t delta, void *src);
void set_mute_points (MuteMaster::MutePoint);
MuteMaster::MutePoint mute_points () const;
@@ -381,7 +381,9 @@ class LIBARDOUR_API Route : public SessionObject, public Automatable, public Rou
void clear_fed_by ();
bool add_fed_by (boost::shared_ptr<Route>, bool sends_only);
- /* Controls (not all directly owned by the Route */
+ /* Controls (not all directly owned by the Route) */
+
+ boost::shared_ptr<AutomationControl> get_control (const Evoral::Parameter& param);
class RouteAutomationControl : public AutomationControl {
public:
@@ -393,7 +395,7 @@ class LIBARDOUR_API Route : public SessionObject, public Automatable, public Rou
void set_value (double val, PBD::Controllable::GroupControlDisposition group_override) {
boost::shared_ptr<Route> r = _route.lock();
if (r) {
- r->set_control (*this, val, group_override);
+ r->set_control ((AutomationType) parameter().type(), val, group_override);
}
}
@@ -407,7 +409,28 @@ class LIBARDOUR_API Route : public SessionObject, public Automatable, public Rou
boost::weak_ptr<Route> _route;
};
- boost::shared_ptr<AutomationControl> get_control (const Evoral::Parameter& param);
+ class GainControllable : public GainControl {
+ public:
+ GainControllable (Session& session,
+ AutomationType type,
+ boost::shared_ptr<Route> route);
+
+ void set_value (double val, PBD::Controllable::GroupControlDisposition group_override) {
+ boost::shared_ptr<Route> r = _route.lock();
+ if (r) {
+ r->set_control ((AutomationType) parameter().type(), val, group_override);
+ }
+ }
+
+ protected:
+ friend class Route;
+
+ void route_set_value (double val) {
+ GainControl::set_value (val, Controllable::NoGroup);
+ }
+
+ boost::weak_ptr<Route> _route;
+ };
class SoloControllable : public RouteAutomationControl {
public:
@@ -442,7 +465,7 @@ class LIBARDOUR_API Route : public SessionObject, public Automatable, public Rou
uint32_t _current_phase;
};
- void set_control (RouteAutomationControl&, double val, PBD::Controllable::GroupControlDisposition group_override);
+ void set_control (AutomationType, double val, PBD::Controllable::GroupControlDisposition group_override);
boost::shared_ptr<SoloControllable> solo_control() const {
return _solo_control;
@@ -675,9 +698,9 @@ class LIBARDOUR_API Route : public SessionObject, public Automatable, public Rou
virtual void maybe_declick (BufferSet&, framecnt_t, int);
- boost::shared_ptr<AutomationControl> _gain_control;
+ boost::shared_ptr<GainControllable> _gain_control;
boost::shared_ptr<Amp> _amp;
- boost::shared_ptr<AutomationControl> _trim_control;
+ boost::shared_ptr<GainControllable> _trim_control;
boost::shared_ptr<Amp> _trim;
boost::shared_ptr<PeakMeter> _meter;
boost::shared_ptr<DelayLine> _delayline;
diff --git a/libs/ardour/audio_track.cc b/libs/ardour/audio_track.cc
index 5e4a3bf236..f5d5207cc6 100644
--- a/libs/ardour/audio_track.cc
+++ b/libs/ardour/audio_track.cc
@@ -166,7 +166,7 @@ AudioTrack::deprecated_use_diskstream_connections ()
diskstream->deprecated_io_node = 0;
if ((prop = node.property ("gain")) != 0) {
- _amp->set_gain (atof (prop->value().c_str()), this);
+ _amp->gain_control()->set_value (atof (prop->value().c_str()), PBD::Controllable::NoGroup);
}
if ((prop = node.property ("input-connection")) != 0) {
diff --git a/libs/ardour/internal_send.cc b/libs/ardour/internal_send.cc
index 60de2087f3..8870535939 100644
--- a/libs/ardour/internal_send.cc
+++ b/libs/ardour/internal_send.cc
@@ -74,10 +74,10 @@ InternalSend::init_gain ()
{
if (_role == Listen) {
/* send to monitor bus is always at unity */
- _amp->set_gain (GAIN_COEFF_UNITY, this);
+ _gain_control->set_value (GAIN_COEFF_UNITY, PBD::Controllable::NoGroup);
} else {
/* aux sends start at -inf dB */
- _amp->set_gain (GAIN_COEFF_ZERO, this);
+ _gain_control->set_value (GAIN_COEFF_ZERO, PBD::Controllable::NoGroup);
}
}
diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc
index 16efc35a8c..a23af603de 100644
--- a/libs/ardour/route.cc
+++ b/libs/ardour/route.cc
@@ -172,8 +172,7 @@ Route::init ()
/* add amp processor */
- boost::shared_ptr<AutomationList> gl (new AutomationList (Evoral::Parameter (GainAutomation)));
- _gain_control = boost::shared_ptr<GainControl> (new GainControl (_session, Evoral::Parameter(GainAutomation), gl));
+ _gain_control = boost::shared_ptr<GainControllable> (new GainControllable (_session, GainAutomation, shared_from_this ()));
add_control (_gain_control);
_amp.reset (new Amp (_session, X_("Fader"), _gain_control, true));
@@ -185,8 +184,7 @@ Route::init ()
/* and input trim */
- boost::shared_ptr<AutomationList> tl (new AutomationList (Evoral::Parameter (TrimAutomation)));
- _trim_control = boost::shared_ptr<GainControl> (new GainControl (_session, Evoral::Parameter(TrimAutomation), tl));
+ _trim_control = boost::shared_ptr<GainControllable> (new GainControllable (_session, TrimAutomation, shared_from_this ()));
add_control (_trim_control);
_trim.reset (new Amp (_session, X_("Trim"), _trim_control, false));
@@ -389,9 +387,20 @@ Route::ensure_track_or_route_name(string name, Session &session)
}
void
-Route::inc_gain (gain_t fraction, void *src)
+Route::inc_gain (gain_t factor, void *src)
{
- _amp->inc_gain (fraction, src);
+ /* To be used ONLY when doing group-relative gain adjustment, from
+ * ::set_gain()
+ */
+
+ float desired_gain = _gain_control->user_double();
+
+ if (fabsf (desired_gain) < GAIN_COEFF_SMALL) {
+ // really?! what's the idea here?
+ _gain_control->route_set_value (0.000001f + (0.000001f * factor));
+ } else {
+ _gain_control->route_set_value (desired_gain + (desired_gain * factor));
+ }
}
void
@@ -442,24 +451,18 @@ Route::set_gain (gain_t val, void *src)
return;
}
- if (val == _amp->gain()) {
+ if (val == _gain_control->get_value()) {
return;
}
- _amp->set_gain (val, src);
-}
-
-void
-Route::inc_trim (gain_t fraction, void *src)
-{
- _trim->inc_gain (fraction, src);
+ _gain_control->route_set_value (val);
}
void
Route::set_trim (gain_t val, void * /* src */)
{
// TODO route group, see set_gain()
- _trim->set_gain (val, 0);
+ _trim_control->route_set_value (val);
}
void
@@ -3891,17 +3894,23 @@ Route::set_latency_compensation (framecnt_t longest_session_latency)
}
void
-Route::set_control (RouteAutomationControl& control, double val, PBD::Controllable::GroupControlDisposition /*group_override*/)
+Route::set_control (AutomationType type, double val, PBD::Controllable::GroupControlDisposition /*group_override*/)
{
boost::shared_ptr<RouteList> rl;
- switch (control.parameter().type()) {
+ switch (type) {
case GainAutomation:
/* route must mediate group control */
set_gain (val, this); /* any "src" argument will do other than our route group */
return;
break;
+ case TrimAutomation:
+ /* route must mediate group control */
+ set_trim (val, this); /* any "src" argument will do other than our route group */
+ return;
+ break;
+
case RecEnableAutomation:
/* session must mediate group control */
rl.reset (new RouteList);
@@ -3931,19 +3940,12 @@ Route::set_control (RouteAutomationControl& control, double val, PBD::Controllab
return;
break;
- case PanAzimuthAutomation:
- case PanElevationAutomation:
- case PanWidthAutomation:
- case PanFrontBackAutomation:
- case PanLFEAutomation:
- break;
-
default:
/* Not a route automation control */
+ fatal << string_compose (_("programming error: %1%2\n"), X_("illegal type of route automation control passed to Route::set_control(): "), enum_2_string(type)) << endmsg;
+ /*NOTREACHED*/
return;
}
-
- control.route_set_value (val);
}
@@ -3958,6 +3960,13 @@ Route::RouteAutomationControl::RouteAutomationControl (const std::string& name,
{
}
+Route::GainControllable::GainControllable (Session& s, AutomationType atype, boost::shared_ptr<Route> r)
+ : GainControl (s, Evoral::Parameter(atype))
+ , _route (r)
+{
+
+}
+
Route::SoloControllable::SoloControllable (std::string name, boost::shared_ptr<Route> r)
: RouteAutomationControl (name, SoloAutomation, boost::shared_ptr<AutomationList>(), r)
{
@@ -4436,13 +4445,13 @@ Route::panner_shell() const
boost::shared_ptr<AutomationControl>
Route::gain_control() const
{
- return _amp->gain_control();
+ return _gain_control;
}
boost::shared_ptr<AutomationControl>
Route::trim_control() const
{
- return _trim->gain_control();
+ return _trim_control;
}
boost::shared_ptr<AutomationControl>
diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc
index bde7208867..13d1413b19 100644
--- a/libs/ardour/session_state.cc
+++ b/libs/ardour/session_state.cc
@@ -3740,7 +3740,7 @@ Session::config_changed (std::string p, bool ours)
} else if (p == "click-gain") {
if (_click_gain) {
- _click_gain->set_gain (Config->get_click_gain(), this);
+ _click_gain->gain_control()->set_value (Config->get_click_gain(), Controllable::NoGroup);
}
} else if (p == "send-mtc") {
diff --git a/libs/surfaces/osc/osc.cc b/libs/surfaces/osc/osc.cc
index f245a65ad3..31fd146a5f 100644
--- a/libs/surfaces/osc/osc.cc
+++ b/libs/surfaces/osc/osc.cc
@@ -1109,7 +1109,7 @@ OSC::route_set_send_gain_abs (int rid, int sid, float val)
boost::shared_ptr<Amp> a = s->amp();
if (a) {
- a->set_gain (val, this);
+ a->gain_control()->set_value (val, PBD::Controllable::NoGroup);
}
}
return 0;
@@ -1141,7 +1141,7 @@ OSC::route_set_send_gain_dB (int rid, int sid, float val)
boost::shared_ptr<Amp> a = s->amp();
if (a) {
- a->set_gain (dB_to_coefficient (val), this);
+ a->gain_control()->set_value (dB_to_coefficient (val), PBD::Controllable::NoGroup);
}
}
return 0;