zynthian / zynthian-issue-tracking

Centralized Issue Tracking for Zynthian Project
https://github.com/orgs/zynthian/projects/1
11 stars 3 forks source link

Extension to MIDI Filter Rule Language: Velocity/Value Mappings #433

Open gr0k-net opened 3 years ago

gr0k-net commented 3 years ago

Is your feature request related to a problem? Please describe. I would love to get visual feedback between my MIDI controller and ZynStep by mapping momentary CC LED toggle buttons to NoteOn messages depending on specific values.

The toggle feature on all the controllers I have access to send CC messages at 127 and 0 when toggled, but ZynStep ignores Note-On messages at zero velocity, so I can get momentary mappings to work via the MIDI Filter Language, but lose the visual feedback the toggle feature would provide.

Describe the solution you'd like An extension to the MIDI Filter Rule Language to allow velocity mappings.

For example, mapping CC messages at value 0 on Channel 15 to NON messages at 100 velocity might look something like this:

MAP CH#15 CC#0:127@0 => CH#15 NON#0:127@100

Which would result in a CC message on channel 15 with a velocity of zero being mapped by the Zynthian to a NON message at 100 velocity at the relevant event number. (0:127 in this example)

Describe alternatives you've considered ZynStep appears to receives messages before MIDI utility layers (mapping, velocity adjust etc) that might have otherwise solved this solution.

None of the controllers I have regular access to allow me to map the controller buttons to note-on, they are all limited to CC. They also do not allow me to set the minimum/maximum values that are sent with toggles, they are limited to 0/127.

I could have created a feature request for ZynStep to accept CC as well as NoteOn messages, but an extension to the MIDI Filter Rule Language would make the Zynthian more useful overall.

It would probably upset some people if a zero velocity note triggered a sequence, but another solution would be a toggle option in ZynStep to allow note-on messages at zero velocity to turn a sequence off, tho this solution doesn't allow the flexibility of the MIDI Filter Language extension in other applications.

I understand that my solution would prevent two way sync of the pattern status, but I map MIDI channels and build sequences up rather than toggle between different fully built patterns, so this wouldn't be a problem for me. (Tho another different but related feature request would be an option to turn off toggle of patterns on the same MIDI channel within ZynStep, allowing multiple patterns to run on the same MIDI channel at the same time)

Additional context Apologies I've not been around here or on the forum this last few weeks, busy few weeks with work and life. Will be back on the forum etc soon.

jofemodo commented 3 years ago

Hi @gr0k-net !

The current implementation of the MIDI Filter doesn't allow this level of mapping and i don't plan to introduce a new operator.

Integrating "mididings" could be interesting for allowing complex MIDI mapping and filtering. Also, it's aligned with our plans of improving controller support on zynpad:

There is a open issue for implementing the first item. Could you open a new one for integrating "middings" ;-)

Regards,

gr0k-net commented 3 years ago

Thanks @jofemodo

I've managed to find a hack that works for me anyway, by jacking into to the set_midi_filter_event_map function in zynmidirouter.c, in the Event Mapping portion of the while loop, at the end of the if (event_map->type>=0) { } section I've added the following:

// gr0k Changes if (event_chan == 14 && event_num >= 9 && event_num <= 16 && event_val == 0) { ev.buffer[2] = 100; }

Obviously this code solves a very specific problem and isn't useful to others so I won't be pushing it :laughing:

Also I haven't coded in C for 15+ years so it might not be the most elegant solution, but this little hack has solved my problem and also got me started digging around in the Zynthian code-base. Not that I have the time to do anything useful right now (I'm still catching up on all the work I should have been doing whilst playing with my Zynthian :rofl:) but at least I've made a start.

Hopefully I will have the time to implement some push-worthy fixes or mods sometime soon.

Thanks again @jofemodo !!