<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Quality granular processing in pd]]></title><description><![CDATA[<p>I'm having fun with granular processing of samples and live input of acoustic instruments.and I'm thinking about making a granular processor in pd.</p>
<p>I've tried several granular apps and software (I love Grainstorm on Android) but I keep seeing interesting possibilities that none have implemented, especially for live manipulation.</p>
<p>I don't want to spend months making a patch and end up with crap sound. Would I be able to make granular patches with sound quality at least close to the available granular software? I have a good grasp of pd/Max. Any tricks/pitfalls you can think of (besides declicking)? Thanks!</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/15784/quality-granular-processing-in-pd</link><generator>RSS for Node</generator><lastBuildDate>Tue, 17 Mar 2026 15:54:37 GMT</lastBuildDate><atom:link href="http://forum.pdpatchrepo.info/topic/15784.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 09 Jan 2026 21:08:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Quality granular processing in pd on Fri, 09 Jan 2026 21:08:00 GMT]]></title><description><![CDATA[<p>I'm having fun with granular processing of samples and live input of acoustic instruments.and I'm thinking about making a granular processor in pd.</p>
<p>I've tried several granular apps and software (I love Grainstorm on Android) but I keep seeing interesting possibilities that none have implemented, especially for live manipulation.</p>
<p>I don't want to spend months making a patch and end up with crap sound. Would I be able to make granular patches with sound quality at least close to the available granular software? I have a good grasp of pd/Max. Any tricks/pitfalls you can think of (besides declicking)? Thanks!</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/15784/quality-granular-processing-in-pd</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/15784/quality-granular-processing-in-pd</guid><dc:creator><![CDATA[Moddmo]]></dc:creator><pubDate>Fri, 09 Jan 2026 21:08:00 GMT</pubDate></item><item><title><![CDATA[Reply to Quality granular processing in pd on Sat, 10 Jan 2026 08:52:15 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-a" href="http://forum.pdpatchrepo.info/user/moddmo">@Moddmo</a> said:</p>
<blockquote>
<p>I don't want to spend months making a patch and end up with crap sound.</p>
</blockquote>
<p>Well, that's hard to promise because I'm not sure exactly what you mean by crap sound. <img class="emoji emoji-extended" src="http://forum.pdpatchrepo.info/plugins/nodebb-plugin-emoji-extended/images/laughing.png" title="laughing" alt=":laughing:" /></p>
<p>What I can say is that granular synthesis is made up of short clips of audio under envelopes. Pd can do both:</p>
<ul>
<li>clips: <code>tabread4~</code> for a sound file loaded into memory, <code>delread4~</code> for live input.</li>
<li>envelopes: you can fill an array with a Hann (or any other type of) window, and stream it out using <code>tabread4~</code> as well.</li>
</ul>
<p>Pd has one edge over Max here, in that Pd's <code>metro</code> is sub-block accurate. In both Pd and Max, there's an audio block size (default 64 samples), and control messages execute only on those block boundaries. In Max, last time I tried to do granular synthesis driven by control messages, I could hear the timing inaccuracy due to the messages being quantized to these block boundaries. (Maybe that's changed in Max 9, but that's my recollection from Max 8.) In Pd, control messages are processed on block boundaries, but they also carry sub-block timing information so that grains will start on the right sample, not just the right block. IMO Pd's timing was noticeably smoother. (In Max, multichannel signals get a better result.)</p>
<p>For sound quality, it's very helpful to introduce a little bit of randomness into the grain time position, to avoid &quot;machine gun&quot; effects.</p>
<p>Again, &quot;close to the available software,&quot; I'm not sure exactly what you mean. With proper tuning, I was able to get a pretty smooth sound out of it. Maybe an example later.</p>
<p>hjh</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/15784/quality-granular-processing-in-pd/2</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/15784/quality-granular-processing-in-pd/2</guid><dc:creator><![CDATA[ddw_music]]></dc:creator><pubDate>Sat, 10 Jan 2026 08:52:15 GMT</pubDate></item><item><title><![CDATA[Reply to Quality granular processing in pd on Sat, 10 Jan 2026 09:54:50 GMT]]></title><description><![CDATA[<p>OK, here's a basic live input granulator, no really fancy features, just pitch shifting.</p>
<p>The handling of grain playback rate in the one-grain abstraction is a neat trick I had worked out some time ago. For example, if you want to play the grain an octave higher (2x speed), then you need to span <code>2 * dur</code> ms of audio in <code>dur</code> ms of time. You can do that by modulating the delay time as a straight line, from <code>dur</code> ms to 0 ms -- adding <code>dur</code> to the delay time at the beginning adds that many ms to the amount of audio being used: <code>dur * (rate-1)</code>. Or, to play slower, start with a shorter delay and go toward a longer delay, and the boundary is again <code>dur * (rate-1)</code>. If rate = 1, then the delay time goes from 0 to 0 = no change = normal speed. That might look a bit funky in the patch you can try it with different transposition intervals, which will show that it's correct.</p>
<p>For sound file processing, replace the delay line with a soundfiler-filled array, and use tabread4~ for the audio source (and the line~ driving it will have to be different too).</p>
<p>IMO granular processing is 99% refinement and more advanced modulation of these basic parameters, which you should be able to tailor to your needs. I <em>think</em> the pitch shifting is more-or-less smooth here, though I'm not sure it matches your comparison plugins -- this is 66.6667 grains per second, with 4x overlap.</p>
<p><a href="/uploads/files/1768038611712-one-delay-grain.pd">one-delay-grain.pd</a><br />
<a href="/uploads/files/1768038611711-live-granular.pd">live-granular.pd</a></p>
<p>hjh</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/15784/quality-granular-processing-in-pd/3</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/15784/quality-granular-processing-in-pd/3</guid><dc:creator><![CDATA[ddw_music]]></dc:creator><pubDate>Sat, 10 Jan 2026 09:54:50 GMT</pubDate></item><item><title><![CDATA[Reply to Quality granular processing in pd on Sat, 10 Jan 2026 13:35:13 GMT]]></title><description><![CDATA[<p>this has   a bunch of stuff     it uses an older version of pd sometimes but you can work around it , they changed a couple object names.<br />
<a href="http://pd-tutorial.com/" rel="nofollow">http://pd-tutorial.com/</a><br />
<a href="http://pd-tutorial.com/english/ch03s07.html" rel="nofollow">http://pd-tutorial.com/english/ch03s07.html</a><img src="/uploads/files/1768052109225-screenshot_2026-01-10_13-33-42.png" alt="Screenshot_2026-01-10_13-33-42.png" class="img-responsive img-markdown" /></p>
]]></description><link>http://forum.pdpatchrepo.info/topic/15784/quality-granular-processing-in-pd/4</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/15784/quality-granular-processing-in-pd/4</guid><dc:creator><![CDATA[willblackhurst]]></dc:creator><pubDate>Sat, 10 Jan 2026 13:35:13 GMT</pubDate></item><item><title><![CDATA[Reply to Quality granular processing in pd on Sat, 10 Jan 2026 17:22:40 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-a" href="http://forum.pdpatchrepo.info/user/moddmo">@Moddmo</a> Try this vanilla (no deps, I think) patch by:</p>
<p>Granular21 patch by Jakob Skouborg 3.2.21</p>
<pre><code>I run the patch at 48khz, but you should be able to run it at any sample rate.
The sample that comes with the patch in the ´+Sounds+ folder is 48khz!!!!
So if you want to run it at 44.1khz, you need to convert the sample!!!!
</code></pre>
<p><img src="/uploads/files/1768065709258-image.png" alt="image.png" class="img-responsive img-markdown" /></p>
<p><a href="/uploads/files/1768065757944-granular21.zip">granular21.zip</a></p>
]]></description><link>http://forum.pdpatchrepo.info/topic/15784/quality-granular-processing-in-pd/5</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/15784/quality-granular-processing-in-pd/5</guid><dc:creator><![CDATA[EEight]]></dc:creator><pubDate>Sat, 10 Jan 2026 17:22:40 GMT</pubDate></item><item><title><![CDATA[Reply to Quality granular processing in pd on Sun, 11 Jan 2026 01:15:31 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-a" href="http://forum.pdpatchrepo.info/user/ddw_music">@ddw_music</a></p>
<p>Thank you! I will play around with this.</p>
<p>And fair enough, crap vs. quality sound is subjective. I guess a better question is if pd has disadvantages here compared to other DSP programming languages.</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/15784/quality-granular-processing-in-pd/6</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/15784/quality-granular-processing-in-pd/6</guid><dc:creator><![CDATA[Moddmo]]></dc:creator><pubDate>Sun, 11 Jan 2026 01:15:31 GMT</pubDate></item><item><title><![CDATA[Reply to Quality granular processing in pd on Sun, 11 Jan 2026 03:57:27 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-a" href="http://forum.pdpatchrepo.info/user/moddmo">@Moddmo</a> said:</p>
<blockquote>
<p>I guess a better question is if pd has disadvantages here compared to other DSP programming languages.</p>
</blockquote>
<p>Granular synthesis is sometimes imagined as this magical, complex thing, but the fundamentals are quite simple. Get the fundamentals right, and the sound quality follows from that (and is mainly a matter of parameter tuning).</p>
<p>So you're playing back a block of audio from a buffer or a delay line. (I used a delay line because that's the best way to implement a circular buffer in Pd vanilla. You could also use cyclone [count~] to generate phase for use with [tabwrite~] and [tabread4~].) The important points here are to get the boundaries of the audio segment correct, and to modulate the starting position intelligently. &quot;Boundaries&quot; includes concepts of: how many grains per second should be triggered, how many of them overlap, how fast will the audio be played.</p>
<p>And each grain needs an envelope matching the grain duration.</p>
<p>In my example, I've already tuned it for one specific use case (pitch shifting). But there's no magic here -- it really is just linear audio playback with envelopes, overlapped and added.</p>
<p>Comparison with other DSP environments, then, is just a matter of implementation. E.g., SuperCollider has UGens (single objects) TGrains and GrainBuf that do the audio segment <em>and</em> envelope <em>and</em> overlap/add for you, so that you can concentrate on the parameters:</p>
<pre><code>s.boot;  // sort of like &quot;; pd dsp 1&quot;

(
var rateSl;

a = { |inbus, rate = 1, trigFreq = 66.66667, overlap = 4|
    var sr = SampleRate.ir;
    var maxDelaySamps = 2 * sr;
    
    var src = In.ar(inbus, 1);
    
    // &quot;delwrite&quot; part (rolling my own circular buffer)
    var buf = LocalBuf(maxDelaySamps, 1).clear;
    var phase = Phasor.ar(0, 1, 0, maxDelaySamps);
    var writer = BufWr.ar(src, buf, phase);
    
    // *all* of the rest of it
    var trig = Impulse.ar(trigFreq);
    var grainDur = overlap / trigFreq;
    var delayBound = max(0, grainDur * (rate - 1));
    // grain position in samples, for now
    var pos = phase - (sr * (delayBound + TRand.ar(0.0, 0.003, trig)));

    GrainBuf.ar(2,
        trig, grainDur, buf,
        rate,
        pos: (pos / maxDelaySamps) % 1.0,  // normalized pos in GrainBuf
        interp: 4  // cubic
    ) * 0.4;
}.play(args: [inbus: s.options.numOutputBusChannels]);

rateSl = Slider(nil, Rect(800, 200, 200, 50))
.value_(0.5)
.orientation_(\horizontal)
.action_({ |view|
    a.set(\rate, view.value.linexp(0, 1, 0.25, 4))
})
.onClose_({ a.free })
.front
)
</code></pre>
<p>The DSP design here is the same as in the Pd patch (rate-scaled audio segments under Hann windows [GrainBuf gives you Hann windows for free], with a 3 ms randomized timing offset for each grain) so the sound should be basically identical. Personally I find the SC way to be easier to read and write, but I wouldn't expect everyone on a graphical patching forum to feel the same <img class="emoji emoji-extended" src="http://forum.pdpatchrepo.info/plugins/nodebb-plugin-emoji-extended/images/wink.png" title="wink" alt=":wink:" /></p>
<p>hjh</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/15784/quality-granular-processing-in-pd/7</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/15784/quality-granular-processing-in-pd/7</guid><dc:creator><![CDATA[ddw_music]]></dc:creator><pubDate>Sun, 11 Jan 2026 03:57:27 GMT</pubDate></item><item><title><![CDATA[Reply to Quality granular processing in pd on Sun, 11 Jan 2026 22:59:04 GMT]]></title><description><![CDATA[<p>Have a look at my granulation external and be sure to let me know if it meets your definition of crap.<br />
<a href="https://puredata.info/Members/ricky/software/rfpg/0.1/" rel="nofollow">https://puredata.info/Members/ricky/software/rfpg/0.1/</a></p>
]]></description><link>http://forum.pdpatchrepo.info/topic/15784/quality-granular-processing-in-pd/8</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/15784/quality-granular-processing-in-pd/8</guid><dc:creator><![CDATA[ricky]]></dc:creator><pubDate>Sun, 11 Jan 2026 22:59:04 GMT</pubDate></item><item><title><![CDATA[Reply to Quality granular processing in pd on Mon, 12 Jan 2026 00:03:17 GMT]]></title><description><![CDATA[<p>mine might be crappy too, see [else/grain.live~]</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/15784/quality-granular-processing-in-pd/9</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/15784/quality-granular-processing-in-pd/9</guid><dc:creator><![CDATA[porres]]></dc:creator><pubDate>Mon, 12 Jan 2026 00:03:17 GMT</pubDate></item></channel></rss>