{"id":8253,"date":"2013-11-29T12:37:02","date_gmt":"2013-11-29T12:37:02","guid":{"rendered":"http:\/\/zerokidz.com\/ideas\/?p=8253"},"modified":"2014-06-24T20:48:51","modified_gmt":"2014-06-25T00:48:51","slug":"phase-locked-loop-fm-detection-in-max","status":"publish","type":"post","link":"https:\/\/reactivemusic.net\/?p=8253","title":{"rendered":"Phase locked loop FM detection in Max"},"content":{"rendered":"<p><a href=\"https:\/\/reactivemusic.net\/wp-content\/uploads\/2013\/11\/Screen-Shot-2013-11-29-at-7.28.42-AM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-8254\" title=\"Screen Shot 2013-11-29 at 7.28.42 AM\" src=\"https:\/\/reactivemusic.net\/wp-content\/uploads\/2013\/11\/Screen-Shot-2013-11-29-at-7.28.42-AM-300x166.png\" alt=\"\" width=\"300\" height=\"166\" srcset=\"https:\/\/reactivemusic.net\/wp-content\/uploads\/2013\/11\/Screen-Shot-2013-11-29-at-7.28.42-AM-300x166.png 300w, https:\/\/reactivemusic.net\/wp-content\/uploads\/2013\/11\/Screen-Shot-2013-11-29-at-7.28.42-AM-1024x566.png 1024w, https:\/\/reactivemusic.net\/wp-content\/uploads\/2013\/11\/Screen-Shot-2013-11-29-at-7.28.42-AM-500x276.png 500w, https:\/\/reactivemusic.net\/wp-content\/uploads\/2013\/11\/Screen-Shot-2013-11-29-at-7.28.42-AM.png 1189w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><span style=\"line-height: 1.6;\">Here is an example of audio from the patch.<\/span><\/p>\n\t<audio id=\"wp_mep_1\"      controls=\"controls\" preload=\"none\"  >\r\n\t\t\r\n\t\t<source src=\"https:\/\/reactivemusic.net\/wp-content\/uploads\/2013\/11\/fm-pll-test2.mp3\" type=\"audio\/mp3\" \/>\r\n\t\t\r\n\t\t\r\n\t\t\r\n\t\t\r\n\t\t\r\n\t<\/audio>\r\n<script type=\"text\/javascript\">\r\njQuery(document).ready(function($) {\r\n\t$('#wp_mep_1').mediaelementplayer({\r\n\t\tm:1\r\n\t\t\r\n\t\t,features: ['playpause','current','progress','duration','volume','tracks','fullscreen']\r\n\t\t,audioWidth:400,audioHeight:30\r\n\t});\r\n});\r\n<\/script>\r\n\n<p><span style=\"line-height: 1.6;\">The source is a speech by Barack Obama which is FM modulated on an audio carrier at 23040 Hz. \u00a0Warning turn down the volume. You can hear as the PLL locks on to the signal. Then some of the params are tweaked in such a way that it is impossible to lock on to the signal, but the algorithm keeps on trying &#8211; producing an interesting result<\/span><\/p>\n<p>A picture of the signal as its locking-on and when it loses the lock:<\/p>\n<p><a href=\"https:\/\/reactivemusic.net\/wp-content\/uploads\/2013\/11\/Screen-Shot-2013-12-18-at-3.46.53-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-8601\" title=\"Screen Shot 2013-12-18 at 3.46.53 PM\" src=\"https:\/\/reactivemusic.net\/wp-content\/uploads\/2013\/11\/Screen-Shot-2013-12-18-at-3.46.53-PM-300x70.png\" alt=\"\" width=\"300\" height=\"70\" srcset=\"https:\/\/reactivemusic.net\/wp-content\/uploads\/2013\/11\/Screen-Shot-2013-12-18-at-3.46.53-PM-300x70.png 300w, https:\/\/reactivemusic.net\/wp-content\/uploads\/2013\/11\/Screen-Shot-2013-12-18-at-3.46.53-PM-500x116.png 500w, https:\/\/reactivemusic.net\/wp-content\/uploads\/2013\/11\/Screen-Shot-2013-12-18-at-3.46.53-PM.png 603w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>[original post]<\/p>\n<p>A phase-locked loop algorithm running in Max (gen~)<\/p>\n<p>The patch is unstable &#8211; but actually demodulates FM now.<\/p>\n<h4>download<\/h4>\n<p>in max-projects:\u00a0<a href=\"https:\/\/github.com\/tkzic\/max-projects\">https:\/\/github.com\/tkzic\/max-projects<\/a><\/p>\n<p>folder: demodulation\/max\/phase-locked-loop<\/p>\n<p><span style=\"line-height: 1.6;\">patch<\/span><\/p>\n<p>gen-fm-detector2.maxpat<\/p>\n<p>(also uses output from modem3.maxpat in folder:\u00a0demodulation\/max\/)<\/p>\n<h4>instructions<\/h4>\n<ul>\n<li>run modem3.maxpat<\/li>\n<li>set FM modulation level to less than 250<\/li>\n<li>run gen-fm-detector2.maxpat<\/li>\n<li>turn up audio output and try presets<\/li>\n<\/ul>\n<h4><span style=\"line-height: 22px;\">notes<\/span><\/h4>\n<p>Two things: 1) I really don&#8217;t know what I&#8217;m doing with gen~ and 2) There are serious issues with the P and I coefficients in the algorithm. There is no &#8216;D&#8217; coefficient yet &#8211; nor do I know whether its needed.<\/p>\n<p>The thing that finally got it working was the loop filter component &#8211; which cleans up the output of the phase detector. The phase detector is essentially a phase ring modulator which contains not only the error signal, but also the sum of the incoming carrier and the reference oscillator. So the low pass filter gets rid of the high frequency component. By setting the resonance and cutoff extremely low, you can make the PLL start going a bit crazy in a beautiful way, lots of motion and spectral shifting.<\/p>\n<p>Need to go through and analyze the output of the various stages, now to get the coefficients set properly &#8211; also, may need some kind of AGC on the input stage. Its very sensitive to over modulation and will distort badly.<\/p>\n<p>Its interesting to play with the coefficients and hear the difference in how the demodulation works. By slowing down the P coefficient \u00a0it not only slows lock response, but during lock, the output is muffled \u00a0&#8211; so the P coefficient acts as a low pass filter &#8211; because it changes how responsive the circuit is in detecting changes in the input signal frequency (i.e., modulation).<\/p>\n<p>There&#8217;s a weird thing going on &#8211; a fixed carrier is getting mixed with the error signal (output) \u00a0 The patch is using notch filters to eliminate it, but it seems like it shouldn&#8217;t be there at all. Or should get filtered by the Loop filter.<\/p>\n<p>Another thing to mention if I haven&#8217;t already is that I&#8217;m using a somewhat inefficient way to detect phase difference. Its the convert to complex and slope detection method used in the differentiator &#8211; but done using signals from reference oscillator instead of from delayed samples from original signal. Simply multiplying the two signals without complex conversion would probably do.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here is an example of audio from the patch. The source is a speech by Barack Obama which is FM modulated on an audio carrier at 23040 Hz. \u00a0Warning turn down the volume. You can hear as the PLL locks on to the signal. Then some of the params are tweaked in such a way &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/reactivemusic.net\/?p=8253\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Phase locked loop FM detection in Max&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","footnotes":""},"categories":[21,273,28],"tags":[191,244,190,57],"class_list":["post-8253","post","type-post","status-publish","format-standard","hentry","category-dsp","category-max-projects","category-maxmsp","tag-favorites","tag-pll","tag-portfolio","tag-radio"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Phase locked loop FM detection in Max - reactive music<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/reactivemusic.net\/?p=8253\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Phase locked loop FM detection in Max - reactive music\" \/>\n<meta property=\"og:description\" content=\"Here is an example of audio from the patch. The source is a speech by Barack Obama which is FM modulated on an audio carrier at 23040 Hz. \u00a0Warning turn down the volume. You can hear as the PLL locks on to the signal. Then some of the params are tweaked in such a way &hellip; Continue reading &quot;Phase locked loop FM detection in Max&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/reactivemusic.net\/?p=8253\" \/>\n<meta property=\"og:site_name\" content=\"reactive music\" \/>\n<meta property=\"article:published_time\" content=\"2013-11-29T12:37:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-06-25T00:48:51+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/reactivemusic.net\/wp-content\/uploads\/2013\/11\/Screen-Shot-2013-11-29-at-7.28.42-AM-300x166.png\" \/>\n<meta name=\"author\" content=\"Tom Zicarelli\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Tom Zicarelli\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=8253#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=8253\"},\"author\":{\"name\":\"Tom Zicarelli\",\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/#\\\/schema\\\/person\\\/56224d281582df7e5518e037ca63e571\"},\"headline\":\"Phase locked loop FM detection in Max\",\"datePublished\":\"2013-11-29T12:37:02+00:00\",\"dateModified\":\"2014-06-25T00:48:51+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=8253\"},\"wordCount\":520,\"image\":{\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=8253#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/reactivemusic.net\\\/wp-content\\\/uploads\\\/2013\\\/11\\\/Screen-Shot-2013-11-29-at-7.28.42-AM-300x166.png\",\"keywords\":[\"favorites\",\"PLL\",\"portfolio\",\"radio\"],\"articleSection\":[\"DSP\",\"max-projects\",\"Max\\\/MSP\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=8253\",\"url\":\"https:\\\/\\\/reactivemusic.net\\\/?p=8253\",\"name\":\"Phase locked loop FM detection in Max - reactive music\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=8253#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=8253#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/reactivemusic.net\\\/wp-content\\\/uploads\\\/2013\\\/11\\\/Screen-Shot-2013-11-29-at-7.28.42-AM-300x166.png\",\"datePublished\":\"2013-11-29T12:37:02+00:00\",\"dateModified\":\"2014-06-25T00:48:51+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/#\\\/schema\\\/person\\\/56224d281582df7e5518e037ca63e571\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=8253#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/reactivemusic.net\\\/?p=8253\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=8253#primaryimage\",\"url\":\"https:\\\/\\\/reactivemusic.net\\\/wp-content\\\/uploads\\\/2013\\\/11\\\/Screen-Shot-2013-11-29-at-7.28.42-AM.png\",\"contentUrl\":\"https:\\\/\\\/reactivemusic.net\\\/wp-content\\\/uploads\\\/2013\\\/11\\\/Screen-Shot-2013-11-29-at-7.28.42-AM.png\",\"width\":\"1189\",\"height\":\"658\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=8253#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/reactivemusic.net\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Phase locked loop FM detection in Max\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/#website\",\"url\":\"https:\\\/\\\/reactivemusic.net\\\/\",\"name\":\"reactive music\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/reactivemusic.net\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/#\\\/schema\\\/person\\\/56224d281582df7e5518e037ca63e571\",\"name\":\"Tom Zicarelli\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0da58cf21a2707dd335b204b8ed3cd9194dcbf9d9814ac5d71195a65c76c8a72?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0da58cf21a2707dd335b204b8ed3cd9194dcbf9d9814ac5d71195a65c76c8a72?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0da58cf21a2707dd335b204b8ed3cd9194dcbf9d9814ac5d71195a65c76c8a72?s=96&d=mm&r=g\",\"caption\":\"Tom Zicarelli\"},\"sameAs\":[\"http:\\\/\\\/tomzicarelli.com\"],\"url\":\"https:\\\/\\\/reactivemusic.net\\\/?author=2\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Phase locked loop FM detection in Max - reactive music","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/reactivemusic.net\/?p=8253","og_locale":"en_US","og_type":"article","og_title":"Phase locked loop FM detection in Max - reactive music","og_description":"Here is an example of audio from the patch. The source is a speech by Barack Obama which is FM modulated on an audio carrier at 23040 Hz. \u00a0Warning turn down the volume. You can hear as the PLL locks on to the signal. Then some of the params are tweaked in such a way &hellip; Continue reading \"Phase locked loop FM detection in Max\"","og_url":"https:\/\/reactivemusic.net\/?p=8253","og_site_name":"reactive music","article_published_time":"2013-11-29T12:37:02+00:00","article_modified_time":"2014-06-25T00:48:51+00:00","og_image":[{"url":"https:\/\/reactivemusic.net\/wp-content\/uploads\/2013\/11\/Screen-Shot-2013-11-29-at-7.28.42-AM-300x166.png","type":"","width":"","height":""}],"author":"Tom Zicarelli","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Tom Zicarelli","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/reactivemusic.net\/?p=8253#article","isPartOf":{"@id":"https:\/\/reactivemusic.net\/?p=8253"},"author":{"name":"Tom Zicarelli","@id":"https:\/\/reactivemusic.net\/#\/schema\/person\/56224d281582df7e5518e037ca63e571"},"headline":"Phase locked loop FM detection in Max","datePublished":"2013-11-29T12:37:02+00:00","dateModified":"2014-06-25T00:48:51+00:00","mainEntityOfPage":{"@id":"https:\/\/reactivemusic.net\/?p=8253"},"wordCount":520,"image":{"@id":"https:\/\/reactivemusic.net\/?p=8253#primaryimage"},"thumbnailUrl":"https:\/\/reactivemusic.net\/wp-content\/uploads\/2013\/11\/Screen-Shot-2013-11-29-at-7.28.42-AM-300x166.png","keywords":["favorites","PLL","portfolio","radio"],"articleSection":["DSP","max-projects","Max\/MSP"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/reactivemusic.net\/?p=8253","url":"https:\/\/reactivemusic.net\/?p=8253","name":"Phase locked loop FM detection in Max - reactive music","isPartOf":{"@id":"https:\/\/reactivemusic.net\/#website"},"primaryImageOfPage":{"@id":"https:\/\/reactivemusic.net\/?p=8253#primaryimage"},"image":{"@id":"https:\/\/reactivemusic.net\/?p=8253#primaryimage"},"thumbnailUrl":"https:\/\/reactivemusic.net\/wp-content\/uploads\/2013\/11\/Screen-Shot-2013-11-29-at-7.28.42-AM-300x166.png","datePublished":"2013-11-29T12:37:02+00:00","dateModified":"2014-06-25T00:48:51+00:00","author":{"@id":"https:\/\/reactivemusic.net\/#\/schema\/person\/56224d281582df7e5518e037ca63e571"},"breadcrumb":{"@id":"https:\/\/reactivemusic.net\/?p=8253#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/reactivemusic.net\/?p=8253"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/reactivemusic.net\/?p=8253#primaryimage","url":"https:\/\/reactivemusic.net\/wp-content\/uploads\/2013\/11\/Screen-Shot-2013-11-29-at-7.28.42-AM.png","contentUrl":"https:\/\/reactivemusic.net\/wp-content\/uploads\/2013\/11\/Screen-Shot-2013-11-29-at-7.28.42-AM.png","width":"1189","height":"658"},{"@type":"BreadcrumbList","@id":"https:\/\/reactivemusic.net\/?p=8253#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/reactivemusic.net\/"},{"@type":"ListItem","position":2,"name":"Phase locked loop FM detection in Max"}]},{"@type":"WebSite","@id":"https:\/\/reactivemusic.net\/#website","url":"https:\/\/reactivemusic.net\/","name":"reactive music","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/reactivemusic.net\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/reactivemusic.net\/#\/schema\/person\/56224d281582df7e5518e037ca63e571","name":"Tom Zicarelli","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/0da58cf21a2707dd335b204b8ed3cd9194dcbf9d9814ac5d71195a65c76c8a72?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/0da58cf21a2707dd335b204b8ed3cd9194dcbf9d9814ac5d71195a65c76c8a72?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0da58cf21a2707dd335b204b8ed3cd9194dcbf9d9814ac5d71195a65c76c8a72?s=96&d=mm&r=g","caption":"Tom Zicarelli"},"sameAs":["http:\/\/tomzicarelli.com"],"url":"https:\/\/reactivemusic.net\/?author=2"}]}},"_links":{"self":[{"href":"https:\/\/reactivemusic.net\/index.php?rest_route=\/wp\/v2\/posts\/8253","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/reactivemusic.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/reactivemusic.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/reactivemusic.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/reactivemusic.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8253"}],"version-history":[{"count":14,"href":"https:\/\/reactivemusic.net\/index.php?rest_route=\/wp\/v2\/posts\/8253\/revisions"}],"predecessor-version":[{"id":16721,"href":"https:\/\/reactivemusic.net\/index.php?rest_route=\/wp\/v2\/posts\/8253\/revisions\/16721"}],"wp:attachment":[{"href":"https:\/\/reactivemusic.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8253"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/reactivemusic.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8253"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/reactivemusic.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8253"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}