/* 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()) {
if (_route && _route->amp() == _amp) {
_route->set_gain (value, this);
} else {
- _amp->set_gain (value, this);
+ _amp->gain_control()->set_value (value, Controllable::NoGroup);
}
}
}
}
-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)
{
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;
}
#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"
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;
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:
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);
}
}
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:
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;
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;
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) {
{
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);
}
}
/* 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));
/* 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));
}
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
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
}
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);
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);
}
{
}
+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)
{
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>
} 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") {
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;
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;