fix midi automation sliders
authorRobin Gareus <robin@gareus.org>
Thu, 16 Oct 2014 19:21:11 +0000 (21:21 +0200)
committerRobin Gareus <robin@gareus.org>
Thu, 16 Oct 2014 19:21:45 +0000 (21:21 +0200)
Allow controls to work without a list. see also 34c1465 and b469cd2

gtk2_ardour/automation_controller.cc
libs/ardour/automation_control.cc
libs/ardour/midi_track.cc

index fbc5066c439e7be738ea1a76abbbe1b08120d299..3174980a7b4c46db1213ba9bd552f1488b30e8b0 100644 (file)
@@ -120,6 +120,7 @@ AutomationController::start_touch()
 void
 AutomationController::end_touch ()
 {
+       if (!_controllable->alist()) return;
        if (_controllable->automation_state() == Touch) {
 
                bool mark = false;
index 2bb694c7e5d2ca6031dd9b0524521c71b3eb580e..f1305609ef009862bff6f827d5d8348091a31957 100644 (file)
@@ -117,6 +117,7 @@ AutomationControl::set_automation_style (AutoStyle as)
 void
 AutomationControl::start_touch(double when)
 {
+       if (!_list) return;
        if (!touching()) {
                if (alist()->automation_state() == Touch) {
                        alist()->start_touch (when);
@@ -129,6 +130,7 @@ AutomationControl::start_touch(double when)
 void
 AutomationControl::stop_touch(bool mark, double when)
 {
+       if (!_list) return;
        if (touching()) {
                set_touching (false);
                if (alist()->automation_state() == Touch) {
index 3866eb4d80844f4790bbb418725911a69736d4a3..0dab684ac23fbe2cdfbb9e3d197e4cb40aafc496 100644 (file)
@@ -643,15 +643,17 @@ MidiTrack::set_parameter_automation_state (Evoral::Parameter param, AutoState st
 void
 MidiTrack::MidiControl::set_value(double val)
 {
+       const Evoral::Parameter &parameter = _list ? _list->parameter() : Control::parameter();
+
        bool valid = false;
        if (isinf(val)) {
                cerr << "MIDIControl value is infinity" << endl;
        } else if (isnan(val)) {
                cerr << "MIDIControl value is NaN" << endl;
-       } else if (val < _list->parameter().min()) {
-               cerr << "MIDIControl value is < " << _list->parameter().min() << endl;
-       } else if (val > _list->parameter().max()) {
-               cerr << "MIDIControl value is > " << _list->parameter().max() << endl;
+       } else if (val < parameter.min()) {
+               cerr << "MIDIControl value is < " << parameter.min() << endl;
+       } else if (val > parameter.max()) {
+               cerr << "MIDIControl value is > " << parameter.max() << endl;
        } else {
                valid = true;
        }
@@ -660,14 +662,14 @@ MidiTrack::MidiControl::set_value(double val)
                return;
        }
 
-       assert(val <= _list->parameter().max());
-       if ( ! automation_playback()) {
+       assert(val <= parameter.max());
+       if ( ! _list || ! automation_playback()) {
                size_t size = 3;
-               uint8_t ev[3] = { _list->parameter().channel(), uint8_t (val), 0 };
-               switch(_list->parameter().type()) {
+               uint8_t ev[3] = { parameter.channel(), uint8_t (val), 0 };
+               switch(parameter.type()) {
                case MidiCCAutomation:
                        ev[0] += MIDI_CMD_CONTROL;
-                       ev[1] = _list->parameter().id();
+                       ev[1] = parameter.id();
                        ev[2] = int(val);
                        break;