Uija
20
I use a Teensy for all my MIDI related products, as the MIDI and USB MIDI Implementation on that device are awesome. The 4.1 is even capable of USB Host without you doing much.
But: You have to do some soldering to have DIN Midi working:
Hot that is done, is documented on the Teensy page: MIDI Library, For Communication With Musical Instruments
Theoretically you have one Box send a clock, that you listen for in Arduino-Code. Knowing a little bit about MIDI Clock, it is sent 24 times per quarter note. So one bar would be 96 clock pulses.
As soon as you hit Play the first time, you send transport-start and start to count the pulses and reset that count if you reach 96. If you now hit Play again, you wait until you reset the bar-counter and send the transport-start at 0. That way you should sync the devices. If that does not work correctly (and the second device is lagging a tiny bit, you might send the start Before the first clock of the bar, so at 95.
Doing your own clock is a little bit more work. You need to add hardware to the controller to change and see the BPM. You then need to calculate the micoseconds that elapse per clock-pulse and set a interrupt-timer for that:
IntervalTimer timer;
timer.begin(callbackFunction, yourNumberOfMicosecondsPerPulse);
In that callback function you handle the same as you did as reaction on clock pulses and as the code is master-clock now, send a clock pulse yourself.
3 Likes