Arduino Trigger-to-MIDI converter

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?

Bookmark the permalink.

6 Responses to Arduino Trigger-to-MIDI converter

  1. BlackDiscoBall says:

    Just built this and it seems to work great. Im new to the whole arduino world would it be easy to implement a trigger out that you could easily adjust the output voltage and pulse width?

  2. Pingback: Monotribe and Gate to Midi converter. « blackdiscoball

  3. BlackDiscoBall says:

    One more thing, (and more useful) how hard would it be to add a switch (multiswitch) to select between a number of different ppqn so you could do half time, regular time, and double time?

  4. glacial23 says:

    It probably wouldn’t be really hard, though I’d worry that timing the pulse width would mess with the timing of the MIDI sync. You’d have to use one of the PWM pins to vary the output voltage.

    What would you be connecting this trigger out to?

  5. glacial23 says:

    This is something I had thought about doing, but never got around to (I don’t even have a finished one of these- I just threw it together on a breadboard and only used it for a few months…)

    Code-wise, you could maybe change DIVIDE_SLICE from a #define to a variable, and set it depending on the condition of the switch pins- 3 to set the output to 12 ppqn, or set it to 12 for 48 ppqn.

  6. BlackDiscoBall says:

    Thanks. I will have to start messing around with the code and see what I can do. This is my first Arduino project and I’ve never coded before so its a little daunting but I will start checking the site and see what I can find. Thanks.

Leave a Reply

Your email address will not be published.