Sustain Pedal for guitar / anything else

Hello everybody.
My interest was to make a sustain pedal for any Input signal. Specifically targeted at a guitar. I’m not quite sure, but I think i remember somewhere something like that was already implemented for Supercollider but i cannot find it. Maybe my memories also deceive me here…
Does anyone have any ideas how one could implement such a thing? Basically a sustain for any or signal. Not sure if it makes sense to create some infinite reverb or record a buffer and hold it.
Maybe someone has an idea or remembers if there was a posting along this line. Thank you very much.

Hello there,
This is not the expected answer, but maybe it will help.

I’m not sure if there’s an official definition of this kind of sustain. I don’t use it myself, because I like the idea of having an analogical sustain with tremolo, but I think the pedal holds the note of the guitar until another note is played, so it’s repeating a certain timbre at a certain frequency until it detects another timbre or another pitch, right ?

Then I’d say that using an AllpassN or a buffer could be the right solution to sample the sound and play it again and again. I think the problem would be how to loop on the right frequency, I don’t know how to implement a frequency detector myself, but I think FFT can achieve this. Another idea I have is to loop on several cycles and apply an envelope slowly fading in and out, so we don’t hear that the freq is not properly synced with the previous loop. But that’s because I’m a bad sound engineer :grinning: .

I guess FFT is the “best” way to achieve a sustain effect. But it’s possible to get a reasonable sustain/freeze sound with granular synthesis - Eli’s tutorial shows this here:

Heyy, thanks for u responsed. Mh this is what I came up with, its a way of sustaining i guess, not a perfect or optimized at all way. kinda trial and error. If you have some ideas how to improve let me know.
I used Grain for this task now, not entirely sure how I could do it with a FFT.
Anyhow, here is the code, you can test it, if you have a device for Pay attention I amplified this signal, for my personal specs:

~b_sus = Buffer.alloc(s, s.sampleRate * 0.1,1);
	var sig, rec, loop, ptr, buf, run;
	//run is for when the pedal is pressed
	//for demonstration purposes you can
	//use your mouse instead
	//mouse in the left half is just your signal
	//mouse on right half is when the sustain pedal is pressed
	//right now, 'pressing' the pedal mutes your original signal
	run =,0).round;
	//heres the buffer
	//your sound input, i used a microphone
	//pay attention to feedback, i amplified this signal!!
	rec = (*15).tanh;
	//record and re-record/overdub the previous rec channel
	ptr =,, 0,;
	loop =,buf,ptr);
	loop = (rec*run)+(loop*(1-run));, buf, ptr);
	//the actual output signal
	sig = 0.25*
	//maybe add some reverb? dunno
	// sig =;
	//high pass, since some bass resonance might happen
	sig =,80);
	//plays the record input, with run = 0
	//with run = 1 the sustain effect
	sig = (sig*(1-run.lag(0.1))) + (rec*run.lag(0.1));

You can use the classes PV_Freeze and PV_MagFreeze.
See help files for examples: