patch from roy vegard to stop feedback from causing jumps when a MIDI controller and ardour are out of sync
git-svn-id: svn://localhost/ardour2/branches/3.0@11001 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
b6d1fb0707
commit
dcccd5b4d6
@ -48,6 +48,7 @@ MIDIControllable::MIDIControllable (Port& p, bool m)
|
||||
_learned = false; /* from URI */
|
||||
setting = false;
|
||||
last_value = 0; // got a better idea ?
|
||||
last_controllable_value = 0.0f;
|
||||
control_type = none;
|
||||
_control_description = "MIDI Control: none";
|
||||
control_additional = (byte) -1;
|
||||
@ -63,6 +64,7 @@ MIDIControllable::MIDIControllable (Port& p, Controllable& c, bool m)
|
||||
_learned = true; /* from controllable */
|
||||
setting = false;
|
||||
last_value = 0; // got a better idea ?
|
||||
last_controllable_value = 0.0f;
|
||||
control_type = none;
|
||||
_control_description = "MIDI Control: none";
|
||||
control_additional = (byte) -1;
|
||||
@ -217,7 +219,20 @@ MIDIControllable::midi_sense_controller (Parser &, EventTwoBytes *msg)
|
||||
if (control_additional == msg->controller_number) {
|
||||
|
||||
if (!controllable->is_toggle()) {
|
||||
controllable->set_value (midi_to_control (msg->value));
|
||||
float new_value = msg->value;
|
||||
float max_value = max(last_controllable_value, new_value);
|
||||
float min_value = min(last_controllable_value, new_value);
|
||||
float range = max_value - min_value;
|
||||
float threshold = 10;
|
||||
|
||||
// prevent jumps when MIDI controller and controllable are "out of sync"
|
||||
if (range < threshold &&
|
||||
controllable->get_value() <= midi_to_control(max_value) &&
|
||||
controllable->get_value() >= midi_to_control(min_value)) {
|
||||
controllable->set_value (midi_to_control (new_value) );
|
||||
}
|
||||
|
||||
last_controllable_value = new_value;
|
||||
} else {
|
||||
if (msg->value > 64.0f) {
|
||||
controllable->set_value (1);
|
||||
|
@ -95,6 +95,7 @@ class MIDIControllable : public PBD::Stateful
|
||||
MIDI::Port& _port;
|
||||
bool setting;
|
||||
MIDI::byte last_value;
|
||||
float last_controllable_value;
|
||||
bool _momentary;
|
||||
bool _is_gain_controller;
|
||||
bool _learned;
|
||||
|
Loading…
Reference in New Issue
Block a user