Fix for SubSceneSwitch with an offset value < 0 and wrap = True
Opened this issue · 2 comments
When the SubSceneSwitch offset value is < 0 and wrap is True, n eventually becomes < 0 and SubSceneSwitch stops working. To correct this, after calculating the remainder, check for n < 0 and if true then add num_subscenes to n. This will give n the intended offset value in both directions.
Here's the fix (just the if (n < 0) {...}
statement):
if (_wrap) {
n %= engine.num_subscenes();
if (n < 0) {
n += engine.num_subscenes();
}
}
Here's an example from a mididings script in which I map the two rightmost control pads on a Korg nanoPAD2 controller to cycle up and down through a list of sub scenes (wrap is True by default).
ControlMap.append( KeyFilter(PadMap["U8"]) >> SubSceneSwitch(offset = -1) )
ControlMap.append( KeyFilter(PadMap["L8"]) >> SubSceneSwitch(offset = +1) )
I will create a pull request, but again I'm wondering about the maintenance of this excellent project since the last pull request processed was 5 years ago.
Hey! I’ve been going back and attempting to add fixes/improvements to mididings.
Is this where the code needs to be inserted?
EDIT: I've just pulled the fix in. :)
Yes, that's exactly where to put it! I was away from mididings for a while. I'm going to work on switching over to your Community Edition of mididings, thank you!