Fix incorrect initial point when recording toggled automation.
[ardour.git] / libs / evoral / src / ControlList.cpp
index d9c1b993bd69e5174c97c05a0faa2c92289be4f5..6d07ff150afa91ae0c893ddf04a5cc7bf795ac80 100644 (file)
@@ -584,8 +584,15 @@ ControlList::add (double when, double value, bool with_guards, bool with_initial
                        /* empty: add an "anchor" point if the point we're adding past time 0 */
 
                        if (when >= 1) {
-                               _events.insert (_events.end(), new ControlEvent (0, value));
-                               DEBUG_TRACE (DEBUG::ControlList, string_compose ("@%1 added default value %2 at zero\n", this, _default_value));
+                               if (_desc.toggled) {
+                                       const bool bval = ((value >= 0.5) ? true : false);
+                                       _events.insert (_events.end(), new ControlEvent (0, !bval));
+                                       DEBUG_TRACE (DEBUG::ControlList, string_compose ("@%1 added bool value %2 at zero\n", this, !bval));
+
+                               } else {
+                                       _events.insert (_events.end(), new ControlEvent (0, value));
+                                       DEBUG_TRACE (DEBUG::ControlList, string_compose ("@%1 added default value %2 at zero\n", this, _default_value));
+                               }
                        }
                }