Sunday, May 04, 2008

MIDI Clock --> Sync 24 Interface


I have made a MIDI Clock --> Sync 24 Interface. Actually, I don't know if it is strictly Sync 24 compatible, because read varying specs on what exactly is the correct pulse length for each timing tick (@ 24ppqn).

The interface interprets the real time sys ex message bytes 0xFA ('start'), 0xFC ('stop') and 0xF8 ('clock') and thereby controls the start/stop and the sync pulse lines of the Sync 24 protocol.

But, it seems to work great with Prophet 64 (a program on Commodore 64), which is what I made it for. Obviously, Prophet 64 accepts Sync 24 as a synchronisation signal.

Demo Video of slaving Prophet 64 to Ableton Live: http://youtube.com/watch?v=s_J6jltUfQg

Something cool that happened while I was working on this little project, is that when I applied more than 5V to the C64 userport (eg. 5.5V), the Commodore video signal became all glitchy, like this:
The music would still play and pause, and i could still sort of navigate through menus and such. It was definitely entertaining.

Anyway, I will post schematics and code once I am happy (the only problem might be the power source of around 5.5V coming from my computer...).

21 comments:

dontmarryme said...

hi i m a student from Taiwan, i m a newbie to arduino and max.
i have some question for u and it'll be great if u help me!
how do i control my arduino board with 4021 chip?
cause i wanna make a tiny drum machine or a sequencer therefore i need multi input which are 32 swiches. I wanna use maxduino to control it cause i m more familiar to that interface. If i can't do so, than wat else can i do?
the link of maxduino:
http://www.parasitaere-kapazitaeten.net/max_msp/pduino_for_max

thx very much

Luka

dontmarryme said...

and oops...
my gmail is
dontmarryme@gmail.com

thx again

Sebastian Tomczak said...

Hi there,
I would recommend reading this tutorial on how to use the 4021 with Arduino: http://www.arduino.cc/en/Tutorial/ShiftIn

If you ned any help beyond this, please let me know.

dontmarryme said...

thx for the link and i made it by following it.
and i have a new question:
i've heard ur soundtrack and its amazing!
how do u handle with the pitch? (like Cmaj Dm...etc) or do u use midi?
i wanna make my own sequencer with just cycle and phasor but no midi and sampling, how do i make the sound more layer?
and i use "mtof" to tune my sequencer but i have to make each track's frequency very separately cause they combine together when they are in same frequency, like 2 cycle both in frequency 1000, you hear one single sound, however, is there any way to make different pitch ?

Sebastian Tomczak said...

Hi Luka,
1) Which 'soundtrack' of mine are you referring to?

2) I am not quite understanding your question -- are you able to rephrase it?

Cheers,
Sebastian

Unknown said...

1. sorry...i meant disasterpiece: level.

2. I dont even quite understand my question as well....anyway...
fist of all, i wanna make a sequencer with msp, so i wanna ask u do u use only just maxmsp?
second, how do i make a 16 analogin, 16 digitalin to maxmsp? i use 4021 chip, i need code of arduino and max.pat.
3rd, i wanna make an installation with sound and light, similar to violin but its anotherthing....i have to learn the first 2 things!
sorry to trouble u a lot and thx for ur answering!

Sebastian Tomczak said...

1. Yes, the album Level by the artist Disasterpiece is simply amazing! Something I have been listening to quite a bit this year so far.

2. You can get 16 analog in and 16 digital in quite easily into Max/MSP. You might like to use 2 x 4051 or 1 x 4067 multiplexers to get the 16 analog inputs.

The 16 digital inputs can be obtained by using 2 x 4021 ICs, for example.

Then it is simply a matter of writing a sketch for Arduino that takes these values and sends them to Max/MSP.

Perhaps an easy, easy way to do it would be via hardware-based MIDI, so you have a MIDI interface on the computer and a MIDI output on the Arduino.

The Arduino then sends information via, say, MIDI CC data and/or note on/off data.

Actually, I have done some similar sort of things in the past (at least, you can get some idea), like here and here.

3. Hmm. Cool!

dontmarryme said...

oh my!
the second "here" is want! ur really helping lol
actually i have already make it 16 switches
(well...sorry to keep bothering u here, if u feel any uncomfortable for i make question here i can send u mail.)
but how do i handle the data in MAX/MSP? i use this code
http://www.arduino.cc/en/Tutorial/ShftIn21
i can see the data but i cant separate them into 16 port, shall i use delay or something?

dontmarryme said...

for return ur favor, this is my recently project, hope u will like it!
http://www.flickr.com/photos/chasingafterdeer/

http://tw.youtube.com/watch?v=z0cvvUUs3CM

Sebastian Tomczak said...

Okay, the way I see it, you have two options:

1) Use the USB and serial connection, and use some sort of identifier byte so that you can separate the two or four bytes.

