[sharing] Digital PLL made with gen~

skrasms's icon

skrasms

3月 04 2012 | 7:04 午後

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.

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

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.

AudioLemon's icon

AudioLemon

3月 04 2012 | 10:37 午後

brilliant - it sounds lovely - really crunchy - thanks.

geddonn's icon

geddonn

3月 06 2012 | 7:07 午後

Lovely sounds.

LiamCormacGould's icon

LiamCormacGould

3月 12 2012 | 3:23 午後

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

matdalgleish@hotmail.com's icon

matdalgleish@hotmail.com

3月 29 2012 | 6:09 午後

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!

antoniosvisa's icon

antoniosvisa

11月 20 2013 | 5:29 午後

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

joshg567's icon

joshg567

7月 10 2014 | 5:02 午後

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...

joshg567's icon

joshg567

7月 10 2014 | 6:00 午後

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

Vincent Goudard's icon

Vincent Goudard

7月 11 2014 | 8:45 午前

@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