[sharing] Digital PLL made with gen~

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

    • Mar 04 2012 | 10:37 pm
      brilliant - it sounds lovely - really crunchy - thanks.
    • Mar 06 2012 | 7:07 pm
      Lovely sounds.
    • Mar 12 2012 | 3:23 pm
      this is very cool, and a lot of possibilities thanks.
    • Mar 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!
    • Nov 20 2013 | 5:29 pm
      Hello everyone, I'm looking desperately for a max 5 patch that implements the PLL. some help? thanks in advance :)
    • Jul 10 2014 | 5:02 pm
      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...
    • Jul 10 2014 | 6:00 pm
      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
    • Jul 11 2014 | 8: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