View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0004553 | ardour | features | public | 2011-12-11 13:02 | 2020-04-19 20:15 |
| Reporter | royvegard | Assigned To | paul | ||
| Priority | normal | Severity | feature | Reproducibility | N/A |
| Status | closed | Resolution | fixed | ||
| Product Version | 3.0-beta1 | ||||
| Target Version | 3.0-beta3 | ||||
| Summary | 0004553: [PATCH] Prevent jumps when MIDI controller and controllable are "out of sync" | ||||
| Description | This patch prevents a gain-like controlled value to make large jumps when the MIDI controller and the controlled value are "out of sync". The controlled value will remain unaltered until the MIDI controller crosses the controlled value. This is useful for MIDI controllers that don't have motorized faders and knobs. | ||||
| Steps To Reproduce | 1. Bind your MIDI controller to for example the master gain fader. 2. Move the MIDI fader all the way down. 3. Use the mouse to move the master gain fader to the 0 dB position. 4. Start moving the MIDI fader The master gain fader will not move until the MIDI fader is at the equivalent 0 dB position. Old behavior would be that the master gain fader would instantly jump all the way down as soon as the MIDI fader started moving. | ||||
| Additional Information | Maybe this should be optional, but I can not think of a situation where the old behavior would be useful. | ||||
| Tags | No tags attached. | ||||
|
2011-12-11 13:05
|
4553.patch (2,242 bytes)
diff --git a/libs/surfaces/generic_midi/midicontrollable.cc b/libs/surfaces/generic_midi/midicontrollable.cc
index bae3201..9960515 100644
--- a/libs/surfaces/generic_midi/midicontrollable.cc
+++ b/libs/surfaces/generic_midi/midicontrollable.cc
@@ -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,17 @@ 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_controllable_value = midi_to_control (msg->value);
+ float max_value = max(last_controllable_value, new_controllable_value);
+ float min_value = min(last_controllable_value, new_controllable_value);
+
+ // prevent jumps when MIDI controller and controllable are "out of sync"
+ if (controllable->get_value() <= max_value &&
+ controllable->get_value() >= min_value) {
+ controllable->set_value (new_controllable_value);
+ }
+
+ last_controllable_value = new_controllable_value;
} else {
if (msg->value > 64.0f) {
controllable->set_value (1);
diff --git a/libs/surfaces/generic_midi/midicontrollable.h b/libs/surfaces/generic_midi/midicontrollable.h
index 2e70e98..5f188d1 100644
--- a/libs/surfaces/generic_midi/midicontrollable.h
+++ b/libs/surfaces/generic_midi/midicontrollable.h
@@ -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;
|
|
2011-12-11 20:42
|
4553_r2.patch (2,308 bytes)
diff --git a/libs/surfaces/generic_midi/midicontrollable.cc b/libs/surfaces/generic_midi/midicontrollable.cc
index bae3201..226502f 100644
--- a/libs/surfaces/generic_midi/midicontrollable.cc
+++ b/libs/surfaces/generic_midi/midicontrollable.cc
@@ -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);
diff --git a/libs/surfaces/generic_midi/midicontrollable.h b/libs/surfaces/generic_midi/midicontrollable.h
index 2e70e98..5f188d1 100644
--- a/libs/surfaces/generic_midi/midicontrollable.h
+++ b/libs/surfaces/generic_midi/midicontrollable.h
@@ -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;
|
|
|
New version uploaded. This should also work when you change banks on the MIDI controller. |
|
|
patch committed in rev 11001. thanks! |
|
|
Issue has been closed automatically, by Trigger Close Plugin. Feel free to re-open with additional information if you think the issue is not resolved. |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2011-12-11 13:02 | royvegard | New Issue | |
| 2011-12-11 13:05 | royvegard | File Added: 4553.patch | |
| 2011-12-11 13:11 | cth103 | cost | => 0.00 |
| 2011-12-11 13:11 | cth103 | Target Version | => 3.0-beta2 |
| 2011-12-11 20:42 | royvegard | File Added: 4553_r2.patch | |
| 2011-12-11 20:43 | royvegard | Note Added: 0012378 | |
| 2011-12-14 15:58 | paul | Note Added: 0012413 | |
| 2011-12-14 15:58 | paul | Status | new => resolved |
| 2011-12-14 15:58 | paul | Resolution | open => fixed |
| 2011-12-14 15:58 | paul | Assigned To | => paul |
| 2012-01-10 20:45 | cth103 | Target Version | 3.0-beta2 => 3.0-beta3 |
| 2020-04-19 20:15 | system | Note Added: 0022886 | |
| 2020-04-19 20:15 | system | Status | resolved => closed |