Skip to content

Instantly share code, notes, and snippets.

@iani
Created June 29, 2013 11:34
Show Gist options
  • Save iani/5890827 to your computer and use it in GitHub Desktop.
Save iani/5890827 to your computer and use it in GitHub Desktop.
How to use DetectSilence in SuperCollider to start a new sound when another sound falls below a certain amplitude level. Here we use AllpassC to add a reverb on the tail of the sound that we are tracking.
(
SynthDef("releaser", { | gate = 1 |
var env;
env = Env([0, 1, 0], [0.04, 6.0], releaseNode: 1);
Out.ar(0, WhiteNoise.ar(1) * EnvGen.kr(env, gate, doneAction: 2))
}).add;
)
(
SynthDef("reverbreleaser_template", { | gate = 1 |
var env, source, reverb;
env = Env([0, 1, 0], [0.04, 6.0], releaseNode: 1);
source = WhiteNoise.ar(1) * EnvGen.kr(env, gate, doneAction: 0);
reverb = GrayNoise.ar(1) * DetectSilence.ar(source, 0.5);
Out.ar(0, [source, reverb])
}).add;
)
(
SynthDef("reverbreleaser", { | gate = 1 |
var env, source, reverb;
env = Env([0, 1, 0], [0.04, 6.0], releaseNode: 1);
source = SinOsc.ar(LFNoise2.kr(5).range(400, 4000))
* EnvGen.kr(env, gate, doneAction: 0);
reverb = Mix({
AllpassC.ar(source, 0.3, 0.001.exprand(0.1) min: 0.3, decaytime: 5);
} ! 20
)* DetectSilence.ar(source, 0.5);
Out.ar(0, [source, reverb])
}).add;
)
a = Synth('reverbreleaser');
a.release(10);
a.release(3);
a.release(10);
a = Synth('releaser');
a.set(\gate, 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment