Synchronising rate~ with plugphasor~

outsider's icon

hello folks! i'm working on an m4l MIDI device that uses plugphasor~ and rate~ (in "lock" sync mode) to derive what should be sample-accurate timing over the course of an arbitrary number of bars (4, 8, 16, etc).

however, using rate~ in combination with plugphasor~ to create a master phasor of a length longer than 1 beat introduces a problem where rate~ wants to pick up from where it left off when transport stops and starts again.

i've tried using the "transport active" flag from plugsync~ to tell rate~ to reset, but this still causes erratic behaviour where rate~ sometimes begins a new cycle on the second beat (shown in blue), or resets to a different point in its cycle (shown in red). i assume this is because plugsync~ is outputting data at event rate (?) while plugphasor~ is synchronised at audio rate...

any ideas what i can do here?

double_UG's icon

use phasor @lock 1

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

outsider's icon

not gonna solve it unfortunately! the issue is with the synchronisation of the output of rate~ for phasors with a length longer than 1 beat. it snaps to a beat-synchronised value (e.g. 0.0, 0.25, 0.5, 0.75 for a multiplier of 4) when playback is started and stopped. i want it to start from 0.0 every time.

double_UG's icon

the is also subdiv~

outsider's icon

i programmed something in gen~ to solve this issue! it functions like rate~ except it resets whenever playback stops and starts. it also has a quantise function that will synchronise any multiplier changes to a user-determined number of cycles of the input phasor. in case anyone was having trouble with rate~ not resetting when they want it to!

rate-reset-quant.gendsp
gendsp 14.14 KB