[sdiy] midi and clock sync (fault analysis)

Dave Kendall davekendall at ntlworld.com
Mon Dec 28 19:21:52 CET 2009


Hi Julian.

Sending MIDI clocks *and* MIDI NOTES from the same physical MIDI port 
will always produce a small timing discrepancy at the receiving device, 
however minor.
The MIDI CLOCK message is a single byte of 320 uSec long. A MIDI note 
consists of 3 bytes in series for NOTE-ON (nearly 1 mS), and another 3 
bytes for NOTE-OFF.

As MIDI is a serial interface - *something* has to come first. In the 
tests I have done with a home-built MIDI CLOCK to pulse decoder, MIDI 
CLOCKS take precedence over notes. It is quite possible that a MIDI 
CLOCK will be sent in the middle of the 3 NOTE-ON bytes, further 
delaying the note, as all 3 bytes have to be decoded before the 
receiving device knows what note it is.
Add to that the fact that a single byte MIDI START message is sent when 
the sequencer is started, followed by MIDI CLOCKS, the first MIDI 
NOTE-ON sent will be late, so your data is not surprising. The 
resolution of the sequencer you are using will also have an effect on 
what time the recorded data is displayed as.

When some sequencers are started, they also send out MIDI PROGRAM 
CHANGE data, sometimes with added MIDI BANK CHANGE data (continuous 
controllers 0 and 32) and sometimes an initial volume (CC7), or other 
controller start positions. The Kurzweil K2000 does this for example 
when it's sequencer is started.
Any MIDI merging will only make things worse, as the data has to be 
processed before continuing on it's journey.

A work-around for using MIDI CLOCKS with a computer sequencer, is to 
dedicate a physical MIDI out port from the your MIDI interface to 
*only* carry MIDI clock info.
Note and controller data is then sent from another port. This is not 
always possible depending on the receiving device, but when it is, it 
lessens or removes the problem.

Having a count-in bar at the start can get round the 
first-note-being-late problem.

Hope this helps,

cheers,
Dave


On Dec 28, 2009, at 17:03, Julian wrote:

