Right, OK. Thank you. I'm going to strip this back to one Arduino, with 3 LEDs and go from there. I'll write a simple midi file that plays a middle C every bar for 30 seconds. I've done some quick googling, and I think I've got my head around finite state machines. Also converting 0-velocity-ons to offs is OK. What I'm struggling with is time-stamping the events and putting them in a queue - would you mind posting a snippet of code as a starting point?
I think if you actually draw out a timeline on paper it will be clear.
- Events will arrive spaced T milliseconds apart (this will vary, but just consider one event and the time between it and the previous event).
- When event N-1 arrives, record the millis() value against that event. This will trigger the FSM to start for this element.
- Element N arrives a time T after element N-1. This could be more or less than the animation time for one note press, but generally it does not matter as all events are delayed by D milliseconds (equal to 2*time between animation LEDs) .
- When a time T has elapsed from the start of element N-1 animation, you start the animation for element N.
- Because you are using a FSM, the element animations are independent of each other and run the same FSM with different data (hint, using a structure to encapsulate the data to track an element is usually a good idea).
If you go to my blog (https://arduinoplusplus.wordpress.com/) and search for "Finite State Machine" there are several articles I have written about applications + tutorial about FSM.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.