move Amp::GainControl out into its own source module and out of Amp
This commit is contained in:
parent
d1033819bd
commit
55094b7237
|
@ -26,6 +26,7 @@
|
|||
#include "ardour/amp.h"
|
||||
#include "ardour/audio_buffer.h"
|
||||
#include "ardour/buffer_set.h"
|
||||
#include "ardour/gain_control.h"
|
||||
#include "ardour/midi_buffer.h"
|
||||
#include "ardour/rc_configuration.h"
|
||||
#include "ardour/session.h"
|
||||
|
@ -390,71 +391,6 @@ 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 */)
|
||||
{
|
||||
if (writable()) {
|
||||
set_value_unchecked (val);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Amp::GainControl::set_value_unchecked (double val)
|
||||
{
|
||||
AutomationControl::set_value (std::max (std::min (val, (double)_desc.upper), (double)_desc.lower), Controllable::NoGroup);
|
||||
_session.set_dirty ();
|
||||
}
|
||||
|
||||
double
|
||||
Amp::GainControl::internal_to_interface (double v) const
|
||||
{
|
||||
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
|
||||
{
|
||||
if (_desc.type == GainAutomation) {
|
||||
return slider_position_to_gain (v);
|
||||
} else {
|
||||
return dB_to_coefficient (lower_db + v * range_db);
|
||||
}
|
||||
}
|
||||
|
||||
double
|
||||
Amp::GainControl::internal_to_user (double v) const
|
||||
{
|
||||
return accurate_coefficient_to_dB (v);
|
||||
}
|
||||
|
||||
double
|
||||
Amp::GainControl::user_to_internal (double u) const
|
||||
{
|
||||
return dB_to_coefficient (u);
|
||||
}
|
||||
|
||||
std::string
|
||||
Amp::GainControl::get_user_string () const
|
||||
{
|
||||
char theBuf[32]; sprintf( theBuf, _("%3.1f dB"), accurate_coefficient_to_dB (get_value()));
|
||||
return std::string(theBuf);
|
||||
}
|
||||
|
||||
/** Write gain automation for this cycle into the buffer previously passed in to
|
||||
* set_gain_automation_buffer (if we are in automation playback mode and the
|
||||
* transport is rolling).
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
namespace ARDOUR {
|
||||
|
||||
class BufferSet;
|
||||
class GainControl;
|
||||
class IO;
|
||||
|
||||
/** Applies a declick operation to all audio inputs, passing the same number of
|
||||
|
@ -76,32 +77,13 @@ public:
|
|||
|
||||
static void update_meters();
|
||||
|
||||
/* automation */
|
||||
|
||||
struct GainControl : public AutomationControl {
|
||||
GainControl (Session& session, const Evoral::Parameter ¶m,
|
||||
boost::shared_ptr<AutomationList> al = boost::shared_ptr<AutomationList>());
|
||||
|
||||
void set_value (double val, PBD::Controllable::GroupControlDisposition group_override);
|
||||
void set_value_unchecked (double);
|
||||
|
||||
double internal_to_interface (double) const;
|
||||
double interface_to_internal (double) const;
|
||||
double internal_to_user (double) const;
|
||||
double user_to_internal (double) const;
|
||||
std::string get_user_string () const;
|
||||
|
||||
double lower_db;
|
||||
double range_db;
|
||||
};
|
||||
|
||||
|
||||
boost::shared_ptr<GainControl> gain_control() {
|
||||
return boost::dynamic_pointer_cast<GainControl> (_gain_control);
|
||||
boost::shared_ptr<AutomationControl> gain_control() {
|
||||
return _gain_control;
|
||||
}
|
||||
|
||||
boost::shared_ptr<const GainControl> gain_control() const {
|
||||
return boost::dynamic_pointer_cast<GainControl> (_gain_control);
|
||||
boost::shared_ptr<const AutomationControl> gain_control() const {
|
||||
return _gain_control;
|
||||
}
|
||||
|
||||
std::string value_as_string (boost::shared_ptr<AutomationControl>) const;
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
Copyright (C) 2006-2016 Paul Davis
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the Free
|
||||
Software Foundation; either version 2 of the License, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef __ardour_gain_control_h__
|
||||
#define __ardour_gain_control_h__
|
||||
|
||||
#include <string>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include "pbd/controllable.h"
|
||||
|
||||
#include "evoral/Parameter.hpp"
|
||||
|
||||
#include "ardour/automation_control.h"
|
||||
#include "ardour/libardour_visibility.h"
|
||||
|
||||
namespace ARDOUR {
|
||||
|
||||
class Session;
|
||||
|
||||
struct LIBARDOUR_API GainControl : public AutomationControl {
|
||||
GainControl (Session& session, const Evoral::Parameter ¶m,
|
||||
boost::shared_ptr<AutomationList> al = boost::shared_ptr<AutomationList>());
|
||||
|
||||
void set_value (double val, PBD::Controllable::GroupControlDisposition group_override);
|
||||
void set_value_unchecked (double);
|
||||
|
||||
double internal_to_interface (double) const;
|
||||
double interface_to_internal (double) const;
|
||||
double internal_to_user (double) const;
|
||||
double user_to_internal (double) const;
|
||||
std::string get_user_string () const;
|
||||
|
||||
double lower_db;
|
||||
double range_db;
|
||||
};
|
||||
|
||||
} /* namespace */
|
||||
|
||||
#endif /* __ardour_gain_control_h__ */
|
|
@ -28,6 +28,7 @@
|
|||
#include "ardour/amp.h"
|
||||
#include "ardour/automatable.h"
|
||||
#include "ardour/event_type_map.h"
|
||||
#include "ardour/gain_control.h"
|
||||
#include "ardour/midi_track.h"
|
||||
#include "ardour/pan_controllable.h"
|
||||
#include "ardour/pannable.h"
|
||||
|
@ -449,9 +450,9 @@ Automatable::control_factory(const Evoral::Parameter& param)
|
|||
warning << "PluginPropertyAutomation for non-Plugin" << endl;
|
||||
}
|
||||
} else if (param.type() == GainAutomation) {
|
||||
control = new Amp::GainControl(_a_session, param);
|
||||
control = new GainControl(_a_session, param);
|
||||
} else if (param.type() == TrimAutomation) {
|
||||
control = new Amp::GainControl(_a_session, param);
|
||||
control = new GainControl(_a_session, param);
|
||||
} else if (param.type() == PanAzimuthAutomation || param.type() == PanWidthAutomation || param.type() == PanElevationAutomation) {
|
||||
Pannable* pannable = dynamic_cast<Pannable*>(this);
|
||||
if (pannable) {
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
Copyright (C) 2006-2016 Paul Davis
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the Free
|
||||
Software Foundation; either version 2 of the License, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "ardour/dB.h"
|
||||
#include "ardour/gain_control.h"
|
||||
#include "ardour/session.h"
|
||||
|
||||
#include "i18n.h"
|
||||
|
||||
using namespace ARDOUR;
|
||||
using namespace std;
|
||||
|
||||
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
|
||||
GainControl::set_value (double val, PBD::Controllable::GroupControlDisposition /* group_override */)
|
||||
{
|
||||
if (writable()) {
|
||||
set_value_unchecked (val);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
GainControl::set_value_unchecked (double val)
|
||||
{
|
||||
AutomationControl::set_value (std::max (std::min (val, (double)_desc.upper), (double)_desc.lower), Controllable::NoGroup);
|
||||
_session.set_dirty ();
|
||||
}
|
||||
|
||||
double
|
||||
GainControl::internal_to_interface (double v) const
|
||||
{
|
||||
if (_desc.type == GainAutomation) {
|
||||
return gain_to_slider_position (v);
|
||||
} else {
|
||||
return (accurate_coefficient_to_dB (v) - lower_db) / range_db;
|
||||
}
|
||||
}
|
||||
|
||||
double
|
||||
GainControl::interface_to_internal (double v) const
|
||||
{
|
||||
if (_desc.type == GainAutomation) {
|
||||
return slider_position_to_gain (v);
|
||||
} else {
|
||||
return dB_to_coefficient (lower_db + v * range_db);
|
||||
}
|
||||
}
|
||||
|
||||
double
|
||||
GainControl::internal_to_user (double v) const
|
||||
{
|
||||
return accurate_coefficient_to_dB (v);
|
||||
}
|
||||
|
||||
double
|
||||
GainControl::user_to_internal (double u) const
|
||||
{
|
||||
return dB_to_coefficient (u);
|
||||
}
|
||||
|
||||
std::string
|
||||
GainControl::get_user_string () const
|
||||
{
|
||||
char theBuf[32]; sprintf( theBuf, _("%3.1f dB"), accurate_coefficient_to_dB (get_value()));
|
||||
return std::string(theBuf);
|
||||
}
|
||||
|
|
@ -24,6 +24,7 @@
|
|||
#include "ardour/amp.h"
|
||||
#include "ardour/audioengine.h"
|
||||
#include "ardour/buffer_set.h"
|
||||
#include "ardour/gain_control.h"
|
||||
#include "ardour/io.h"
|
||||
#include "ardour/meter.h"
|
||||
#include "ardour/return.h"
|
||||
|
@ -50,7 +51,7 @@ Return::Return (Session& s, bool internal)
|
|||
/* never muted */
|
||||
|
||||
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));
|
||||
_gain_control = boost::shared_ptr<GainControl> (new GainControl (_session, Evoral::Parameter (GainAutomation), gl));
|
||||
add_control (_gain_control);
|
||||
|
||||
_amp.reset (new Amp (_session, X_("Fader"), _gain_control, true));
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include "ardour/capturing_processor.h"
|
||||
#include "ardour/debug.h"
|
||||
#include "ardour/delivery.h"
|
||||
#include "ardour/gain_control.h"
|
||||
#include "ardour/internal_return.h"
|
||||
#include "ardour/internal_send.h"
|
||||
#include "ardour/meter.h"
|
||||
|
@ -172,7 +173,7 @@ Route::init ()
|
|||
/* add amp processor */
|
||||
|
||||
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));
|
||||
_gain_control = boost::shared_ptr<GainControl> (new GainControl (_session, Evoral::Parameter(GainAutomation), gl));
|
||||
add_control (_gain_control);
|
||||
|
||||
_amp.reset (new Amp (_session, X_("Fader"), _gain_control, true));
|
||||
|
@ -185,7 +186,7 @@ Route::init ()
|
|||
/* and input 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));
|
||||
_trim_control = boost::shared_ptr<GainControl> (new GainControl (_session, Evoral::Parameter(TrimAutomation), tl));
|
||||
add_control (_trim_control);
|
||||
|
||||
_trim.reset (new Amp (_session, X_("Trim"), _trim_control, false));
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "ardour/amp.h"
|
||||
#include "ardour/buffer_set.h"
|
||||
#include "ardour/debug.h"
|
||||
#include "ardour/gain_control.h"
|
||||
#include "ardour/io.h"
|
||||
#include "ardour/meter.h"
|
||||
#include "ardour/panner_shell.h"
|
||||
|
@ -87,7 +88,7 @@ Send::Send (Session& s, boost::shared_ptr<Pannable> p, boost::shared_ptr<MuteMas
|
|||
//boost_debug_shared_ptr_mark_interesting (this, "send");
|
||||
|
||||
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));
|
||||
_gain_control = boost::shared_ptr<GainControl> (new GainControl (_session, Evoral::Parameter(GainAutomation), gl));
|
||||
add_control (_gain_control);
|
||||
|
||||
_amp.reset (new Amp (_session, _("Fader"), _gain_control, true));
|
||||
|
|
|
@ -71,6 +71,7 @@
|
|||
#include "ardour/engine_state_controller.h"
|
||||
#endif
|
||||
#include "ardour/filename_extensions.h"
|
||||
#include "ardour/gain_control.h"
|
||||
#include "ardour/graph.h"
|
||||
#include "ardour/midiport_manager.h"
|
||||
#include "ardour/scene_changer.h"
|
||||
|
@ -735,7 +736,7 @@ 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));
|
||||
boost::shared_ptr<AutomationControl> gain_control = boost::shared_ptr<GainControl> (new GainControl (*this, Evoral::Parameter(GainAutomation), gl));
|
||||
|
||||
_click_io.reset (new ClickIO (*this, X_("Click")));
|
||||
_click_gain.reset (new Amp (*this, _("Fader"), gain_control, true));
|
||||
|
|
|
@ -90,6 +90,7 @@ libardour_sources = [
|
|||
'filesystem_paths.cc',
|
||||
'filter.cc',
|
||||
'find_session.cc',
|
||||
'gain_control.cc',
|
||||
'globals.cc',
|
||||
'graph.cc',
|
||||
'graphnode.cc',
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "pbd/error.h"
|
||||
|
||||
#include "ardour/gain_control.h"
|
||||
#include "ardour/session.h"
|
||||
#include "ardour/route.h"
|
||||
#include "ardour/audio_track.h"
|
||||
|
|
Loading…
Reference in New Issue