CreepyPants
2020-04-13 00:51:55
I press buttons on a box that makes MTPro decide on a bunch of CCs to send out.
>>>I need to create a routine to 'quantise' the output so if several buttons are pressed within a short amount of time, the Timers which create the output all run closer to the same time than they are currently running. (I think)<<<
I'm running into an issue and please understand it is one hellacious rabbit hole to wander down if we want to get into the why/what/how bits, but basically I'm getting timing issues from the receiving device in that part of the CC's are arriving before the beat and some just enough after that the sequencer (receiving device) is affecting some Tracks one beat late (my options on the quantise on the device are Instant, Beat, and then coarser resolution from there).
I'm thinking about MTPro holding onto the output for a short time to sort of 'quantise' the output, but I'm at a loss as to how to approach the logic on this. I'm also not sure that this will resolve what issues I'm having, but really this is difficult for me to explain (as Steve knows because this is still that same project, Steve! LOL - BTW - It's almost done. I'm actually jamming with it (had a few bad setbacks) and it's runnig the lights and everything)
Sordid Details:
When a button is pressed, MTPro decides which tracks this is going to turn on/off and sets up an output mask, which is 16 bits of a variable representing 16 Tracks with 1 being On and 0 being Off. There are roughly 3 groups of these (it gets more complex, but I think this is the salient part).
Once it has decided what the output mask is going to be, it triggers the Output Timers which just cycles through the 16 bits, checks the status (On/Off;1/0) and compares it to the previous status. If the status changes, it forms the MIDI CC msg and sends it.
There are 3 groups and several output timers for each group: One updates lights on a button box, one decides lighting cues and sends that data out via MIDI over ethernet, both of which are not an issue. The two in each of the 3 groups that are an issue are sending info to my sequencer, one each for two different applications/techniques of muting or playing Tracks.
The Initial Delay on these timers is 0ms.
They run 16x.
They compare the previous run state for each bit, so if there is no change, the script bounces out and doesn't send data (to cut down on MIDI Traffic).
The Repeat Delay is currently 2ms.
So...up to 6 Timers are sending out and take roughly 32ms (just spitballing) to get the data out.
I'm wondering how to approach this, whether I'd want MTPro to hold the incoming Note Data while a Timer cycles until it doesn't receive an input and then process it? Or would it be better on the back end where the output would be subject to a Timer waiting for a pause in input?
As in:
Data comes in
Data is processed and Output Timers are ready to be triggered
Countdown Timer is Started
Output is held until Countdown Timer finishes
Countdown Timer is reset every time an Output Timer is triggered (so, if new data comes in during this window, the Timer is reset and Output effectively held)
Curious bit is that I have roughly 3 systems working independently on these Input/Process/Output routines so I think I'd have to connect them all.
Does that make sense?
No need to write a script - I just don't know the best way or the Bome way to approach this.
I also don't know if this is going to resolve my issues.
I know this will not definitively solve timing issues since the Output Timers happen over a period of time, but I'm wondering if my pressing of multiple buttons is a greater range of time than 32ms.
Also, timing wise:
- if I make a countdown timer, what is a good range of time? Or should I calc how long about a 64th note might be at the tempo of the song I'm using? As in: if the idea is that I want to ensure that several buttons I'm pressing that *to me* are 'at the same time', what is a good number to tell the computer what I mean is 'this is the same as at the same time'?
- My output Timers of Initial Delay 0ms; Repeat Delay 2ms take about 32ms to run and we can count processing time as inconsequential? Or what do you think I can estimate? Or do you want to see that bit of code?
- I thought of another question, which is related, but more specific to Timers and Global Variables so I'll post that in another thread. Sorry.
Whattya think?
Did I get the question in there?
I want to Quantise the Triggering of several Timers.
Generalities & pseudocode perfectly fine