OK, the trigger-to-MIDI clock converter seems relatively happy (though I think the MIDI in on my AN200 isn’t? That’s going to require some more tests…).
I hacked on it a bit tonight trying to determine how drifty the generated MIDI clock was relative to the incoming trigger pulses from the DR-110. At first it was pretty ugly. I then added some compensation to the clocking to account for all of the work the Arduino is doing. After some trial-and-error, it’s relatively tight – total drift by my rough calculations was something like 10 milliseconds over a five minute period. Compare that to an earlier drift of 120 ms in a minute…
Here’s the code: trigger2midisync.pde
Hardware-wise, there’s a trigger input on pin 2 (use a zener if you’re worried about blowing stuff up…), and the MIDI out is the standard (TX, GND, and 5V through a 220 ohm resistor going to the pins of the MIDI port).
You may want to configure some of the #define statements in the code. STOP_TIMEOUT is the amount of time that needed without triggers needed for the converter to decide to stop. I’m using 2 seconds. Changing DIVIDE_SLICE would be important if your trigger source is something other than 4ppqn, and CODE_OVERHEAD_TIME is used to adjust drift in your deployment – 10 worked really well for me in my tests tonight, but it could be anything for others.
Once it’s hooked up and connected to your MIDI source and your trigger source, start sending a series of pulses to pin 2. On the first pulse, MIDI Clock start should get sent, and by the third pulse or so the sync will be “synced” – there will be an offset, but it should remain fairly constant. Now, once the pulses stop, clock will continue to be sent until STOP_TIMEOUT milliseconds have passed.
Next test will be syncing the DR-110 to the very-nearly-finished x0xb0x to see how well that keeps up – I did all my tests tonight with a Yamaha RY10, with both it and the DR110 just playing a “four on the floor” kick pattern.
Questions? Comments? Improvements?