Welcome to Pete Brown's 10rem.net

First time here? If you are a developer or are interested in Microsoft tools and technology, please consider subscribing to the latest posts.

You may also be interested in my blog archives, the articles section, or some of my lab projects such as the C64 emulator written in Silverlight.

(hide this)

A MIDI clock pulse to analog sync voltage converter

Pete Brown - 31 December 2012

I have a few pieces of analog gear which either don't support MIDI, or simply work better with voltage control. This makes including them in a sequence difficult as timing of arpeggios or sequences will drift away from the rest of the performance. Not to mention that synchronizing them by ear is not a simple task in any case, and impossible to do in real-time if you want to adjust the tempo during the performance.

One such piece is my little Korg Monotribe. This is a combination drum machine and step sequencer built into a very inexpensive package.

The Monotribe doesn't have MIDI support (although you can build a conversion for MIDI), but it does accept a sync pulse. The Aturia Minibrute doesn't send an analog clock pulse, so there was no way to synchronize the two. However, the Minibrute *does* accept MIDI clock pulses from an external source, so I knew I could build on that.

Hybrid Analog/Digital sequencers like the Doepfer Dark Time will handle this synchronization for you, but for a price. I already have one analog sequencer on order, one small one mostly built, and another ready to be built, so I didn't want a third one right now.

The Goal

So the goal is to drive both analog gear as well as more modern MIDI gear from an external MIDI clock. In my case, I decided to use Cubase 7 on my PC as the clock source. The completed setup looks like this:


All the straight MIDI communication just works. The rest of this post will focus on the development of the MIDI to analog sync signal part. First, however, a little background on synchronization.

MIDI sync

MIDI master clocks send out 8 bit synchronization messages at the rate of 24 for every quarter note. At a typical BPM of 120, that means that there are 24 * 120 = 2880 clock messages per minute, or 48 clock messages per second.

The standard MIDI protocol itself is a 5v serial protocol running at 31,250 bits per second with 8 data bits, no parity bits, and 1 stop bit. Most messages are two or three bytes in length, but a number of important messages, such as the real-time messages, are only one byte in length. Also note that messages can be interrupted by real-time messages. So, you could get the "note on" message, and then the clock byte, and then the note on message's data. Any code which parses these messages must handle this gracefully.

Analog Sync

Analog sync pre-dates MIDI clock signals, so there are a number of standards. Roland used a DIN sync for drum machines, TB-303, and others. This is a 5 pin cable which looks like MIDI, but is actually carrying completely different analog signals.

Even older than that is the modular approach of clock pulses. This is typically a 5v square pulse which is used to move a sequencer to the next step. This is the way most analog sequencers synchronize with each other, all sharing a common clock/sync source.

The Korg monotribe is a new design, but follows older analog principles. In this case, the sync signal doesn't need to be 5v. In fact, there are phone apps which use audio level signals from the headphone jack to generate sync pulses for the monotribe. Much like the classic analog approach, the monotribe sync approach is used to move the sequencer from one step to the next.

There are many other devices which can synchronize with signals like this. For example, the Nova Drone drone synth includes LFO sync which should work with this type of signal. (I haven't tried it yet, though).


(Yes, that's a Cthulhu mug. I know I just floored you with the awesomeness of this photo)


I've done a fair bit with MIDI hardware, so I knew generally how to parse messages and otherwise deal with the data. I also have a MIDI module which, although designed for .NET Gadgeteer, includes pins so I can use it with any microcontroller. Real-time processing of MIDI messages like this has proven to be too intense for interpreted code like NETMF, so I turned to my ARM development board. Sure, this is something which could have been easily accomplished on Arduino, but I've been getting into ARM lately, and have had larger plans for the processor.

The development board I used is my Mikroelektronika EasyMX Pro v7 for STM32. the C IDE is a mess compared to Visual Studio, but I can't praise this board enough. It's super easy to develop and debug on it, all over USB.

Because the monotribe runs perfectly fine on low amplitude pulses, the 3.3v signal level from the ARM processor works fine. If you use this approach with other analog gear, you'll likely need to scale the output up to 5v (again, not an issue if you use classic Arduino or AVR which both natively support 5v signals).

Initially, I based the pulses on 64 for some reason. I originally thought MIDI used 64 pulses and not 24. Because of this, the code below is not quite correct (it works, but doesn't correspond to actual beats, so the divisions aren't as useful as they should be).

#define MAX_TICKS 64;

// USART2 TX is PA2
// USART2 RX is PA3


#define SetAllPinsLow() ODR = 0;
#define SetPins(pinMask) ODR = pinMask

char _uartReadByte;

void main() {
unsigned short currentTick = 0;
unsigned short pinsHigh = 0;

GPIO_Digital_Output(&GPIO_BASE, _GPIO_PINMASK_LOW); // Set pins as digital output


Delay_ms(100); // Wait for UART module to stabilize

while (1) {
if (UART2_Data_Ready()) {
_uartReadByte = UART2_Read(); // read the received byte

if (_uartReadByte == MIDI_TIMING_CLOCK) { // if MIDI clock message

pinsHigh=1; // always output full clock on first pin

if (currentTick % 2 == 0) {
pinsHigh |= (1 << 1);

if (currentTick % 4 == 0) {
pinsHigh |= (1 << 2);

if (currentTick % 8 == 0) {
pinsHigh |= (1 << 3);

if (currentTick % 16 == 0) {
pinsHigh |= (1 << 4);

if (currentTick % 32 == 0) {
pinsHigh |= (1 << 5);

if (currentTick % 64 == 0) {
pinsHigh |= (1 << 6);

if (pinsHigh) {



pinsHigh = 0;

currentTick = (currentTick + 1) % MAX_TICKS;


I hate that K&R style of brace indentation, but like I said, the IDE is a mess. If you deviate from that style of indentation, the tabs and whatnot get really screwed up. In fact, they get a little screwed up anyway. IDEs in the microcontroller world are a long way from what we're used to for more mainstream development.


Essentially, the code gets each incoming byte and checks to see if it is a clock message. If so, it checks the current tick to see where we are in the timing and then sets a bitmask to set the pins on a port to high based on that step. It then sets the pins high, sleeps for 1ms, then sets them low again.

When I ran the code, I looked at the pulses using my Saleae Logic 8 channel USB logic analyzer (something which is absolutely indispensible for work like this) and, after some debugging, got the right results:


When you code this low to the metal, timing can be really spot on. I love that!

Here's the full device setup on my mess of a desk:


And here's a full set of timing pulses, without the MIDI clock signal visible:


You can see that each row has a period twice that of the row above it. By connecting to different signal divisions, you can speed up or slow down the slave sequencer, but still keep it in time with the rest of the performance. (Remember, I need to change it to be based on 24, not 64 clocks per quarter note)

What's Next?

I'm going to correct the timing and then develop an inexpensive board around this, possibly including support for TB-303/x0xb0x style DIN sync (including stop/start) in addition to the analog sync. I'll keep a couple around for my studio, but have others for sale. If you're interested, drop me a line via the contact link here and let me know.

I'll also post a recording of the sync working on my Soundcloud page.

Update: Recording is here: https://soundcloud.com/psychlist1972/monotribe-and-modular-sync-test

posted by Pete Brown on Monday, December 31, 2012
filed under:      

2 comments for “A MIDI clock pulse to analog sync voltage converter”

  1. vhnemahkxisays:
    [url=http://www.mariajulianpottery.com/logo/books.cfm?pid=42]ミュウミュウ バッグ 青[/url]
    your best bet is a quality secure. All the more suitable if at all composed especially to suit your check out. many of Tudor's several sought after timepieces, in beliefs dark fabric Bays to our Chrono, have proven to be outfitted with an additional pads strip freed from re-charge. plus in my city, The citibank cash machine at 7 eleven prints gone a treatment plan cheaper cardboard at the bottom of the sales receipt. i've not tried on the extender, yet a person and I tried on the extender to locate Gabapentin bargains anf the husband have found a cheaper area to buy or perhaps prescribed drugs. simply not true assurances, But knowing a good idea auto insurance meet.

    2.3.4. the on-going the legislation puts up a range of intentions, endeavours since frequent assignments over SEPA, particularly in environmental surroundings react 1995 and water Environment and Water assistance (Scotland) behavior 2003. We belief that the wide variety of goals and objectives provided to SEPA courtesy of - contrasting legal routines should made easier as well as changed to reflect the sort of regulator Scotlown personal requirements.

    these kind treaties, Which remained in effect by the start of twenty first century, moreover designate some fundamental limits topical to actually map-reading in a straits. u. s completed a separate treaty accompanied by Denmark because this hadn't want to are involved in the convention regarding the abolition of requirements fees. the usa dreaded that may of specific situations this sort of taking part could possibly be interpreted currently being a exposure of ideal of Denmark that will garnishment costs on vessels in passageway along with Danish Straits,
    [url=http://www.mariajulianpottery.com/logo/books.cfm?pid=421]miumiu 財布 売る き[/url]
    although captivation is in some way listed, We consider that the most recent helpful implementation of you can actually development hooked on Toshiba's high-end pc vary clarifies that it's probably that the company has decided to incorporate Immersion's haptics at the same time it really is completely new supplement. this tends to depict a great earn to receive concentration. Toshiba's Libretto was a niche solution, who is transactions will in all probability hold little with references to royalties to concentration.

    classification: all of near course 7 barbecue grill are hands down extremely in order to be offering up new, your own local what you eat to the Berkshire neighbours as well as,while companions. all of our dishes are often the natural way farmed via community plants nicely little wife and children. really is endless that our close in proximity relationship problems these kinds of farmers have any beneficial toll in sustaining localised producing way of life.

    So i offers real question is why is it necessary this uncommon gift of predominantly message, alternatively reported by users in the holy book, each present regarding discernment? you can could help me remember more. pleased, ), Carl IretonThere are typically two biggest choices readily talk about non secular growth. One necessitates flourishing the wherewithall to have as acknowledge unnatural endures, Such as you have had,

    to sum up, through the 1970s, proper, Nonideological everyone was to suspect that his / her phrase prospective business partners could perhaps be dimmed by way of stultifying condition. individuals were right to imagine that executive was first undermining personalised accountability. everyone was to have the things Tyler Cowen, In a good essay in Cato Unbound, requests the entire vs,v,against.
    [url=http://www.mariajulianpottery.com/logo/books.cfm?pid=255]miumiu バッグ 紐 て[/url]
    in spite of this, if you're groom listens to afterward you he may barely full your man's windows and you will be able to see what kind of internet your is on. or you could break high on the dog determine that he is not on any adult web sites and 's just doing work causing you to look remarkably on your guard. there has to be a great way to fnd out is my husband proceeding adult net sites,

    n', i only say, a lot believe having absolutely remorse anytime here is the done is accomplished. "really? completely, it's possible that providing you take it and no one shoves you to become doing. i had a tad inspired using my father at the start, as they said, 'Don't you can check new york straightaway',

    little christmas day barbeque in Bermuda properly complete along with cassava cake, your Bermuda internal meal for more than 300 ages. it is sweetish food having butter, ova, vanilla flavor, in addition to shredded cassava underlying cause layered who have steak chicken. the main curry is fixed isolated because,since when you're a end eating plan.

    aids brought about by the actual penetrating north Korea11. below Nehru, all of this approach happened with the exception:this. nys spent time on use related to big industriesB. In six seasons the way mayor associated with the dutch manufacturing area, Socialist Francoise Gaspard has built an desirable proof with good care. though for this Sunday's city elections, Madame Gaspard face politics extinction.across the united states, the snags have been changing a nearby elections back into the most demanding test associated web design manager Francois Mitterrand's Socialists magnificent Communist companions simply because found might in may 1981.that time period, typically the visitors anticipations to bring back to effectiveness that have a landslide win. it provides chance: polls let you know Mitterrand's fame holds fallen substantially during the past two prolonged.Lionel Jospin, typically the Socialist person's important assistant, is considered referring to freely from shifting certainly 15 full-size online communities.
  2. Ahmetsays:
    Why i cannot put my wlppaaler correctly ? i have a black screen under my beautiful clock .Then, i have the red slider but the frame is not the same that on the screenshot, it's the default iphone frame . How can i fix it ? Thanks for your answers

Comment on this Post

Remember me