{"id":11385,"date":"2014-05-16T18:46:21","date_gmt":"2014-05-16T22:46:21","guid":{"rendered":"http:\/\/zerokidz.com\/ideas\/?p=11385"},"modified":"2014-10-14T00:54:46","modified_gmt":"2014-10-14T04:54:46","slug":"granular-time-stretching-in-max","status":"publish","type":"post","link":"https:\/\/reactivemusic.net\/?p=11385","title":{"rendered":"Granular time stretching in Max"},"content":{"rendered":"<p class=\"lead\">Adaptation of Andy Farnell&#8217;s Pd granular timestretch patch<\/p>\n<p>Adjustable chunk-size, pitch, and speed &#8211; as well as manual scrubbing.<\/p>\n<p>The original Pd patch (timestretch.pd) is available here:\u00a0<a href=\"http:\/\/aspress.co.uk\/sd\/index.php\">http:\/\/aspress.co.uk\/sd\/index.php<\/a><\/p>\n<p><a href=\"https:\/\/reactivemusic.net\/wp-content\/uploads\/2014\/05\/Screen-Shot-2014-05-16-at-6.37.20-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-11386\" title=\"Screen Shot 2014-05-16 at 6.37.20 PM\" src=\"https:\/\/reactivemusic.net\/wp-content\/uploads\/2014\/05\/Screen-Shot-2014-05-16-at-6.37.20-PM-300x188.png\" alt=\"\" width=\"300\" height=\"188\" srcset=\"https:\/\/reactivemusic.net\/wp-content\/uploads\/2014\/05\/Screen-Shot-2014-05-16-at-6.37.20-PM-300x188.png 300w, https:\/\/reactivemusic.net\/wp-content\/uploads\/2014\/05\/Screen-Shot-2014-05-16-at-6.37.20-PM-1024x643.png 1024w, https:\/\/reactivemusic.net\/wp-content\/uploads\/2014\/05\/Screen-Shot-2014-05-16-at-6.37.20-PM.png 1606w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<h4>download<\/h4>\n<p><a href=\"https:\/\/github.com\/tkzic\/max-projects\">https:\/\/github.com\/tkzic\/max-projects<\/a><\/p>\n<p>folder: granular-timestretch<\/p>\n<p>patches<\/p>\n<ul>\n<li><span style=\"line-height: 1.6;\">timestretch5.maxpat (main patch)<\/span><\/li>\n<li><span style=\"line-height: 1.6;\">tabread4~.maxpat (Pd abstraction)\u00a0<\/span><\/li>\n<li>hip~.maxpat (Pd abstraction)<\/li>\n<\/ul>\n<h4>How it works<\/h4>\n<p>An index pointer (file phasor) scans from the beginning to the end of the file. For example, at 44.1KHz, a 1 second file of audio would have 44,100 samples. Each sample is 022676 ms. Another phasor (grain phasor) scans small chunks (grains) of audio. If audio is playing back at the normal rate and pitch, this grain phasor runs at zero. the file phasor just moves sequentially from one grain to the next.<\/p>\n<p>To stretch the time, the file phasor is slowed down, but the grain phasor speeds up, scanning grains of audio, that start at the current file phasor index. In this way, in listening to the file from beginning to end, you are actually listening to a series of overlapping grains.<\/p>\n<p>As the chunk (grain) size increases the grain phasor frequency decreases.<\/p>\n<p>To raise the pitch, the grain phasor frequency would be increased. To lower the pitch, the phasor frequency goes negative and increases in a negative direction to reduce pitch further.<\/p>\n<p>As you can see, while running this patch, the chunk size, pitch, and speed are all related by a single equation.<\/p>\n<p>phasor frequency = ((pitch \/ 120)**2 &#8211; speed) \/ chunksize<\/p>\n<ul>\n<li>where pitch is in cents (0 is normal)<\/li>\n<li>speed is a scaling factor (1 is normal)<\/li>\n<li>chunk (grain) size \u00a0is in ms.<\/li>\n<\/ul>\n<p>So the input values interact with each other.<\/p>\n<p>In addition, the grain player uses a technique called PSOLA. Pitch synchronous overlap and add. There are actually two grain players playing simultaneously 180 degrees out of phase. Each is windowed using a positive cosine function. This helps to reduce clicks by crossfading from one grain to the next.<\/p>\n<p>There is some comb-filtering and ringing present on the audio. There are various techniques to reduce this, including:<\/p>\n<ul>\n<li>trying different window functions<\/li>\n<li>higher sample rates<\/li>\n<li>changing the overlap<\/li>\n<li>varying the grain size<\/li>\n<\/ul>\n<h5>Interesting artifacts:<\/h5>\n<ul>\n<li>reducing the grain size to several ms. causes oscillation similar to the Karplus-Strong effect<\/li>\n<li>increasing the grain size to around 1000 ms. causes a feedback delay effect due to the out of phase grain players<\/li>\n<li>setting the overlap to anything other than .5 causes random phase cancellation<\/li>\n<\/ul>\n<h5>Manual or automated scrubbing.<\/h5>\n<p>There is also an option to manually scrub the file. This way you can listen to the texture of grains of various sizes from various points in the file.<\/p>\n<p>You can also set random automatic scrubbing to branch to various points in the file.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Adaptation of Andy Farnell&#8217;s Pd granular timestretch patch Adjustable chunk-size, pitch, and speed &#8211; as well as manual scrubbing. The original Pd patch (timestretch.pd) is available here:\u00a0http:\/\/aspress.co.uk\/sd\/index.php download https:\/\/github.com\/tkzic\/max-projects folder: granular-timestretch patches timestretch5.maxpat (main patch) tabread4~.maxpat (Pd abstraction)\u00a0 hip~.maxpat (Pd abstraction) How it works An index pointer (file phasor) scans from the beginning to the &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/reactivemusic.net\/?p=11385\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Granular time stretching 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,249],"tags":[344,11,191,132,345,128,190],"class_list":["post-11385","post","type-post","status-publish","format-standard","hentry","category-dsp","category-max-projects","category-maxmsp","category-pd-2","tag-dsp","tag-electronic-music","tag-favorites","tag-granular","tag-maxmsp","tag-pd","tag-portfolio"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Granular time stretching 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=11385\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Granular time stretching in Max - reactive music\" \/>\n<meta property=\"og:description\" content=\"Adaptation of Andy Farnell&#8217;s Pd granular timestretch patch Adjustable chunk-size, pitch, and speed &#8211; as well as manual scrubbing. The original Pd patch (timestretch.pd) is available here:\u00a0http:\/\/aspress.co.uk\/sd\/index.php download https:\/\/github.com\/tkzic\/max-projects folder: granular-timestretch patches timestretch5.maxpat (main patch) tabread4~.maxpat (Pd abstraction)\u00a0 hip~.maxpat (Pd abstraction) How it works An index pointer (file phasor) scans from the beginning to the &hellip; Continue reading &quot;Granular time stretching in Max&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/reactivemusic.net\/?p=11385\" \/>\n<meta property=\"og:site_name\" content=\"reactive music\" \/>\n<meta property=\"article:published_time\" content=\"2014-05-16T22:46:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-10-14T04:54:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/reactivemusic.net\/wp-content\/uploads\/2014\/05\/Screen-Shot-2014-05-16-at-6.37.20-PM-300x188.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=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=11385#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=11385\"},\"author\":{\"name\":\"Tom Zicarelli\",\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/#\\\/schema\\\/person\\\/56224d281582df7e5518e037ca63e571\"},\"headline\":\"Granular time stretching in Max\",\"datePublished\":\"2014-05-16T22:46:21+00:00\",\"dateModified\":\"2014-10-14T04:54:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=11385\"},\"wordCount\":456,\"image\":{\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=11385#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/reactivemusic.net\\\/wp-content\\\/uploads\\\/2014\\\/05\\\/Screen-Shot-2014-05-16-at-6.37.20-PM-300x188.png\",\"keywords\":[\"DSP\",\"electronic music\",\"favorites\",\"granular\",\"Max\\\/MSP\",\"Pd\",\"portfolio\"],\"articleSection\":[\"DSP\",\"max-projects\",\"Max\\\/MSP\",\"Pd\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=11385\",\"url\":\"https:\\\/\\\/reactivemusic.net\\\/?p=11385\",\"name\":\"Granular time stretching in Max - reactive music\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=11385#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=11385#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/reactivemusic.net\\\/wp-content\\\/uploads\\\/2014\\\/05\\\/Screen-Shot-2014-05-16-at-6.37.20-PM-300x188.png\",\"datePublished\":\"2014-05-16T22:46:21+00:00\",\"dateModified\":\"2014-10-14T04:54:46+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/#\\\/schema\\\/person\\\/56224d281582df7e5518e037ca63e571\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=11385#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/reactivemusic.net\\\/?p=11385\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=11385#primaryimage\",\"url\":\"https:\\\/\\\/reactivemusic.net\\\/wp-content\\\/uploads\\\/2014\\\/05\\\/Screen-Shot-2014-05-16-at-6.37.20-PM.png\",\"contentUrl\":\"https:\\\/\\\/reactivemusic.net\\\/wp-content\\\/uploads\\\/2014\\\/05\\\/Screen-Shot-2014-05-16-at-6.37.20-PM.png\",\"width\":\"1606\",\"height\":\"1010\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=11385#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/reactivemusic.net\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Granular time stretching 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":"Granular time stretching 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=11385","og_locale":"en_US","og_type":"article","og_title":"Granular time stretching in Max - reactive music","og_description":"Adaptation of Andy Farnell&#8217;s Pd granular timestretch patch Adjustable chunk-size, pitch, and speed &#8211; as well as manual scrubbing. The original Pd patch (timestretch.pd) is available here:\u00a0http:\/\/aspress.co.uk\/sd\/index.php download https:\/\/github.com\/tkzic\/max-projects folder: granular-timestretch patches timestretch5.maxpat (main patch) tabread4~.maxpat (Pd abstraction)\u00a0 hip~.maxpat (Pd abstraction) How it works An index pointer (file phasor) scans from the beginning to the &hellip; Continue reading \"Granular time stretching in Max\"","og_url":"https:\/\/reactivemusic.net\/?p=11385","og_site_name":"reactive music","article_published_time":"2014-05-16T22:46:21+00:00","article_modified_time":"2014-10-14T04:54:46+00:00","og_image":[{"url":"https:\/\/reactivemusic.net\/wp-content\/uploads\/2014\/05\/Screen-Shot-2014-05-16-at-6.37.20-PM-300x188.png","type":"","width":"","height":""}],"author":"Tom Zicarelli","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Tom Zicarelli","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/reactivemusic.net\/?p=11385#article","isPartOf":{"@id":"https:\/\/reactivemusic.net\/?p=11385"},"author":{"name":"Tom Zicarelli","@id":"https:\/\/reactivemusic.net\/#\/schema\/person\/56224d281582df7e5518e037ca63e571"},"headline":"Granular time stretching in Max","datePublished":"2014-05-16T22:46:21+00:00","dateModified":"2014-10-14T04:54:46+00:00","mainEntityOfPage":{"@id":"https:\/\/reactivemusic.net\/?p=11385"},"wordCount":456,"image":{"@id":"https:\/\/reactivemusic.net\/?p=11385#primaryimage"},"thumbnailUrl":"https:\/\/reactivemusic.net\/wp-content\/uploads\/2014\/05\/Screen-Shot-2014-05-16-at-6.37.20-PM-300x188.png","keywords":["DSP","electronic music","favorites","granular","Max\/MSP","Pd","portfolio"],"articleSection":["DSP","max-projects","Max\/MSP","Pd"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/reactivemusic.net\/?p=11385","url":"https:\/\/reactivemusic.net\/?p=11385","name":"Granular time stretching in Max - reactive music","isPartOf":{"@id":"https:\/\/reactivemusic.net\/#website"},"primaryImageOfPage":{"@id":"https:\/\/reactivemusic.net\/?p=11385#primaryimage"},"image":{"@id":"https:\/\/reactivemusic.net\/?p=11385#primaryimage"},"thumbnailUrl":"https:\/\/reactivemusic.net\/wp-content\/uploads\/2014\/05\/Screen-Shot-2014-05-16-at-6.37.20-PM-300x188.png","datePublished":"2014-05-16T22:46:21+00:00","dateModified":"2014-10-14T04:54:46+00:00","author":{"@id":"https:\/\/reactivemusic.net\/#\/schema\/person\/56224d281582df7e5518e037ca63e571"},"breadcrumb":{"@id":"https:\/\/reactivemusic.net\/?p=11385#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/reactivemusic.net\/?p=11385"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/reactivemusic.net\/?p=11385#primaryimage","url":"https:\/\/reactivemusic.net\/wp-content\/uploads\/2014\/05\/Screen-Shot-2014-05-16-at-6.37.20-PM.png","contentUrl":"https:\/\/reactivemusic.net\/wp-content\/uploads\/2014\/05\/Screen-Shot-2014-05-16-at-6.37.20-PM.png","width":"1606","height":"1010"},{"@type":"BreadcrumbList","@id":"https:\/\/reactivemusic.net\/?p=11385#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/reactivemusic.net\/"},{"@type":"ListItem","position":2,"name":"Granular time stretching 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\/11385","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=11385"}],"version-history":[{"count":14,"href":"https:\/\/reactivemusic.net\/index.php?rest_route=\/wp\/v2\/posts\/11385\/revisions"}],"predecessor-version":[{"id":17277,"href":"https:\/\/reactivemusic.net\/index.php?rest_route=\/wp\/v2\/posts\/11385\/revisions\/17277"}],"wp:attachment":[{"href":"https:\/\/reactivemusic.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11385"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/reactivemusic.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11385"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/reactivemusic.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11385"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}