Remove the source files which got transferred to libpbd
[ardour.git] / libs / ardour / amp.cc
index f60240fd57c128dc6ca97a74364eecbb90b56912..8ee42f3bbf79c875d4449cf7f7708dd6b975ab23 100644 (file)
@@ -27,6 +27,7 @@
 #include "ardour/audio_buffer.h"
 #include "ardour/buffer_set.h"
 #include "ardour/midi_buffer.h"
+#include "ardour/rc_configuration.h"
 #include "ardour/session.h"
 
 #include "i18n.h"
@@ -35,9 +36,6 @@ using namespace ARDOUR;
 using namespace PBD;
 using std::min;
 
-/* gain range of -inf to +6dB, default 0dB */
-const float Amp::max_gain_coefficient = 1.99526231f;
-
 Amp::Amp (Session& s)
        : Processor(s, "Amp")
        , _apply_gain(true)
@@ -46,7 +44,6 @@ Amp::Amp (Session& s)
        , _gain_automation_buffer(0)
 {
        Evoral::Parameter p (GainAutomation);
-       p.set_range (0, max_gain_coefficient, 1, false);
        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);
@@ -61,7 +58,7 @@ Amp::display_name() const
 }
 
 bool
-Amp::can_support_io_configuration (const ChanCount& in, ChanCount& out) const
+Amp::can_support_io_configuration (const ChanCount& in, ChanCount& out)
 {
        out = in;
        return true;
@@ -372,19 +369,9 @@ Amp::inc_gain (gain_t factor, void *src)
 }
 
 void
-Amp::set_gain (gain_t val, void *src)
+Amp::set_gain (gain_t val, void *)
 {
-       val = min (val, max_gain_coefficient);
-
-       if (src != _gain_control.get()) {
-               _gain_control->set_value (val);
-               // bit twisty, this will come back and call us again
-               // (this keeps control in sync with reality)
-               return;
-       }
-
-       _gain_control->set_double (val);
-       _session.set_dirty();
+       _gain_control->set_value (val);
 }
 
 XMLNode&
@@ -414,13 +401,8 @@ Amp::set_state (const XMLNode& node, int version)
 void
 Amp::GainControl::set_value (double val)
 {
-       if (val > max_gain_coefficient) {
-               val = max_gain_coefficient;
-       }
-
-       _amp->set_gain (val, this);
-
-       AutomationControl::set_value(val);
+       AutomationControl::set_value (min (val, (double) Config->get_max_gain()));
+       _amp->session().set_dirty ();
 }
 
 double
@@ -441,6 +423,19 @@ 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).
@@ -450,7 +445,10 @@ Amp::setup_gain_automation (framepos_t start_frame, framepos_t end_frame, framec
 {
        Glib::Threads::Mutex::Lock am (control_lock(), Glib::Threads::TRY_LOCK);
 
-       if (am.locked() && _session.transport_rolling() && _gain_control->automation_playback()) {
+       if (am.locked()
+           && (_session.transport_rolling() || _session.bounce_processing())
+           && _gain_control->automation_playback())
+       {
                assert (_gain_automation_buffer);
                _apply_gain_automation = _gain_control->list()->curve().rt_safe_get_vector (
                        start_frame, end_frame, _gain_automation_buffer, nframes);