summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/ardour/amp.cc22
-rw-r--r--libs/ardour/ardour/amp.h9
2 files changed, 23 insertions, 8 deletions
diff --git a/libs/ardour/amp.cc b/libs/ardour/amp.cc
index ac970fc581..f2381cdefb 100644
--- a/libs/ardour/amp.cc
+++ b/libs/ardour/amp.cc
@@ -34,17 +34,17 @@
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);
@@ -351,7 +351,7 @@ XMLNode&
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;
@@ -374,20 +374,28 @@ Amp::set_state (const XMLNode& node, int version)
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
diff --git a/libs/ardour/ardour/amp.h b/libs/ardour/ardour/amp.h
index 5bfcf1d311..7a24e69edb 100644
--- a/libs/ardour/ardour/amp.h
+++ b/libs/ardour/ardour/amp.h
@@ -19,6 +19,7 @@
#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"
@@ -35,7 +36,7 @@ class IO;
*/
class LIBARDOUR_API Amp : public Processor {
public:
- Amp(Session& s);
+ Amp(Session& s, std::string type = "amp");
std::string display_name() const;
@@ -83,6 +84,9 @@ public:
, _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);
@@ -94,6 +98,8 @@ public:
std::string get_user_string () const;
Amp* _amp;
+ double lower_db;
+ double range_db;
};
boost::shared_ptr<GainControl> gain_control() {
@@ -117,6 +123,7 @@ private:
/** Buffer that we should use for gain automation */
gain_t* _gain_automation_buffer;
+ std::string _type;
};