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);
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;
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
#ifndef __ardour_amp_h__
#define __ardour_amp_h__
+#include "ardour/dB.h"
#include "ardour/libardour_visibility.h"
#include "ardour/types.h"
#include "ardour/chan_count.h"
*/
class LIBARDOUR_API Amp : public Processor {
public:
- Amp(Session& s);
+ Amp(Session& s, std::string type = "amp");
std::string display_name() const;
, _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;
}
void set_value (double val);
std::string get_user_string () const;
Amp* _amp;
+ double lower_db;
+ double range_db;
};
boost::shared_ptr<GainControl> gain_control() {
/** Buffer that we should use for gain automation */
gain_t* _gain_automation_buffer;
+ std::string _type;
};