#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"
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)
, _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);
}
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;
}
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&
void
Amp::GainControl::set_value (double val)
{
- // max gain at about +6dB (10.0 ^ ( 6 dB * 0.05))
- if (val > 1.99526231) {
- val = 1.99526231;
- }
-
- _amp->set_gain (val, this);
-
- AutomationControl::set_value(val);
+ AutomationControl::set_value (min (val, (double) Config->get_max_gain()));
+ _amp->session().set_dirty ();
}
double
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).
{
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);