phasor~ to midi clock [midi mssg 248]

Jun 6, 2006 at 12:39am

phasor~ to midi clock [midi mssg 248]

I appologize if I’m showing all of the wetness behind my ears but I’m having such a hard time at this. The goal is a stable sync between Max/MSP and Logic. Right now I’ve got a patch which works okay but drifts. I know I’ve got something set up wrong so if anyone can tell me what I need to change I’d appreciate it.

What I’ve got so far:

[90] BPM
[!/ 6000]
[!/ 1000]
[phasor~]
[rate~ 0.04166]
[>~ 0.5]
[edge~]
[248]
[midiout]

I read elsewher that I should be using wave~ instead of edge~ but am uncertain as to how to implement that in this patch. Just swapping them out doesn’t work.

Any help is appreciated.

#26311
Jun 6, 2006 at 6:41am

I’m using [edge] as well. It is, as it states in the documentation, less than perfect, but after a few experiments with other solutions, I couldn’t locate anything better. One thing which made alot of difference, however, was to set the max-scheduler to be in audio-interrupt. Now, at least, the [timer] and [metro] objects have the same timing as the [phasors]. Another thing which I noticed is that when I was using my laptop’s internal soundcard, there were pauses in the audio-rate signal, but not when I use my external sound-device.

It has been a since I used it, but all of my experiences with midi-clock were unsatisfactory. The sync was normally alright, but starting and stopping was sloppy at best.

Why don’t you use [rewire]?

Dayton

#78414
Jun 6, 2006 at 11:05am

i find

phasor~ > change~ > ==~ -1 > edge~ > to work well for syncing to phasor…but i think you might want to look at the [sync~] object..

#78415
Jun 6, 2006 at 11:23am

Quote: Dayton wrote on Tue, 06 June 2006 00:41
—————————————————-
>
> Why don’t you use [rewire]?
>
> Dayton
—————————————————-

I always get an error in Max when trying to rewire asking me if I’m sure rewire is connected. I’ll try again though.

#78416
Jun 6, 2006 at 1:45pm

sondod,
I found this midi clock patch on the web somewhere (can’t remember where). It may have been here:
http://www.synthesisters.com/hypermail/max-msp/Sep05/30579.h tml

Anyway, it does not use [phasor~] but seems to work well. Look inside the [p MidiClockOut] subpatch to see how it is working.

Hope this is helpful,
Mitch

max v2;
#N vpatcher 276 156 587 354;
#P window setfont “Fixedwidth Serif” 12.;
#P window linecount 1;
#P newex 231 134 58 1441804 midiout;
#P button 231 87 15 15;
#P message 231 66 51 1441804 goto 0;
#P hidden message 35 46 30 1441804 120;
#P hidden newex 35 24 64 1441804 loadbang;
#N vpatcher 171 447 652 702;
#P origin 0 3;
#P outlet 407 211 15 0;
#P window setfont “Fixedwidth Serif” 12.;
#P message 407 171 58 1441804 242 0 0;
#P inlet 407 35 15 0;
#P outlet 15 211 15 0;
#P inlet 346 35 15 0;
#P inlet 285 35 15 0;
#P inlet 224 35 15 0;
#P inlet 69 35 15 0;
#P message 34 122 15 1441804 0;
#P message 15 122 15 1441804 1;
#P newex 346 171 58 1441804 int 251;
#P flonum 69 84 35 12 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 69 59 154 1441804 expr 60000./($f1*24.);
#P newex 285 171 58 1441804 int 252;
#P newex 224 171 58 1441804 int 250;
#P newex 15 171 58 1441804 int 248;
#P newex 15 146 64 1441804 metro 12;
#P fasten 12 0 7 0 351 109 20 109;
#P fasten 10 0 7 0 229 113 20 113;
#P connect 7 0 0 0;
#P connect 8 0 0 0;
#P connect 0 0 1 0;
#P connect 1 0 13 0;
#P fasten 11 0 8 0 290 117 39 117;
#P connect 9 0 4 0;
#P connect 4 0 5 0;
#P connect 5 0 0 1;
#P connect 10 0 2 0;
#P connect 11 0 3 0;
#P connect 12 0 6 0;
#P connect 14 0 15 0;
#P fasten 1 0 16 0 20 205 412 205;
#P connect 15 0 16 0;
#P fasten 6 0 16 0 351 196 412 196;
#P fasten 3 0 16 0 290 199 412 199;
#P fasten 2 0 16 0 229 202 412 202;
#P pop;
#P newobj 35 108 206 1441804 p MidiClockOut;
#B color 6;
#P button 182 87 15 9;
#P message 182 66 34 1441804 cont;
#P button 133 87 15 8;
#P message 133 66 34 1441804 stop;
#P button 84 87 15 7;
#P message 84 66 44 1441804 start;
#P comment 25 152 34 1441804 tick;
#P button 35 134 15 0;
#P flonum 35 66 41 12 0 0 4 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont “Sans Serif” 9.;
#P comment 107 158 180 196617 Klangwerkstatt ;
#P hidden connect 11 0 12 0;
#P hidden connect 12 0 1 0;
#P connect 1 0 10 0;
#P connect 10 0 2 0;
#P connect 4 0 5 0;
#P connect 5 0 10 1;
#P connect 6 0 7 0;
#P connect 7 0 10 2;
#P connect 8 0 9 0;
#P connect 9 0 10 3;
#P connect 13 0 14 0;
#P connect 14 0 10 4;
#P connect 10 1 15 0;
#P pop;

