Forums > MaxMSP

[sharing] grainstretch~

January 25, 2012 | 2:38 pm

I just released my new external grainstretch~

This flexible granular audioplayer object is based on the algorithm in Mattijs Kneppers’ granular timestretcher max patch. But now in 1 max object and with lots of other features and options (including streaming mode, so you have a ‘no-latency’ pitchshifter).

for mac and windows
for max 5 and max 6

have fun!

January 25, 2012 | 3:11 pm


thanks for this. very nice


January 26, 2012 | 12:27 am

can i use in maxforlive?

January 26, 2012 | 12:47 am

i get his when trying to load in m4l. am i doing something wrong?

January 26, 2012 | 1:34 am

your search path perhaps isn’t set up properly?

January 26, 2012 | 3:48 am

Thank u ! it is stable ?

January 26, 2012 | 7:13 am

thanks guys

yes you can use it in max 4 live, make sure it the mxo file (for mac) or mxe (for windows) is in in a place where m4l will find the object, usually something like the Cycling ’74 folder of your max install

I hope it is stable, I can’t get it to crash… if you can, let me know and I’ll try to fix it

January 26, 2012 | 12:34 pm

i tried reinstalling, copying into cycling74 folder and got this in the max window.

January 26, 2012 | 1:03 pm

ok, interesting… what version of os x do you use? and what processors do you have? Intel or not?

It is compiled with Lion, and I know it works fine in Snow Leopard. It is not a universal build so it won’t work on a powerpc (G5, G4 etc)

January 26, 2012 | 5:28 pm

here you go.

System Version: Mac OS X 10.5.8 (9L31a)

Model Name: iMac
Model Identifier: iMac7,1
Processor Name: Intel Core 2 Duo
Processor Speed: 2.4 GHz

i’m very behind. i’m guessing it wont run on leopard?

January 26, 2012 | 5:47 pm

yes that was the problem, it didn’t run on Leopard, but I updated it, please try again with the new version on

January 26, 2012 | 7:49 pm

Hey, this is really great! Only one question: is it possible to turn looping off?

January 26, 2012 | 8:46 pm

thanks for doing that port to leopard! i cant get over how great this is. reminds me loads of granulab on the pc from years ago. never been able to find anything to replace that, until now!

i love how with a super slow speed and a high grain size you get mega evolving techno!

greta work.

January 26, 2012 | 9:54 pm

good to hear that it works now for you nedrush

@rwg: unfortunately no, but what about this solution, it uses an adsr~ to mute the signal and stop the processing too:

– Pasted Max Patch, click to expand. –

That still leaves the question how to stop it at exactly the end while playing with the playback parameters. But that raises more questions, also about position randomness and such.

January 26, 2012 | 10:27 pm

Absolutely lovely – this is already a great thing for realtime processing. But, okay, now on to my question at hand:

Does anyone have an idea about how to apply the stretching itself to a rotating live input buffer? I’d love love love for that to be at all possible.

January 26, 2012 | 10:44 pm

well, internally it has a rotating live input buffer :-)

what is that you want exactly?

January 26, 2012 | 11:22 pm

yeah, it occured to me, since you can do the "randompositionoffset" even in streaming mode.

Well, I already love it as-is, but would kill for a way to get that time-stretched sound with this even in streaming – in other words, to get the [speed $1] and ideally [pos $1] to run in streaming mode; yes, it might end up sounding… "experimental", but that’s what I’m looking for ;)


January 27, 2012 | 12:11 am

yeah, I already did something similar. What I need, among other things, is to be able to trigger a soundfile and play it once (without looping) and adjust its speed dynamically according to some live-input data.

Of course other objects exists for that, for example the from ircam – but I actually really like the sound and some of the other features of the grainstretch~… So a non-looping version would be awesome ;-)


January 27, 2012 | 2:12 am

well, honestly I’d say it’s very different; I’m talking about the live-input streaming version, not a buffer manipulator per se.

January 27, 2012 | 8:51 am

@Wetterberg: rwg is talking about something else: turning loop function off
What you want with the live buffer is a bit of a puzzle and maybe a separate object will work better for that. Maybe I’ll do it sometime, but not very soon.

@rwg: I’ll check how much work it is and I can imagine that it’s hard to get it proper sounding with position- and pitch randomness (these wrap around the file currently)

January 27, 2012 | 12:37 pm

