I wrote this in a hurry!
What I mean more specifically is, MIDI clock was designed to operate at 24PPQN.
I need to drive my Roland CR-5000 drum machine at 24PPQN.
I get a MIDI clock pulse, but how do I turn a "one dimensional" clock pulse into a symmetrical square wave at the same frequency?
If I toggle the Teensy pin I am using to drive the CR-5000 clock each time I get a MIDI clock event, I get a very stable clock on the drum machine, but it's half the correct frequency.
bool clockState = LOW;
void myClock() {
if (CLOCK_RUNNING) {
digitalWrite(CLOCK_OUT, clockState);
clockState = !clockState;
}
}
If I make up some number, like I dunno 2200 microseconds, and I take the pin HIGH when I get a clock and then 2222 microseconds later I take the pin LOW, it kinda sometimes works.
But the CR-5000 seems very unforgiving of non-symmetrical clock pulses.
If I measure the interval between MIDI clock events, and turn off the pin at that duration/2, it sorta kinda sometimes works.
I have seen some Teensy projects that measure this duration and keep a running average of the tempo on a timer handler. But does that work well enough to keep non-stumbling time?
How can I get a stable clock for my drum machine, that keeps time to at least the 16th note, at the full clock speed?
Roland proposed the MIDI clock spec, I believe, and Roland & Korg made sync boxes that could read MIDI clock and output the Sync24 "DIN" sync signal.
These sync boxes worked great back then; how did they work?
I have a hard time believing they simply measured the tempo and estimated the output clock based on "dead reckoning", because no way is that good enough to keep time.
How can I make a Teensy keep track of a 5-pin MIDI clock signal and generate the TTL equivalent?