#78417
Jun 6, 2006 at 7:34pm

Sondod, I assume you’re on a mac, since you mention Logic. I also assume you’re on OSX.Here’s the bad news…

MaxMsp timing and OSX is not a happy union. OS9 was fine, apparently Windows is fine – which is why I’m considering an Intel model – but OSX, with its multithreaded this and preemptive that, seems to cause serious scheduling problems for non-audio stuff. Like midi sync.

I’ve worked hard at this, and although some tweeking improves the situation, I still take a roland groove box to gigs just for the midi sync.

However:

Don’t assume small IO buffers are better for timing (as with latency), since larger buffers give audio breathing space, which in turn leaves more time for non-audio. = better midi timing.
The audio interrupt thing is fine as long as you have very little midi going on, for example only sync.

Why not use Logic as master ?

#78418
Jun 7, 2006 at 11:32am

Well I finally got the rewire working and it’s sync is much better than phasor~. The only problem is that Logic starts crashing. I’m thinking this will require my getting Logic 7.2 which was supposed to improve ReWire. If it ain’t one thing its another.

#78419
Jun 8, 2006 at 8:38am

PL wrote:
> Right now I’ve got a patch which works okay but drifts.

How do you find out that it drifts? This might lead you to the reason
why it does. Does it miss some midiclocks? (count them) does it not
syncronize? (set Logic to syncronize)….

Stefan


Stefan Tiedje————x——-
–_____———–|————–
–(_|_ —-|—–|—–()——-
– _|_)—-|—–()————–
———-()——–www.ccmix.com

#78420
Jun 9, 2006 at 4:34am

Try this one
It’s been working for me fine; no drifts