> Hello,
>
> I am trying to get to the bottom of an issue here and not having a lot 
> of luck.
>
> I have a machine, a x0xb0x, that appears to be working fine, however, 
> the owner says that if they clock another machine to it, using midi 
> clock, the sync is not correct.
>
> To illustrate this they have sent me an audio file with the x0xb0x 
> syncing their drum machine's sequencer (which plays a 4/4 pattern of 
> rim shots), whilst, at the same time, triggering rimshots in the same 
> sequence over midi, onto the same machine (ie the x0xb0x acts as a 
> sync master, and as a midi sequencer - half the rimshots are triggered 
> on the drum machine by its own sequencer and half by midi note on 
> commands comming from the x0xb0x)
>
> The audio file clearly has the rimshot hits happening at different 
> times (minior, but easily percieved)
>
> I am looking at the machine in question now, and trying to work out 
> what is going on.
>
> I have tried two tests -
>
> Clocking my P3 sequencer to the x0xb0x and analysing the output of the 
> P3s single midi out port (the p3 has a software midi merge, so i can 
> analyse the x0xb0x and p3s output on a single midi wire)
>
> ...and,
>
> The same test, but using a midi thru after the x0xb0x, so i can look 
> at the midi stream from the x0xb0x and the synced p3, but on two 
> independant midi ports (in this case a midi sport device).
>
> I ran both tests to make certain that the P3s merge function was not 
> quantising at all.  Both tests produced the same results.
>
>
> My results using 2 ports (theres more of my comments below!) -
> (evrey 1st 16th from the p3 is a G, not a C, just to illustrate bars)
>
> port-note-event-time
> 1-C 3-Note On-Time in Decimal is 250695
> 8-G 1-Note On-Time in Decimal is 250704 >>> Difference is 9
> 1-C 3-Note On-Time in Decimal is 250824
> 8-E 4-Note On-Time in Decimal is 250824 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 250952
> 8-E 4-Note On-Time in Decimal is 250952 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 251080
> 8-E 4-Note On-Time in Decimal is 251080 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 251209
> 8-E 4-Note On-Time in Decimal is 251210 >>> Difference is 1
> 1-C 3-Note On-Time in Decimal is 251338
> 8-E 4-Note On-Time in Decimal is 251338 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 251466
> 8-E 4-Note On-Time in Decimal is 251466 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 251594
> 8-E 4-Note On-Time in Decimal is 251594 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 251721
> 8-E 4-Note On-Time in Decimal is 251722 >>> Difference is 1
> 1-C 3-Note On-Time in Decimal is 251850
> 8-E 4-Note On-Time in Decimal is 251850 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 251978
> 8-E 4-Note On-Time in Decimal is 251978 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 252106
> 8-E 4-Note On-Time in Decimal is 252106 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 252234
> 8-E 4-Note On-Time in Decimal is 252235 >>> Difference is 1
> 1-C 3-Note On-Time in Decimal is 252362
> 8-E 4-Note On-Time in Decimal is 252363 >>> Difference is 1
> 1-C 3-Note On-Time in Decimal is 252491
> 8-E 4-Note On-Time in Decimal is 252491 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 252619
> 8-E 4-Note On-Time in Decimal is 252619 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 252747
> 8-G 1-Note On-Time in Decimal is 252747 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 252875
> 8-E 4-Note On-Time in Decimal is 252877 >>> Difference is 2
> 1-C 3-Note On-Time in Decimal is 253005
> 8-E 4-Note On-Time in Decimal is 253005 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 253133
> 8-E 4-Note On-Time in Decimal is 253133 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 253261
> 8-E 4-Note On-Time in Decimal is 253261 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 253388
> 8-E 4-Note On-Time in Decimal is 253389 >>> Difference is 1
> 1-C 3-Note On-Time in Decimal is 253517
> 8-E 4-Note On-Time in Decimal is 253517 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 253645
> 8-E 4-Note On-Time in Decimal is 253645 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 253773
> 8-E 4-Note On-Time in Decimal is 253773 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 253901
> 8-E 4-Note On-Time in Decimal is 253902 >>> Difference is 1
> 1-C 3-Note On-Time in Decimal is 254029
> 8-E 4-Note On-Time in Decimal is 254030 >>> Difference is 1
> 1-C 3-Note On-Time in Decimal is 254158
> 8-E 4-Note On-Time in Decimal is 254158 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 254286
> 8-E 4-Note On-Time in Decimal is 254286 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 254414
> 8-E 4-Note On-Time in Decimal is 254415 >>> Difference is 1
> 1-C 3-Note On-Time in Decimal is 254542
> 8-E 4-Note On-Time in Decimal is 254544 >>> Difference is 2
> 1-C 3-Note On-Time in Decimal is 254672
> 8-E 4-Note On-Time in Decimal is 254672 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 254800
> 8-G 1-Note On-Time in Decimal is 254800 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 254927
> 8-E 4-Note On-Time in Decimal is 254927 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 255055
> 8-E 4-Note On-Time in Decimal is 255056 >>> Difference is 1
> 1-C 3-Note On-Time in Decimal is 255184
> 8-E 4-Note On-Time in Decimal is 255184 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 255312
> 8-E 4-Note On-Time in Decimal is 255312 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 255440
> 8-E 4-Note On-Time in Decimal is 255440 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 255568
> 8-E 4-Note On-Time in Decimal is 255569 >>> Difference is 1
> 1-C 3-Note On-Time in Decimal is 255696
> 8-E 4-Note On-Time in Decimal is 255697 >>> Difference is 1
> 1-C 3-Note On-Time in Decimal is 255825
> 8-E 4-Note On-Time in Decimal is 255825 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 255953
> 8-E 4-Note On-Time in Decimal is 255953 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 256081
> 8-E 4-Note On-Time in Decimal is 256082 >>> Difference is 1
> 1-C 3-Note On-Time in Decimal is 256209
> 8-E 4-Note On-Time in Decimal is 256210 >>> Difference is 1
> 1-C 3-Note On-Time in Decimal is 256339
> 8-E 4-Note On-Time in Decimal is 256339 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 256467
> 8-E 4-Note On-Time in Decimal is 256467 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 256594
> 8-E 4-Note On-Time in Decimal is 256594 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 256722
> 8-E 4-Note On-Time in Decimal is 256723 >>> Difference is 1
> 1-C 3-Note On-Time in Decimal is 256851
> 8-G 1-Note On-Time in Decimal is 256851 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 256979
> 8-E 4-Note On-Time in Decimal is 256979 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 257107
> 8-E 4-Note On-Time in Decimal is 257107 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 257235
> 8-E 4-Note On-Time in Decimal is 257236 >>> Difference is 1
> 1-C 3-Note On-Time in Decimal is 257364
> 8-E 4-Note On-Time in Decimal is 257364 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 257492
> 8-E 4-Note On-Time in Decimal is 257492 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 257620
> 8-E 4-Note On-Time in Decimal is 257620 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 257748
> 8-E 4-Note On-Time in Decimal is 257749 >>> Difference is 1
> 1-C 3-Note On-Time in Decimal is 257876
> 8-E 4-Note On-Time in Decimal is 257877 >>> Difference is 1
> 1-C 3-Note On-Time in Decimal is 258006
> 8-E 4-Note On-Time in Decimal is 258006 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 258134
> 8-E 4-Note On-Time in Decimal is 258134 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 258261
> 8-E 4-Note On-Time in Decimal is 258261 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 258389
> 8-E 4-Note On-Time in Decimal is 258390 >>> Difference is 1
> 1-C 3-Note On-Time in Decimal is 258518
> 8-E 4-Note On-Time in Decimal is 258518 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 258646
> 8-E 4-Note On-Time in Decimal is 258646 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 258774
> 8-E 4-Note On-Time in Decimal is 258774 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 258902
> 8-G 1-Note On-Time in Decimal is 258903 >>> Difference is 1
> 1-C 3-Note On-Time in Decimal is 259031
> 8-E 4-Note On-Time in Decimal is 259031 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 259159
> 8-E 4-Note On-Time in Decimal is 259159 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 259287
> 8-E 4-Note On-Time in Decimal is 259287 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 259415
> 8-E 4-Note On-Time in Decimal is 259416 >>> Difference is 1
> 1-C 3-Note On-Time in Decimal is 259543
> 8-E 4-Note On-Time in Decimal is 259544 >>> Difference is 1
> 1-C 3-Note On-Time in Decimal is 259673
> 8-E 4-Note On-Time in Decimal is 259673 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 259801
> 8-E 4-Note On-Time in Decimal is 259801 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 259928
> 8-E 4-Note On-Time in Decimal is 259928 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 260056
> 8-E 4-Note On-Time in Decimal is 260057 >>> Difference is 1
> 1-C 3-Note On-Time in Decimal is 260185
> 8-E 4-Note On-Time in Decimal is 260185 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 260313
> 8-E 4-Note On-Time in Decimal is 260313 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 260441
> 8-E 4-Note On-Time in Decimal is 260441 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 260569
> 8-E 4-Note On-Time in Decimal is 260570 >>> Difference is 1
> 1-C 3-Note On-Time in Decimal is 260698
> 8-E 4-Note On-Time in Decimal is 260698 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 260826
> 8-E 4-Note On-Time in Decimal is 260826 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 260954
> 8-G 1-Note On-Time in Decimal is 260954 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 261082
> 8-E 4-Note On-Time in Decimal is 261083 >>> Difference is 1
> 1-C 3-Note On-Time in Decimal is 261210
> 8-E 4-Note On-Time in Decimal is 261211 >>> Difference is 1
> 1-C 3-Note On-Time in Decimal is 261340
> 8-E 4-Note On-Time in Decimal is 261340 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 261468
> 8-E 4-Note On-Time in Decimal is 261468 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 261595
> 8-E 4-Note On-Time in Decimal is 261595 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 261723
> 8-E 4-Note On-Time in Decimal is 261724 >>> Difference is 1
> 1-C 3-Note On-Time in Decimal is 261852
> 8-E 4-Note On-Time in Decimal is 261852 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 261980
> 8-E 4-Note On-Time in Decimal is 261980 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 262108
> 8-E 4-Note On-Time in Decimal is 262108 >>> Difference is 0
> 1-C 3-Note On-Time in Decimal is 262236
> 8-E 4-Note On-Time in Decimal is 262237 >>> Difference is 1
> 1-C 3-Note On-Time in Decimal is 262365
> 8-E 4-Note On-Time in Decimal is 262365 >>> Difference is 0
>
>
> Now, im checking against a referance machine, and the results are 
> identical, appart from the first pair of notes.  On this problem 
> machine the first synced note has a lag of 9ms against the note played 
> by the master device.
>
> Now i personally would not have thought that to be significant, 
> however, it is the only difference i can detect at all.
>
>
> At this point im confused!
>
> Can anyone make any comment to shed any possible light on this?
>
> Thank you,
> Julian
>
>
>
> _______________________________________________
> Synth-diy mailing list
> Synth-diy at synth-diy.org
> http://synth-diy.org/mailman/listinfo/synth-diy
>



More information about the Synth-diy mailing list