simpler approach for Apple setrlimit() compatibility issue
[ardour.git] / libs / ardour / amp.cc
index 29032525f244c57a7d7c94bfb65bfd6c866d62d0..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);
@@ -404,7 +401,7 @@ Amp::set_state (const XMLNode& node, int version)
 void
 Amp::GainControl::set_value (double val)
 {
-       AutomationControl::set_value (min (val, (double) max_gain_coefficient));
+       AutomationControl::set_value (min (val, (double) Config->get_max_gain()));
        _amp->session().set_dirty ();
 }
 
@@ -426,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).