Articulation chasing doesn't support multiple groups
It's a known issue that Reaper will only chase the most recent program change event on a given channel. The articulation group is a Reaticulate construct that Reaper doesn't know anything about. Consequently, you can have multiple articulations active on a given channel but only the latest one will be chased.
It may be possible to implement custom chasing of program changes efficiently with this design.
On the Lua side:
- Maintain a list of relevant tracks that have the Reaticulate JSFX installed and which have banks loaded that use multiple groups. This list would need to be regenerated whenever tracks are added or deleted, the Reaticulate JSFX is added or removed, or the bank list is updated on a track, or the project is changed.
- Also maintain a program cache that maps a track for at given (track hash, edit cursor) tuple to the most recent articulations on all groups on all channels, only for tracks in the relevant track list. A given track can retain N (hash, edit cursor) mappings.
- In main loop, when edit cursor changes, regenerate program cache for all tracks in relevant track list.
- Optimization: if new edit cursor is < old edit cursor but >= ppq of latest program in the old list, regeneration isn't necessary, simply add a new entry with the (hash, new edit cursor) tuple that points to the other program list. This item can be tagged for early eviction in case N is exceeded, because the (hash, old edit cursor) item is more useful.
- In main loop, enumerate over selected tracks and if hash doesn't exist in the cache for that track, clear existing (track hash, edit cursor) entries and regenerate for that track.
- Regeneration means enumerating all CCs backward from edit cursor and collecting a list of the most recent articulations on all groups on all channels. And then informing the RFX on the track about this list. The relative order must somehow be communicated to the RFX so it can replay them in the right order.
- Optimization 1: if the RFX reports articulations enabled only on a single group for all channels, no cache need be maintained
- Optimization 2: enumeration over MIDI events on track can break once all (channel, group) tuples that the RFX indicate have programs assigned are observed.
On the JSFX side:
- When transport changes to playing or recording, replay all programs on all channels and groups in the order provided by the Lua controller.
Not a professional programmer here and I only understand 20% of what's written above, but let me just throw an uninformed idea at a 6 year old problem and you can ignore it if it does not make sense.
Would it solve the group issue (reaper only changsing the last program change on a channel) if there was a "set articualtion" button that if pressed generates a ranodm program number and synthesizes all at this point active group's MIDI output events into one program change event?
Or otherwise, a list of all possible combinations of all the groups (to cover all possible articulations) could be generated with increasing program numbers when the scirpt is compiled. Then the plug-in could find the program change event that represents this particular combination of all groups and insert it.