Best way to sync a Phasor~ with transport?

Tim Massar's icon

Hi, new max user, i think some of my frustrations come from wanting to do things in Max the way I used to do them in Reaktor (as context)...anyway looking for advice. I wanted a phasor to be synced to the transport, used the standard delta, edge detection for creating bangs at resets to drive a counter that worked independently, but still synced to the transport. What I wanted to do was read what bar and what beat I was on then modulo the counter with the note division i chose, add all those numbers together to get the current step number in relation to the size set by the user in bars - for example, If i set my midi recording to loop every 2 bars I modulo the current bar over 2, multiply by my note division, then add the current beat multiplied by note divisions to get my starting offset value to add to my counter driving current step from 0. But, the phasor was wildly out of sync. numbers that should reset over the modulo at the same time were sometimes two or three steps behind, the phasor was inconsistently throwing out a 1 at the start instead of starting at 0, and just looking at a counter of the phasor edge detection and transport beat readout it was clear they were operating on much different wavelengths. Wish I had the project to share, it was total spaghetti wires anyway, but with all this possibly being irrelevant, what is the best way to independently clock something that is still synced to the transport?

Edit: also is there a way to hold a calculation from being processed until I receive new numbers at both inlets? Because Im still having this sync problem driving from the metronome. Numebers in modulo are rolling over to 0 before the last numbers have arrived from the previous calculation, even though they should be all arriving simulataneously.

Thanks,

A newbie

TFL's icon

Did you try [phasor~ 4n @lock 1]?

See the "Tempo-relative" tab of the phasor~ help patch for more details.

Tim Massar's icon

Here's the current iteration using the metronome to drive the counting, but all the phasor modules are still in there to the left. You can see this still happening using the metro I put a big red "Here" comment to show you where, that number should not be bouncing around like it is, it should be all calculating relatively at the same time. All im trying to do is multiply, modulo and add a few numbers to get current step number in a relative window.

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

TFL's icon

If you refer to the number in the message on the right here, it never changes.

If you refer to your two layered live.scope, they look in sync too for me.

Did you try to enable 'Scheduler in Overdrive' and 'Scheduler in Audio Interrupt' as suggested in the phasor~ help file to see if you have more accurate timing?

Tim Massar's icon

Yes the phasor and edge detection scopes are in sync - and to be clear I'm not necessarily saying Max is wrong, its most likely that Im just doing it wrong - but by default this patch should be synced to the global transport, just hit play and maybe to be safe give the init button a go on the top right - appreciate you making suggestions, and yes, I have overdrive and SAI active.

Tim Massar's icon

Here i made a patch that isolates the area in question and labeled everything. Here's the values get, you can replicate inside. I want to build something that counts 1 - 64 in sequence based on current bar, current beat, and selected beat division (in example its all set to 16th notes)

table 1 2 3 0 1 6 7 4 5 10 11 8 9 14 15 12 13 18 19 16 17 22 23 20 21 26 27 24 25 30 31 28 29 34 35 32 33 38 39 36 37.....

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

TFL's icon

If I understand correctly, you expect to see 1 2 3 4... 62 63 64 in the table, right?

Seems like you need to be careful about the order of execution (see this tutorial for explanation) and hot VS cold inlets (hot ones are red, they trigger the objects output; cold ones are blue, they don't trigger the objects output).

[trigger] is a very common object to make sure your messages are sent in the right order, and [buddy] can also help from time to time, so I invite you to check their help patch if you want to understand better what I did:

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

Tim Massar's icon

awesome, a lot to learn. Need to use the t object control my bang order and the buddy module is new to me. Thanks a lot for your help, I was getting very frustrated.

Roman Thilenius's icon

"Here i made a patch that isolates the area in question"

now we´re talking. :)

normally one would suggest to start all over and do this patch differently, but it is totally understandable that you first want to try to transfer everything from reaktor to max world... that is what i also do when entering new fields... i start to copy how i would work in max... for example i have ported hundreds of my own max abstractions to flowstone... most of them are probably not best practice there...

regarding the "edge~" situation: do not mix and match signal rate and data rate unless it is unavoidable... it might be ok for GUI or network stuff, but it will never give you the desired scheduler accurary or sample accurary when you jump between the domains.