[PD] phase locked loop

Charles Z Henry czhenry at gmail.com
Fri Mar 10 21:21:33 CET 2023


Hi Simon,

I took up the approach that I was thinking of and got something
working today.  It's a good first draft
So, what I've attached here is a phase-resetting, frequency adaptive
oscillator with 0-1 phasor output.  I'm calling it "synch_osc~" for
synchronizing oscillator

It has a thresholded rising edge detector on the input with
(hardcoded) 20 samples of de-bounce to avoid noisy triggers.
Then, once an input spike is received, the oscillator triggers an
update to its phase and frequency

The update amounts vary based on what the phase is currently.

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.

If it receives no input spikes, then the frequency remains constant
and it just outputs a nice steady phasor waveform

It needs to have some parameters set.  For some range of parameters,
it may not work at some frequencies
The parameters are:
threshold
initial frequency
phase update coefficient (0-1)
--values close to 1 are strongly synchronizing
freq update coefficient (0-1)
--affects convergence speed when close to 0, but it's acceptable at
low values also
--creates jitter and excess noise when close to 1

Works like a PLL pretty much!  I might have some more fun with it this
next week, and make a sub-harmonic synchronizing oscillator version

Best,
Chuck


On Fri, Mar 10, 2023 at 1:38 AM Simon Iten <itensimon at gmail.com> wrote:
>
> thanks for your answer.
>
> as a first project i wanted to explore the possibilites in treating the output of a hexaphonic bass pickup with puredata. a pll oscillator with the bass string as input (filtered to remove unwanted harmonics) sprang to mind.
>
>
> other topics i am currently investigating:
>
> -pitch to voltage from the different strings at low latency (difficult with bass frequencies, i took a gr300 guitar synth approach)
> -proper attack detection
> -adaptive filtering of the individual strings overtones to remove octave jumps from the pitch to voltage block
>
>
>
> On Fri, 10 Mar 2023, 00:48 Charles Z Henry, <czhenry at gmail.com> wrote:
>>
>> Synchronizing oscillators is a good topic and there should be some better options with digital alone than with simulations of the analog circuits.
>>
>> Synchronization in natural systems involves a phase-resetting oscillator.  The key behavior is the oscillator responds to input events, by adjusting its phase by an amount that depends on the current state of the oscillator.  This is enough to produce synchronization within a small range of nearby frequencies, by itself, but adjusting frequency is also possible.
>>
>> What did you have in mind?  Any specific behavior it needs to have?
>>
>>
>>
>>
>>
>> On Tue, Mar 7, 2023, 4:01 PM Simon Iten <itensimon at gmail.com> wrote:
>>>
>>> hi list,
>>>
>>> does somebody have a patched version of a PLL (phase locked loop) in PD? or building blocks of it...
>>>
>>> cheers
>>>
>>>
>>> _______________________________________________
>>> Pd-list at lists.iem.at mailing list
>>> UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: synch_osc~.pd
Type: application/octet-stream
Size: 2134 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20230310/46055a8d/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: synch_osc-test.pd
Type: application/octet-stream
Size: 2091 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20230310/46055a8d/attachment-0001.obj>


More information about the Pd-list mailing list