This is a mid-point in my processing. Apologies, but I think it would be terribly cumbersome to try to document my inputs and outputs with enough explanation to make the big picture palatable.
It is insane. Trust me. heh heh
However, this is where I'm at with a certain Preset which is a first step in a much larger world /Ben Kenobi.
I need to select one of four of variables based on which bit is "1" in the first 4 bits of another variable.
Right now, g0 is the index. I'm using the first 4 bits to represent a toggle of 4 buttons. The bits of code before this ensure that only one of the 4 bits is set to "1" (or what I'm sometimes terming 'On').
If the first bit is the 1, then I want to put HA in the destination. If the second bit is the 1, then I want to put HB in the destination.
Third, HC; Fourth, HD.
HA-HD are all 'masks' that represent the On/Off states for 16 different destinations (incidentally, a 0 is 'on' or that it is not masked). I'm attempting to use the bit manipulation technique to toggle the buttons and select the appropriate mask, which is then stuck in GA which is used later on to compare to another mask when output is triggered.
What I have right now is something like:
Incoming: 87 pp [any velocity]
// Have a bunch of buttons and I test for just the 4 in the first column in a specific range, because: reasons
if pp<48, then exit/skip
if pp>63 then exit/skip
if ww!=0 then exit/skip
// So now I've narrowed it down to its button (note) 48, 52, 56, or 60. Let's figure out an index:
//vv is now the index (0,1,2,3) for the bit manipulation
//g0 is the variable to keep track of which button is on; it is exclusive, so only one button is 'on' at a time (the last line clears out any previous 'on' states); also: buttons can be all off (0b0000)
//The only way I can wrap my head around:
I could use a timer, but this is not the 'end' of the processing path. Moreso, I have a timer for the final output of this whole craziness. My understanding is if I stick a timer in there to cycle through these 4 values it will trigger the Outgoing from the timer 4x and that's not quite necessary or warranted.
I'm okay with the above, but I wonder if there's a more elegant way to do it that might encompass more scenarios and allow me to use the same code across other button groupings.
I'm not that great wrapping my head around Timers wrt parallel processing, so I'm probably missing something terribly obvious. If I had more than 32 bits to play with, I'd use one super-mask and then index from there (0-15 for the first, 16-31 for the second, etc)
g0=4 bit toggles for the button states for 4 buttons GA = destination for which of the 4 'masks' will be considered current HA, HB, HC, HD = 'masks' for 16 destination outputs, using the first 16 bits where a "1" indicates that a given destination will be played or muted (Note: 1="Muted", so a mask of value 5 means that Destination 1 and 3 are muted, all the rest are played)
pp=Inc Note #, test to be 48-60, and that it is evenly divisible by 4 (which represents the first column of my button matrix)
ww=Tester variable to verify Note/Button in question is first column
xx=Resulting Note # after forced into range 0-12
vv=Derived from Note/Button#, ends up being the Index for the bit manipulation
oo=temp var for determining which mask goes into the 'Current' global variable position
qq=temp var to help calc which mask is selected