Question to Sequencer Plugin - Timing issue (SOLVED)



currently I'm trying out JUCE and i would like to develop a VST sequencer with JUCE ( i like ! ).
Before i have developed a standalone sequencer with a own event loop, midi out etc ( Qt, RtMidi )...

In the standalone sequencer i have a timer and a callback after time X - time X has the duration of one clock step ( e.g. 96 per bar ). At every callback i do send the midi messages for this tick and after i do calculations for the next tick...

In the JUCE AudioProcessor::processBlock i get a periodical callback from the host and can calculate my ticks ( like in the examples ), but it's not guaranteed to get a callback for every “tick” or get more than one at each tick - right?

How to send a midi message at the correct tick pos?
Is there a way to set a delay to a midi message, push it in the MidiBuffer and the host will send it if the time is come?
Or is there an other way to get "clock" positions from the host? :-)

Or do I think completely wrong?

Any comment, a code snipped or open project is welcome.




Ok, now I understand how to do.

I have to calculate if the next tick event will be in the size/time of the current buffer and set numSamples in the addEvent() methode for the "delay".




Sounds about right!




would it be possible to provide a small code example for this?
many thanks!