max v2;
#N vpatcher 40 55 440 355;
#P comment 479 52 30 196617 -jhno;
#P comment 428 355 37 196617 default;
#P comment 440 381 25 196617 max;
#P comment 443 328 22 196617 min;
#P message 466 321 82 196617 ; max interval 1;
#P comment 465 410 108 196617 set scheduler interval;
#P message 466 348 82 196617 ; max interval 5;
#P message 466 375 82 196617 ; max interval 20;
#P comment 242 410 202 196617 scheduler interval (ms
between “ticks” ->;
#P comment 242 397 147 196617 audio interrupt (DSP
Status);
#P comment 242 384 147 196617 overdrive;
#P comment 242 371 147 196617 signal vector size (DSP
Status);
#P comment 242 358 147 196617 sampling rate (DSP
Status);
#P comment 242 335 147 196617 timing accuracy is
affected by:;
#P comment 465 188 83 196617 MIDI beat clock: tick ,
stop , start;
#P message 517 223 26 196617 250;
#P message 491 223 26 196617 252;
#P comment 378 93 121 196617 24 ticks per quarter
note;
#P toggle 250 30 15 0;
#P newex 250 51 29 196617 dac~;
#P comment 190 300 46 196617 delta ms;
#P comment 236 300 68 196617 quarter count;
#P newex 190 220 56 196617 t b b b;
#P number 190 279 46 9 0 0 0 3 0 0 0 221 221 221 222
222 222 0 0 0;
#P newex 190 248 33 196617 timer;
#P newex 190 115 74 196617 pong~ 1 0. 1.;
#P newex 190 92 33 196617 *~ 4.;
#P number 236 279 53 9 0 0 0 3 0 0 0 221 221 221 222
222 222 0 0 0;
#N counter;
#X flags 0 0;
#P newobj 236 248 66 196617 counter;
#P newex 190 168 31 196617 < ~ 0.;
#P newex 190 141 35 196617 delta~;
#P newex 190 192 34 196617 edge~;
#P comment 40 300 46 196617 delta ms;
#P comment 86 300 49 196617 bar count;
#P newex 40 220 56 196617 t b b b;
#P number 40 279 46 9 0 0 0 3 0 0 0 221 221 221 222
222 222 0 0 0;
#P newex 40 248 33 196617 timer;
#P number 86 279 53 9 0 0 0 3 0 0 0 221 221 221 222
222 222 0 0 0;
#N counter;
#X flags 0 0;
#P newobj 86 248 66 196617 counter;
#P comment 326 300 46 196617 delta ms;
#P comment 379 300 51 196617 tick count;
#P comment 44 420 167 196617 ticks per bar (should
always be 96);
#P newex 40 141 35 196617 delta~;
#P newex 154 327 27 196617 int;
#P number 154 399 53 9 0 0 0 3 0 0 0 221 221 221 222
222 222 0 0 0;
#P newex 154 350 27 196617 t i i;
#P newex 154 377 27 196617 -;
#P newex 465 248 41 196617 midiout;
#P newex 326 220 56 196617 t b b b;
#P number 326 279 46 9 0 0 0 3 0 0 0 221 221 221 222
222 222 0 0 0;
#P newex 326 248 33 196617 timer;
#P newex 326 115 74 196617 pong~ 1 0. 1.;
#P newex 326 92 39 196617 *~ 96.;
#P flonum 40 30 35 9 0 0 0 3 0 0 0 221 221 221 222 222
222 0 0 0;
#P number 372 279 53 9 0 0 0 3 0 0 0 221 221 221 222
222 222 0 0 0;
#N counter;
#X flags 0 0;
#P newobj 372 248 66 196617 counter;
#P newex 40 51 62 196617 phasor~ 0.5;
#P newex 40 168 31 196617 < ~ 0.;
#P newex 40 192 34 196617 edge~;
#P newex 326 168 31 196617 < ~ 0.;
#P newex 326 141 35 196617 delta~;
#P newex 326 192 34 196617 edge~;
#P message 465 223 26 196617 248;
#P comment 85 30 100 196617 master phasor~ sync;
#P comment 348 33 203 196617 generate MIDI sync from
MSP phasor~ sync;
#P connect 11 0 8 0;
#P connect 8 0 22 0;
#P connect 22 0 7 0;
#P connect 7 0 6 0;
#P connect 6 0 30 0;
#P connect 30 0 28 0;
#P connect 28 0 29 0;
#P connect 30 1 28 1;
#P connect 30 2 26 0;
#P connect 26 0 27 0;
#P fasten 30 2 21 0 91 242 159 242;
#P connect 21 0 19 0;
#P connect 19 1 18 0;
#P connect 18 0 20 0;
#P fasten 10 0 21 1 377 319 176 319;
#P connect 19 0 18 1;
#P fasten 8 0 38 0 45 79 195 79;
#P connect 38 0 39 0;
#P connect 39 0 34 0;
#P connect 34 0 35 0;
#P connect 35 0 33 0;
#P connect 33 0 42 0;
#P connect 42 0 40 0;
#P connect 40 0 41 0;
#P connect 42 1 40 1;
#P connect 42 2 36 0;
#P connect 36 0 37 0;
#P connect 46 0 45 0;
#P fasten 8 0 12 0 45 79 331 79;
#P connect 12 0 13 0;
#P connect 13 0 4 0;
#P connect 4 0 5 0;
#P connect 5 0 3 0;
#P connect 3 0 16 0;
#P connect 16 0 14 0;
#P connect 14 0 15 0;
#P connect 16 1 14 1;
#P connect 16 2 9 0;
#P connect 9 0 10 0;
#P fasten 3 0 2 0 331 216 470 216;
#P fasten 49 0 17 0 522 243 470 243;
#P fasten 48 0 17 0 496 243 470 243;
#P connect 2 0 17 0;
#P pop;

#78421

You must be logged in to reply to this topic.