is this something you are planning to continue work on and expand? if so can i offer a suggestion of a pitch envelope on single grains? so if i have a high grain size and a slow speed, i can get pitch changes with each new grain? or is that totally wack?

if not could i do this in max anyway? maybe but somehow monitoring the grain size, converting that to clicks then using those clicks to trigger an adsr~ multiplying the pitch?


January 27, 2012 | 1:13 pm

@nedrush: I think I will let it go for a bit, I mean, I just wait and see what people want and collect feature requests (and fix bugs if people have problems) and then in a later stage I’ll decide what to add.

I don’t full understand your idea, currently the pitch is applied at the start of the grain (and it remains constant during the grain), this makes parameter changes smooth and without clicks.
This already sounds a bit like what you are after, or do I miss something?

January 27, 2012 | 3:42 pm

Yes, of course randomness doesn’t go so well with the idea of a non-looping player… But without randomness it would be great – and in my eyes really make this external a bit more complete – but hey, this is just my opinion ;-)

Anyway it should be possible to make a system that stops it at the end by using information about samplelength, speed and position. I’ll get back about that if I manage to make a solution when I have time.

I hope you continue to develop this external as I think that what you have done this far is really good!

January 27, 2012 | 4:16 pm

@timo i could probably demonstrate the idea using a regular sampler and post a video, or i’ll look around for something that explains it better.

January 27, 2012 | 7:14 pm


maybe look around for a video:

Inspired by Timo’s video, I’ve got some very funky pitch/time stretchiness here, applied using the very algo Timo (and yourself) describes


January 28, 2012 | 2:08 am

here you go. heres me jamming around with it, plugged into a pitched reverb which is on a feedback loop.

apologies if you’re not into half an hour of cacophonous drone techno.

January 28, 2012 | 12:45 pm

this is a great object, some very clean musical sounds imo. thanks very much, I can see this getting incorporated into a few patches :)

July 24, 2012 | 3:28 pm


I just put grainstretch into my msp-externals folder but it doesn’t come up when i look for it on object explorer. Any ideas why ?


July 25, 2012 | 8:47 am

Hi Freddy,

personally I never use the object explorer, but I don’t think third party externals appear there.
does it work when you simple make a new object (press ‘n’) and type grainstretch~ in it?


October 3, 2012 | 1:02 pm

Yes it does actually.


October 3, 2012 | 9:11 pm

Timo, this is a really nice and good sounding max external used it for awhile in max. Now just built a device around it in M4L and it seems to act a bit differently but I have to try it further to be sure…

October 5, 2012 | 11:23 am

i’m using this in a sampler project. timo, i noticed it seems to be hardcoded to 44kHz. with other samplefreq. a speed value of 1. is not the normal pitch anymore. i can work around it. it creates nice grain clouds.

October 5, 2012 | 1:34 pm

I like this object and have built it into a patch I’m using Tuesday. For all of its great features it is lacking some basic functions (based on copying and pasting from the help file), such as a start/stop loop, and a reset for neutral settings. I’ll have to hack into it more to deal with the latter. For the former I’ve added a standard gain~ object, with 128 and 0 messages sent to it; I’m not so much starting and stopping the loop as I am the audio feed. Feeding a silent audio file into the buffer is also useful.

January 5, 2014 | 12:56 pm

Hi Timo

I’ve been enjoying your grainstretch~ external for a few months now. It’s very comprehensible. Huge thanks. Big benefit to my quality of life. I have two questions and thought I’d ask them here.
First, what kind of grain envelope is controlled by the fade command? I suspect it’s a Hanning, but maybe it’s a trapezoid, or maybe there’s a way to customize it.
Second, do you have any version where the grain number can be customized? I should be able to handle 32 voices no sweat, if that’s an option.

Thanks again

January 5, 2014 | 1:04 pm

Yes !
Timo , Sir ? can you provide 64bit version for windows ?

January 23, 2014 | 7:16 am

Great, great, great external..thanks Timo for sharing your work with us.
I’m using it mostly as a sample-masher/granulator.
Feature request, if I may: all the parameters control seems to work very smoothly, but sometimes I get some clicks when changing the grain size, has anyone else noticed that?
It would be great to have a click-free ‘size’ parameter control.

Btw, thanks again for this amazing external Timo

June 1, 2014 | 4:50 am

Hi Timo,

I get this message when I trying to load in Max6 running on OS X Mavericks. Is there something wrong?


Viewing 37 posts - 1 through 37 (of 37 total)