+ if (!_desc.toggled) {
+ AutomationWatch::instance().remove_automation_watch (shared_from_this());
+
+ }
+ }
+ }
+}
+
+void
+AutomationControl::commit_transaction (bool did_write)
+{
+ if (did_write) {
+ if (alist ()->before ()) {
+ _session.begin_reversible_command (string_compose (_("record %1 automation"), name ()));
+ _session.commit_reversible_command (new MementoCommand<AutomationList> (*alist ().get (), alist ()->before (), &alist ()->get_state ()));
+ }
+ } else {
+ alist ()->clear_history ();
+ }
+}
+
+double
+AutomationControl::internal_to_interface (double val) const
+{
+ if (_desc.integer_step) {
+ // both upper and lower are inclusive.
+ val = (val - lower()) / (1 + upper() - lower());
+ } else {
+ val = (val - lower()) / (upper() - lower());
+ }
+
+ if (_desc.logarithmic) {
+ if (val > 0) {
+ val = pow (val, 1./2.0);
+ } else {
+ val = 0;
+ }
+ }
+
+ return val;
+}
+
+double
+AutomationControl::interface_to_internal (double val) const
+{
+ if (!isfinite_local (val)) {
+ val = 0;
+ }
+ if (_desc.logarithmic) {
+ if (val <= 0) {
+ val = 0;
+ } else {
+ val = pow (val, 2.0);