Midiclock class

Hi thanks for the reply!

No, my standalone is not a host. Juce is calling throw the audioDeviceIOCallback my processor processBlock method.
In my processBlock method, i call mygenerateMidiClock() function with buffer.getNumSamples and sampleRate as parameters.

In mygenerateMidiClock function:

1/ for the first call i initialize a ppQTime to getMillisecondCounterHiRes();
then for next calls it’s increased by bufferSize*1000.0/sampleRate
2/ i set the value for the AudioPlayHead::CurrentPositionInfo
ppQ is calculated during the processBlock call by a sequencer class, every 32 samples, from tempo, resolution and buffer size.
So it’s calculated from the number of samples passed from the audioCallback.
3/ i call your generateMidiClock with the CurrentPositionInfo, buffersize and sample rate and a cleared MidiBuffer
4/ i pass the buffer and the ppQTime to a High priority thread that will call sendBlockOfMessages with ppQTime

I’ve tried to call directly the sendBlockOfMessages in mygenerateMidiClock (not using a high priority thread)
and still using the ppQTime as parameter along with the buffer filled by your generateMidiClock. I have the same jittering.
Do i have to expect some jittering in that case?

One thing i can do, is :use my standalone as vstplugin (it has both possible configurations) and check if i have the same jittering or not.
I’ll let you know :slight_smile:

Thanks for your time…

Compiling as a plugin is a good idea. May you can also describe a bit better when does the jitter occur.
Is it a constant jitter? If so, have you tried to use the delay in the class?
When I was developing the code I tested with an internal Midi cable rather than using a physical output
as the physical one surely introduces jitter and that is really confusing while designing such a class.

The description of the way you are using the class seems okay to me but I am not using a PPQ value
to pass to the sendBlockOfMessages() method. I do it like this:

dataMidiOut->sendBlockOfMessages(outBuffer, Time::getMillisecondCounterHiRes(), sampleRate);

Joerg

I’ve double checked on Mac. NI Kontakt as clock slave using MAC internal Midi cable…
There is absolute no jitter from what I can hearing.
The latency of my external Midi device must by adjusted by 1100 samples instead (44.1Khz).
The internal Midi cable has around 10 samples; actually it is not noticeable.
The latter one tells me that my code seems to be correct.

The only jitter you may hear is due to the different behavior of some slaves, starting to chase.

Joerg

am I missing something? Where can I find this Midiclock class?

Hi peteblues,

they may have been deleted at the tine the forum went to a new host.
Drop me an pm including your email address and I will share it.

Joerg

1 Like

@Joerg_Koehler - I would love to get a copy of this class. I want to have a crack at writing a VST which sends MIDI clock. For some reason, the forum won’t let me PM you. Maybe it’s because I am a new forum user. Would you mind PMing me your email, so that I can in turn send you my email?

Really appreciate it! :slight_smile: