[PD] phase locked loop

Charles Z Henry czhenry at gmail.com
Sat Mar 11 19:49:02 CET 2023


> If the phase is <0.5,  then we're receiving pulses at more than double
> the current freq.  In that case, don't update phase, update frequency.
> If the phase is >0.5 and <2.0, then we're within one octave.
> The maximum phase update amount is (1-phase)
> The maximum frequency update amount is ((1-phase)/phase)*freq
> Then, if the phase is >2.0, then the input freq is more than 1 octave
> lower.  In this case, don't update phase, update frequency.

The cool part is this can all be implemented at a basic level in just
a few lines of code with fexpr~!  (I started in on it just to write
this part, figuring it takes me 20 min)

fexpr~ modf($y1+$f5*$y2+$f3*$x1*$y3);
if($y6!=$y6[-2], $y6, $y2+$f4*$x1*$y4);
if($y5<0.5, 0, if($y5<2, 1-$y5, 0));
if($y5<0.5, $y2, if($y5<2, (1-$y5)/$y5*$y2, -1.414*$y2/sqrt($y5)));
if($x1[-1]==1, $y1+$f5*$y2, $y5+$f5*$y2);
if($y6!=$f2, $f2, $y6)

But just so difficult to explain, I created a mathcha document for it,
if you expected to be able to start modifying it and tuning it up for
use.

https://www.mathcha.io/editor/OBgdJIo6UzgsgZHp8K1VSjK188YTN4eVJyHrz1q8G

work in progress





More information about the Pd-list mailing list