<br>I've created a very basic MIDI sequence a while ago, and the following is how I done it:<br><br>-"Time" is kept track of using JACK frames, and a BPM. This tells you how many beats (from frame 0) you've played, and what "percentage" or part of beat your in.<br>
<br>-"EventClip" objects have a big vector of "EventClipElement"s, which represent events like NOTE_ON, NOTE_OFF, CC_CHANGE, etc. <br><br>-Process() gets Time information: int currentBeat; float  currentPercent;<br>
<br>-Check if the "time" just went past the next Event in the clip:<br>// start code<br>if ( EventClip->upcomingEvent()->beat == currentBeat )<br>{<br>    if ( EventClip->nextEvent()->percent <= currentPercent)<br>
    {<br>        processEvent(); // write MIDI message in this case<br>        EventClip->goToNextEvent();<br>    }<br>}<br>// end code<br><br>That's pretty much it, now for the caveat's:<br>-Vector's are not RT friendly, so use a List, or reserve *plenty* of space in your vector!<br>
-The EventClip class can be very simple, it only needs a way to quickly retrieve the *next* event, so having a member pointer to the next EventClipElement in the vector will make avoid lots of array access.<br>-If you relocate on the timeline, then you'll have to "search" through the vector to find the right nextEvent. (ie where currentBeat == beat, but currentPercent < eventPercent)<br>
<br>Note this was the first time I got a MIDI sequencer running, and there are probably other ways to do it too... perhaps which provide cleaner code & better readability...<br>Keeping an eye on this :D -Harry<br>