Slave Max to Elektron Midi Clock

jack3l's icon

Hey all,

I am trying to get Max to be slaved to external midi clock from my Elektron Analog Rytm.
I know to use rtin and I have read about using it with Sync~ but I dont know how to use the output of Sync~ correctly.

As a test I have used Ableton and tried to get Sync~ to output correct bpm from its middle port but I have noticed that when I change the bpm on Ableton there is a very big delay before Max matches the bpm. That delay means that Max then becomes out of step

Can anyone help here?

Thanks in advance
Jon

Max Patch
Copy patch and select New From Clipboard in Max.

Source Audio's icon

It is normal for sync~ object to spend some time calculating tempo from incoming midi clock.
It works like tap tempo.
I would not use it for midi sync to external hardware devices.
You will have to implement complete rtin, and include song position pointer
and all that stuff, If You want Midi Beat Clock, with synced Bar, Beat etc

Source Audio's icon
Max Patch
Copy patch and select New From Clipboard in Max.

And here is a patch demonstrating Midi Clock with SPP

jack3l's icon

Wow! Source Audio - thanks so much for your efforts...I really appreciate.

Im not sure how long that would have taken me but Im sure I would still be trying to research how to do it

Thanks again. Legend!!

Source Audio's icon

You are welcome.
That is all stuff from the past time when one had to sync a lot of
hardware gear together.
Nowadays nobody seems to need this, so it is just great to have it back on the table.

bici cletta's icon

Hello, I am interested in a similar setup - using the Elektron Analog Keys as synthesizer and MIDI keyboard but also aiming to sync it with MAX and Jitter for video/open GL playback and real-time effects.

Source Audio - I appreciate the work you have put into the MIDI sync patch. Is there anything I need to add to your patch in order to see e.g. the elapsed notes? I am a MAX beginner, I can see the Analog Keys coming up as a midiin device. But I don't know how to take it from there - since nothing else seems to happen in this patch for me. Thanks.

notno's icon

Thanks from 2020, Source Audio!

Onokio's icon

Yeah, thanks Source Audio, saved me loads of time. <3

gogo's icon

hello.

I'd like to use SOURCE AUDIO's wonderful patch to sync Max with an external sampler, but it's not working.

For example, in order to extract the bang for each quarter note, I try using trigger objects as shown in the photo, but the bangs are probably played continuously at the timing when the numerical value marked in the photo is updated, so I can't get the bang I want. It doesn't fit.

Sorry if this question is too beginner-friendly. I would like some advice.

Finally, thank you to SOURCE AUDIO and everyone on this forum for providing the patch.

Source Audio's icon

insert change object

gogo's icon

SOURCE AUDIO

Thank you for your reply, I got the bang I was looking for!

Thank you very much for providing such a great patch.

gogo's icon

Let me ask you one more question.

I got this bang for various reasons.

Is it possible to get a dotted (nd) or triple time (nt) bang from sync~?

Source Audio's icon

sync~ ramps 0. ~ 1. for 1/4 note length.

I don't use it at all.

either only signal based timing, or

non signal, like beat clock or metro.

.............

You can divide 480 ticks with your wished note length

and use rate~ .

try to avoid translate object - it has it's dissadvantages,

if you for example want 128nd you get 22 ticks from translate, but it really is 22.5.

if you calculate rate~ factor expr 1 / (480. /$f1) (input ticks)

that 0.5 tick difference will get you out of sync

Midi beat clock bangs in 20 ticks interval.

that is the grain for any counter based banging,

and limits any duration that does not fit into 20 ticks grid.

which is beat clock dissadvantage.

for smaller durations, like 1/128 = 15 ticks,

one would have to add extra stuff.

gogo's icon

thank you for your reply

I solved the problem using the hint you provided as shown in the photo.

Thank you very much for this time.

Exploding PSYCH's icon

This patch is great. I was unable to get MIDI to sync correctly without having a randomly delayed start time. Not sure why that was happening, but it doesn't happen here.

I noticed that the divisions don't send the first pulse. I tried to resolve that by merging the start pulse with them, but the start pulse ends up with a different latency than the division pulses. (Can match them pretty close with a delay to the division pulses though.)

