I have a standalone app which sends midi clock, but I'm not managing at all to get it working.
I was looking at the MidiBuffer, and I'm filling a midi buffer like I'm supposed to, but I have no idea *when* to send the midi buffer to the midi output. As the sendBlockOfMessages of the MidiOutput creates new objects ( new PendingMessage (data, len, eventTime) ) I suppose you're not supposed to use it inside the audio thread. However, how do I now work around this while still keeping stable timing?? And, even though I tried about 10 different ways, I can get my message to be sent to the output. I did this:
- Code: Select all
void SomeClass::audioDeviceIOCallback(const float** inputChannelData, int numInputChannels, float** outputChannelData, int numOutputChannels, int numSamples)
{
for (...)
{
midiBuffer.addEvent(MidiEvent(...), positionInSamples); // can positionInSamples be larger than the size of the current block??
}
...
midiOutput->sendBlockOfMessages(midiBuffer, (numSamples*1000.0)/m_SampleRate, m_SampleRate);
// delay one block of samples?? how much should I delay?
// this allocates memory... ouch
midiBuffer.clear()
}
Other than that there seem to be quite a few timing questions in my head, like the millisecondCounterToStartAt in sendBlockOfMessages. As audio buffers aren't really (wall-clock) timestamped in Juce the only way to figure out anything about the wall clock is to do a getTime( ) at the start of the block, but this seems a bit... weird to me.
In general any more pointers towards getting a (stable) midi output clock running would be greatly appreciated!
cheers,
- bram
