Forums > Gen

[sharing] Digital PLL made with gen~

March 4, 2012 | 7:04 pm

I saw someone on another forum ask for advice on how to implement a real PLL using Max/MSP. It seemed like a great task for gen~, so I put this patch together. The gen~ object creates a square wave internally and tries to lock onto the signal from a cycle~ object.

PLLs can be a tricky subject, but playing with the patch doesn’t require understanding the math. I tried to add comments about how tuning controls affect the behavior.

This implementation uses a "bang-bang" phase detector and a PI control loop.
For the interested, wikipedia has a lot of information on PID control loops:
http://en.wikipedia.org/wiki/PID_controller
I removed the "D" term to simplify things.

– Pasted Max Patch, click to expand. –

March 4, 2012 | 10:37 pm

brilliant – it sounds lovely – really crunchy – thanks.


March 6, 2012 | 7:07 pm

Lovely sounds.


March 12, 2012 | 3:23 pm

this is very cool, and a lot of possibilities thanks.


March 29, 2012 | 6:09 pm

I made the post (at least I think it’s the one you mention) over at muffwiggler, so thanks for this, really interesting to see how you implemented it!


November 20, 2013 | 9:29 am

Hello everyone, I’m looking desperately for a max 5 patch that implements the PLL. some help?
thanks in advance :)


July 10, 2014 | 10:02 am

I could be barking up the wrong tree, but I’m trying to implement this as a M4L audio device. I’ve swapped plugout~ for ezdac~ and I hear it, but I’m not sure if I should expect it to respond to input other than the mono sine wave that feeds it here. I’d like to keep the input stereo to retain any panorama effects that feedforward into this as a device, but it seems like I’d need to edit the gen~ object and it only works for me in runtime mode. I’ll try replacing the sine input with a mono signal from Live and see if it works…


July 10, 2014 | 11:00 am

So it works with the mono input, but doesn’t always sound that musical. I filtered down the input signal with a Live EQ8 and that helped to make it behave a bit more musically. I really want to use this as a guitar effect after seeing this stomp box PLL today: http://www.sunsineaudio.com/Harmonic-Decoder-045.htm


July 11, 2014 | 1:45 am

@antoniosvisa : you can easily implement PLL with rate~ and some feedback.
If you need a real accurate and stable PLL, you’ll need to work sample tight which you can do by packing your PLL in a poly~ @ vs 1.
I’ve been using such an implementation in this example : http://vimeo.com/25740547


Viewing 9 posts - 1 through 9 (of 9 total)