Hi, I want to build a generic modulation matrix, that would allow any to take a source X (velocity, aftertouch, modwheel) and control a CC parameter Y around its default setting.
The aim is to build to flexibly, and allow any number of slots. For it to work I was thinking of setting up a table or array, but my knowledge on these in lua is fairly basic, and you can do a lot with them.
I’m doubt if I shoud work with a 2D matrix (x,y) where the value is the depth. Or should I build 3 simple tables.
Table Source: key = slot, value = source
Table Destination: key = slot, value = destination
Table depth: key = slot, value = depth
My main concern here is speed: on any event such as aftertouch, I need to verify if there are slots with source Aftertouch, then I need, for all destinations found, to find if there are other sources modulating the same destination. Only then I can calculate the new temp value for that destination.
What is the fastest way to execute such algorithm?
I’ve found a workable way, but it’s not yet a generic modulation matrix, where each slot can be set with source, depth and destination. Instead I’ve foreseen a set number of sources (velocity, aftertouch, modwheel etc…) and gave each two destination slots.
By definining a number for each source , I could make it work using 2 tables:
table modDest is one dimensional: i = the source, the value is the CC-value destination
table modDepth is two dimensional: i = the source, j = the destination, the value is the depth.
Whenever a certain combination is no longer in use, the nil is assigned to the component in those arrays. The number of variables is therefor kept at a minimum.