fix midi automation sliders

Allow controls to work without a list. see also 34c1465 and b469cd2
This commit is contained in:
Robin Gareus 2014-10-16 21:21:11 +02:00
parent 8d8717800d
commit d34bd9e6a0
3 changed files with 14 additions and 9 deletions

View file

@ -120,6 +120,7 @@ AutomationController::start_touch()
void void
AutomationController::end_touch () AutomationController::end_touch ()
{ {
if (!_controllable->alist()) return;
if (_controllable->automation_state() == Touch) { if (_controllable->automation_state() == Touch) {
bool mark = false; bool mark = false;

View file

@ -117,6 +117,7 @@ AutomationControl::set_automation_style (AutoStyle as)
void void
AutomationControl::start_touch(double when) AutomationControl::start_touch(double when)
{ {
if (!_list) return;
if (!touching()) { if (!touching()) {
if (alist()->automation_state() == Touch) { if (alist()->automation_state() == Touch) {
alist()->start_touch (when); alist()->start_touch (when);
@ -129,6 +130,7 @@ AutomationControl::start_touch(double when)
void void
AutomationControl::stop_touch(bool mark, double when) AutomationControl::stop_touch(bool mark, double when)
{ {
if (!_list) return;
if (touching()) { if (touching()) {
set_touching (false); set_touching (false);
if (alist()->automation_state() == Touch) { if (alist()->automation_state() == Touch) {

View file

@ -643,15 +643,17 @@ MidiTrack::set_parameter_automation_state (Evoral::Parameter param, AutoState st
void void
MidiTrack::MidiControl::set_value(double val) MidiTrack::MidiControl::set_value(double val)
{ {
const Evoral::Parameter &parameter = _list ? _list->parameter() : Control::parameter();
bool valid = false; bool valid = false;
if (isinf(val)) { if (isinf(val)) {
cerr << "MIDIControl value is infinity" << endl; cerr << "MIDIControl value is infinity" << endl;
} else if (isnan(val)) { } else if (isnan(val)) {
cerr << "MIDIControl value is NaN" << endl; cerr << "MIDIControl value is NaN" << endl;
} else if (val < _list->parameter().min()) { } else if (val < parameter.min()) {
cerr << "MIDIControl value is < " << _list->parameter().min() << endl; cerr << "MIDIControl value is < " << parameter.min() << endl;
} else if (val > _list->parameter().max()) { } else if (val > parameter.max()) {
cerr << "MIDIControl value is > " << _list->parameter().max() << endl; cerr << "MIDIControl value is > " << parameter.max() << endl;
} else { } else {
valid = true; valid = true;
} }
@ -660,14 +662,14 @@ MidiTrack::MidiControl::set_value(double val)
return; return;
} }
assert(val <= _list->parameter().max()); assert(val <= parameter.max());
if ( ! automation_playback()) { if ( ! _list || ! automation_playback()) {
size_t size = 3; size_t size = 3;
uint8_t ev[3] = { _list->parameter().channel(), uint8_t (val), 0 }; uint8_t ev[3] = { parameter.channel(), uint8_t (val), 0 };
switch(_list->parameter().type()) { switch(parameter.type()) {
case MidiCCAutomation: case MidiCCAutomation:
ev[0] += MIDI_CMD_CONTROL; ev[0] += MIDI_CMD_CONTROL;
ev[1] = _list->parameter().id(); ev[1] = parameter.id();
ev[2] = int(val); ev[2] = int(val);
break; break;