+void
+Amp::inc_gain (gain_t factor, void *src)
+{
+ float desired_gain = _gain_control->user_double();
+
+ if (desired_gain == 0.0f) {
+ set_gain (0.000001f + (0.000001f * factor), src);
+ } else {
+ set_gain (desired_gain + (desired_gain * factor), src);
+ }
+}
+
+void
+Amp::set_gain (gain_t val, void *src)
+{
+ // max gain at about +6dB (10.0 ^ ( 6 dB * 0.05))
+ if (val > 1.99526231f) {
+ val = 1.99526231f;
+ }
+
+ //cerr << "set desired gain to " << val << " when curgain = " << _gain_control->get_value () << endl;
+
+ 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, false);
+ _session.set_dirty();
+}
+
+XMLNode&
+Amp::state (bool full_state)
+{
+ XMLNode& node (Processor::state (full_state));
+ node.add_property("type", "amp");
+ node.add_child_nocopy (_gain_control->get_state());
+
+ return node;
+}
+
+int
+Amp::set_state (const XMLNode& node, int version)
+{
+ XMLNode* gain_node;
+
+ Processor::set_state (node, version);
+
+ if ((gain_node = node.child (Controllable::xml_node_name.c_str())) != 0) {
+ _gain_control->set_state (*gain_node, version);
+ }
+
+ return 0;
+}
+
+void
+Amp::GainControl::set_value (double val)
+{
+ // max gain at about +6dB (10.0 ^ ( 6 dB * 0.05))
+ if (val > 1.99526231f) {
+ val = 1.99526231f;
+ }
+
+ _amp->set_gain (val, this);
+
+ AutomationControl::set_value(val);
+}
+
+double
+Amp::GainControl::get_value (void) const
+{
+ return AutomationControl::get_value();
+}
+
+void
+Amp::setup_gain_automation (framepos_t start_frame, framepos_t end_frame, framecnt_t nframes)
+{
+ Glib::Mutex::Lock am (control_lock(), Glib::TRY_LOCK);
+
+ if (am.locked() && _session.transport_rolling() && _gain_control->automation_playback()) {
+ _apply_gain_automation = _gain_control->list()->curve().rt_safe_get_vector (
+ start_frame, end_frame, _session.gain_automation_buffer(), nframes);
+ } else {
+ _apply_gain_automation = false;
+ }
+}
+
+bool
+Amp::visible() const
+{
+ return true;
+}