change ownership of the AutomationControl used by Amp.

It used to be owned by Amp. Now it is owned by Amp's owner
This commit is contained in:
Paul Davis 2016-01-12 14:09:24 -05:00
parent 19af86ece2
commit d1033819bd
11 changed files with 63 additions and 56 deletions

View File

@ -2027,7 +2027,8 @@ ProcessorBox::help_count_visible_prefader_processors (boost::weak_ptr<Processor>
)
) {
if (boost::dynamic_pointer_cast<Amp>(processor) && boost::dynamic_pointer_cast<Amp>(processor)->type() == X_("amp")) {
if (boost::dynamic_pointer_cast<Amp>(processor) &&
boost::dynamic_pointer_cast<Amp>(processor)->gain_control()->parameter().type() == GainAutomation) {
*amp_seen = true;
} else {
if (!*amp_seen) {
@ -2117,7 +2118,8 @@ ProcessorBox::setup_entry_positions ()
uint32_t num = 0;
for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
if (boost::dynamic_pointer_cast<Amp>((*i)->processor()) && boost::dynamic_pointer_cast<Amp>((*i)->processor())->type() == X_("amp")) {
if (boost::dynamic_pointer_cast<Amp>((*i)->processor()) &&
boost::dynamic_pointer_cast<Amp>((*i)->processor())->gain_control()->parameter().type() == GainAutomation) {
pre_fader = false;
(*i)->set_position (ProcessorEntry::Fader, num++);
} else {
@ -2689,7 +2691,7 @@ ProcessorBox::get_editor_window (boost::shared_ptr<Processor> processor, bool us
}
}
if (boost::dynamic_pointer_cast<Amp> (processor) && boost::dynamic_pointer_cast<Amp> (processor)->type() == X_("amp")) {
if (boost::dynamic_pointer_cast<Amp> (processor) && boost::dynamic_pointer_cast<Amp> (processor)->gain_control()->parameter().type() == GainAutomation) {
if (_parent_strip) {
_parent_strip->revert_to_default_display ();

View File

@ -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 &param, 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

View File

@ -36,13 +36,11 @@ class IO;
*/
class LIBARDOUR_API Amp : public Processor {
public:
Amp(Session& s, std::string type = "amp");
Amp(Session& s, const std::string& display_name, boost::shared_ptr<AutomationControl> control, bool control_midi_also);
std::string display_name () const { return _display_name; }
void set_display_name (const std::string& name) { _display_name = name; }
std::string type() const { return _type;}
bool visible () const;
bool can_support_io_configuration (const ChanCount& in, ChanCount& out);
@ -81,16 +79,8 @@ public:
/* automation */
struct GainControl : public AutomationControl {
GainControl (std::string name, Session& session, Amp* a, const Evoral::Parameter &param,
boost::shared_ptr<AutomationList> al = boost::shared_ptr<AutomationList>() )
: AutomationControl (session, param, ParameterDescriptor(param), al, name)
, _amp (a) {
set_flags (Controllable::Flag (flags() | Controllable::GainLike));
alist()->reset_default (1.0);
lower_db = accurate_coefficient_to_dB (_desc.lower);
range_db = accurate_coefficient_to_dB (_desc.upper) - lower_db;
}
GainControl (Session& session, const Evoral::Parameter &param,
boost::shared_ptr<AutomationList> al = boost::shared_ptr<AutomationList>());
void set_value (double val, PBD::Controllable::GroupControlDisposition group_override);
void set_value_unchecked (double);
@ -101,17 +91,17 @@ public:
double user_to_internal (double) const;
std::string get_user_string () const;
Amp* _amp;
double lower_db;
double range_db;
};
boost::shared_ptr<GainControl> gain_control() {
return _gain_control;
return boost::dynamic_pointer_cast<GainControl> (_gain_control);
}
boost::shared_ptr<const GainControl> gain_control() const {
return _gain_control;
return boost::dynamic_pointer_cast<GainControl> (_gain_control);
}
std::string value_as_string (boost::shared_ptr<AutomationControl>) const;
@ -125,11 +115,10 @@ private:
std::string _display_name;
boost::shared_ptr<GainControl> _gain_control;
boost::shared_ptr<AutomationControl> _gain_control;
/** Buffer that we should use for gain automation */
gain_t* _gain_automation_buffer;
std::string _type;
bool _midi_amp;
};

View File

@ -64,6 +64,7 @@ public:
protected:
bool _metering;
boost::shared_ptr<AutomationControl> _gain_control;
boost::shared_ptr<Amp> _amp;
boost::shared_ptr<PeakMeter> _meter;

View File

@ -675,7 +675,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<Amp> _amp;
boost::shared_ptr<AutomationControl> _trim_control;
boost::shared_ptr<Amp> _trim;
boost::shared_ptr<PeakMeter> _meter;
boost::shared_ptr<DelayLine> _delayline;

View File

@ -78,6 +78,7 @@ class LIBARDOUR_API Send : public Delivery
protected:
bool _metering;
boost::shared_ptr<AutomationControl> _gain_control;
boost::shared_ptr<Amp> _amp;
boost::shared_ptr<PeakMeter> _meter;
boost::shared_ptr<DelayLine> _delayline;

View File

@ -449,19 +449,9 @@ Automatable::control_factory(const Evoral::Parameter& param)
warning << "PluginPropertyAutomation for non-Plugin" << endl;
}
} else if (param.type() == GainAutomation) {
Amp* amp = dynamic_cast<Amp*>(this);
if (amp) {
control = new Amp::GainControl(X_("gaincontrol"), _a_session, amp, param);
} else {
warning << "GainAutomation for non-Amp" << endl;
}
control = new Amp::GainControl(_a_session, param);
} else if (param.type() == TrimAutomation) {
Amp* amp = dynamic_cast<Amp*>(this);
if (amp) {
control = new Amp::GainControl(X_("trimcontrol"), _a_session, amp, param);
} else {
warning << "TrimAutomation for non-Amp" << endl;
}
control = new Amp::GainControl(_a_session, param);
} else if (param.type() == PanAzimuthAutomation || param.type() == PanWidthAutomation || param.type() == PanElevationAutomation) {
Pannable* pannable = dynamic_cast<Pannable*>(this);
if (pannable) {

View File

@ -49,7 +49,11 @@ Return::Return (Session& s, bool internal)
{
/* never muted */
_amp.reset (new Amp (_session));
boost::shared_ptr<AutomationList> gl (new AutomationList (Evoral::Parameter (GainAutomation)));
_gain_control = boost::shared_ptr<Amp::GainControl> (new Amp::GainControl (_session, Evoral::Parameter (GainAutomation), gl));
add_control (_gain_control);
_amp.reset (new Amp (_session, X_("Fader"), _gain_control, true));
_meter.reset (new PeakMeter (_session, name()));
}
@ -159,4 +163,3 @@ Return::configure_io (ChanCount in, ChanCount out)
return true;
}

View File

@ -171,7 +171,11 @@ Route::init ()
/* add amp processor */
_amp.reset (new Amp (_session));
boost::shared_ptr<AutomationList> gl (new AutomationList (Evoral::Parameter (GainAutomation)));
_gain_control = boost::shared_ptr<Amp::GainControl> (new Amp::GainControl (_session, Evoral::Parameter(GainAutomation), gl));
add_control (_gain_control);
_amp.reset (new Amp (_session, X_("Fader"), _gain_control, true));
add_processor (_amp, PostFader);
if (is_monitor ()) {
@ -179,7 +183,12 @@ Route::init ()
}
/* and input trim */
_trim.reset (new Amp (_session, "trim"));
boost::shared_ptr<AutomationList> tl (new AutomationList (Evoral::Parameter (TrimAutomation)));
_trim_control = boost::shared_ptr<Amp::GainControl> (new Amp::GainControl (_session, Evoral::Parameter(TrimAutomation), tl));
add_control (_trim_control);
_trim.reset (new Amp (_session, X_("Trim"), _trim_control, false));
_trim->set_display_to_user (false);
if (dynamic_cast<AudioTrack*>(this)) {

View File

@ -86,13 +86,15 @@ Send::Send (Session& s, boost::shared_ptr<Pannable> p, boost::shared_ptr<MuteMas
//boost_debug_shared_ptr_mark_interesting (this, "send");
_amp.reset (new Amp (_session));
boost::shared_ptr<AutomationList> gl (new AutomationList (Evoral::Parameter (GainAutomation)));
_gain_control = boost::shared_ptr<Amp::GainControl> (new Amp::GainControl (_session, Evoral::Parameter(GainAutomation), gl));
add_control (_gain_control);
_amp.reset (new Amp (_session, _("Fader"), _gain_control, true));
_meter.reset (new PeakMeter (_session, name()));
_delayline.reset (new DelayLine (_session, name()));
add_control (_amp->gain_control ());
if (panner_shell()) {
panner_shell()->Changed.connect_same_thread (*this, boost::bind (&Send::panshell_changed, this));
}
@ -400,5 +402,3 @@ Send::value_as_string (boost::shared_ptr<AutomationControl> ac) const
{
return _amp->value_as_string (ac);
}

View File

@ -733,8 +733,12 @@ void
Session::setup_click ()
{
_clicking = false;
boost::shared_ptr<AutomationList> gl (new AutomationList (Evoral::Parameter (GainAutomation)));
boost::shared_ptr<AutomationControl> gain_control = boost::shared_ptr<Amp::GainControl> (new Amp::GainControl (*this, Evoral::Parameter(GainAutomation), gl));
_click_io.reset (new ClickIO (*this, X_("Click")));
_click_gain.reset (new Amp (*this));
_click_gain.reset (new Amp (*this, _("Fader"), gain_control, true));
_click_gain->activate ();
if (state_tree) {
setup_click_state (state_tree->root());