Sync MIDI generation in AudioPlugin


Okay, i’m a bit dumb at 3:27am!

Just trying to figure out how one should sensibly generate midi to a plugin output?

i know i need to stick a MidiMessage into the MidiBuffer, and it needs to have an appropriate sample offset from the current position. Do I calculate the current position using the current time (from the posinfo) and the sample rate?

I know this is a really greedy thing to ask, but I’d sure love some guidance!

Here’s a simple example someone may be able to provide to help me get started:

How would I generate a MIDI note at the start of every bar?


Yes, the maths can be a bit of a pain, but the posinfo and sample rate should give you enough info to calculate it.