Then, you could use the sto.1b8b object that you can find hereto separate each bit from each byte.

You need to change the following code:
Serial.println(switchVar1, BIN);
Serial.println(switchVar2, BIN);

//white space
Serial.println("-------------------");
//delay so all these print satements can keep up.
delay(500);

To this:

Serial.print('S');
Serial.print(switchVar);
Serial.print(switchVar2);
Serial.print('E');
delay(20);


Then S is your identifier for start and E is your identifier for the end, for example. Use an itoa object to determine which byte is S and which is E.

OR you could

2) Create a MIDI output circuit, as found here. (just the MIDI connector connected to TX).

And then print out the data directly to MIDI, and then pick up the data on a MIDI interface connected to the computer. You would need to do the following:

a) change the serial transfer baud rate to 31250

b) You need to change the following code:
Serial.println(switchVar1, BIN);
Serial.println(switchVar2, BIN);

//white space
Serial.println("-------------------");
//delay so all these print satements can keep up.
delay(500);

to this:

for(int i = 7; i >= 0; i --) {
byte data;
data = (switchVar1 >> i) & (B0000001);
printByte(B10110000);
printByte(i);
printByte(data);

data = (switchVar2 >> i) & (B0000001);
printByte(B10110000); // cc and channel
printByte(i + 8); // cc number
printByte(data << 6); // 64 for on, 0 for off
}


}

delay(20);


This code is an example, and I have just written it from the top of my head so it might not parse or be correct! But it gives you an idea...



Just some stuff to get you going eh!

dontmarryme said...

thank u very much i m geting really colse! pls help me with this:
now i can read the whole data in max, but now the problem is
1. how do i combine a list like "1 0 0 0 1 0 0 0" into a number "10001000" ? or u have another idea? even i make it into a number, its still not smart cause its too many.

second, i tried to make 64 switches with just simply add another 6 switchvar: ("?" means i dont know wat to type there)

byte switchVar1 = 72; //01001000
byte switchVar2 = 159; //10011111
byte switchVar3 = ???
byte switchVar4 = ???

switchVar1 = shiftIn(dataPin, clockPin);
switchVar2 = shiftIn(dataPin, clockPin);
switchVar3 = shiftIn(dataPin, clockPin);
switchVar4 = shiftIn(dataPin, clockPin);

Serial.print('S');
Serial.print(switchVar1, BIN);
Serial.print('M');
Serial.print(switchVar2, BIN);
Serial.print('Q');
Serial.print(switchVar3, BIN);
Serial.print('E');
Serial.print(switchVar4, BIN);
delay(500);


3. and it doesnt work, why?

I do the serial.print('Q') between each line so that i can tell wich var is it.

4. and i cant find out where should i use sto.1b8b, cause i use BIN not BYTE?

Unknown said...

Hi Little Scale,
Really like your midi projects - they've been really inspirational!

I'm trying to make a wireless midi interface using two arduino boards and xbee shields - the xbee shields don't run at 31250 baud. Do you know if you can use two baud rates? or send information at a lower baud rate and then output the information from the recieving arduino at the higher 31250 baud rate?

Any help would be appreciated!

Best,

Ben

Unknown said...

Hi Little Scale,
Really like your midi projects - they've been really inspirational!

I'm trying to make a wireless midi interface using two arduino boards and xbee shields - the xbee shields don't run at 31250 baud. Do you know if you can use two baud rates? or send information at a lower baud rate and then output the information from the recieving arduino at the higher 31250 baud rate?

Any help would be appreciated!

Best,

Ben

Sebastian Tomczak said...

Hi there,
Hmm, that's a tough one. You might try to get hold of a discrete baud rate converter chip. That's the only thing that comes to mind.

Anonymous said...

hi,today i've tryied to sync 2 macbook black running traktor pro...but the sync was not...in syc...any idea?i've used the leopard's midi over ip built in utility...

Sebastian Tomczak said...

Hi Silent,
Which programs are you trying to sync?

Cheers,

Seb

Anonymous said...

Traktor Pro,but i need to sync 2 traktor pro and 1 ableton live

Sebastian Tomczak said...

Silent,
Im sure you know that you can place an offset in ms in Ableton Live for the sync clock.

If that still doesn't help, why not try physical MIDI connections using very cheap USB MIDI interfaces?

- Seb

Anonymous said...

If this solution works...yes...but...works great?!

Anonymous said...

hey
maybe a good idea to try this free program midiclock. it has dual clock output, you can route one signal internally, and the other to a cheap external interface (converting to sync 24 if you want).

I downloaded it from
http://www.midiclock.com/ .
Works ok for my experiments

cheers
Berthold

Tom Milnes said...

Hi,

Did you ever post the schematic and code for te DIN sync 24 converter? Would love to make my own.
Thanks,
Tom