I want to slave Max to my DAW (Reaper) via a sync tone generated from the E-RM Multiclock vst. It sends a 24 ppq tone on the next downbeat of the DAW. How would you modify this code to have it work with a sync tone instead of MIDI?

Additional info if needed: I have the sync tone routed via Reapers "rearoute" which acts as virtual audio cables between Max and Reaper. MIDI is sent via LoopMIDI

Source Audio's icon

I am afraid all you could do with that signal is to detect bpm

and trigger counter to progress ticks.

But no spp . In addition audio latency .

Similar to sync~ , but using clock instead of beat click~ .

Can Max use several audio drivers at same time on windows ?

That would be needed to receive clock signal from reaper,

and then use other I/O for audio processing .

I tried that vst in Mac now, it has one beat lag to start producing clock,

probably to detect host tempo ?

Exploding PSYCH's icon

Thanks for the example. I want to use the VST in Reaper and send the audio to Max, so SSP shouldn't be needed in my case, since the sync tone starts on the next downbeat (I want max to sync to it the same way my modular hardware does).

Your question about Windows Driver: I don't think Max can use multiple audio drivers at once. Right now I'm using the driver that uses Reapers Rearoute channels (it seems like a built in rewire that you can install optionally with Reaper that adds extra Inputs and Outputs to/from Reaper). I'm happy to just use the Rearoute ASIO drivers in Max as I am now.

I've been trying to use adc~ to get the test tone from Reaper. I ran it back to Reaper via dac~ (connected directly to the adc~) and it was perfectly on beat when I recorded the test tone in Reaper looped through Max. However whenever I attempted to do anything else with it there is a random amount of latency added to the first pulse received by Max. Even with something as simple as a scope.

Another way to put this question: Can a 24 ppq sync tone from an external audio source be used to reliably clock Max?

Source Audio's icon

You must test it yourself, in your setup.

that pulse created by the plugin is longer than max click~

which is used in most examples when it comes to pulse driven signal stuff.

pulse length is 97 samples no matter what tempo

and between pulses signal is not 0. but alternating + - -80db each sample.

That is direct from vst plugin.

vst pulse at top, max click~ at bottom

in max patch vst created pulses run together with max transport driving click~

created pulses stay well steady, but are offset by one vector size.

Peter Ostry's icon

Not sure if it helps in this case, but since a while I use Pam Sync to musically synchronize Max to Logic. At 120 BPM my Logic MIDI Clock has an average jitter of 0.5 ms. With the Pam Sync Plugin in Logic routed via a Metric Halo Interface I measured only 0.01 ms average jitter in Max. Average means that I continuously measured the deviation within 4 pulses.

I have not tested the accuracy of the first impulse (maybe in combination with the "Run" sinal?) and did not test via virtual audio ports.

Exploding PSYCH's icon

Source:

I've been testing under my current use case, which is with adc~ feeding the test tone from the VST (loaded in Reaper).

Is image from your previous example where you are loading the VST within Max? Because I'm trying to load it within Reaper. When the Multiclock VST is loaded in Reaper, it knows to wait to start the signal until the next downbeat, which is what I want it to do. If the plugin is loaded within Max I'm unsure how it will derive the proper downbeat info from Reaper. That's why I'm routing the sync tone from Reaper into max via adc~.

Peter: What does your patch look like in Max for turning the clock into pulses Max can use?

Peter Ostry's icon

Peter: What does your patch look like in Max for turning the clock into pulses Max can use?

[adc– 31]
[>~ 0.2]
[edge~]

Source Audio's icon

I tested that plugin in Max itself just to see what signal it sends.

recording started 2 beats after max transport was triggered

so that there is no gap in recording.

Loaded In Max vst~ (on Mac) this plug performs a bit strange.

Sometimes after transport stop or stop/rewind or stop / jump

to other location it transmits square waves of different length.

Ranging from 128 - 256 samples , and that happens when being sent close to

20 tick position turnover.

Sometimes not.

Loaded in Live on Mac plugin is quiet when jumping location,

but it starts sending clocks immediately when Live transport starts.