(
var tutorialDecayPink =
{
arg outBus = 0, effectBus,
direct = 0.5; // controls proportion of "direct" / "processed" sound
var source;
// Decaying pulses of PinkNoise.
source = Decay2.ar( in:Impulse.ar( freq:1, phase:0.25 ),
attackTime:0.01,
decayTime:0.2,
mul:PinkNoise.ar
);
Out.ar( outBus, (source*direct) ); // main output
Out.ar( effectBus, (source*(1-direct)) ); // effects output
};
var tutorialDecaySine =
{
arg outBus = 0, effectBus,
direct = 0.5; // controls proportion of "direct" / "processed" sound
var source;
// Decaying pulses of a modulating Sine wave.
source = Decay2.ar( in:Impulse.ar( freq:0.3, phase: 0.25),
attackTime:0.3,
decayTime:1,
mul:SinOsc.ar( freq:SinOsc.kr( freq:0.2, mul:110, add:440) )
);
Out.ar(outBus, (source*direct) ); // main output
Out.ar(effectBus, (source*(1-direct)) ); // effects output
};
var tutorialReverb =
{
arg outBus = 0, inBus; // default outBus is audio interface
var input;
input = In.ar( inBus, 1 );
16.do( { input = AllpassC.ar( in:input,
maxdelaytime:0.04,
delaytime:{ Rand(0.001,0.04) }.dup,
decaytime:3
)
}
);
Out.ar( outBus, input );
};
// send synthesis information to the server
SynthDef( \tutorialReverb, tutorialReverb ).send( s );
SynthDef( \tutorialDecayPink, tutorialDecayPink ).send( s );
SynthDef( \tutorialDecaySine, tutorialDecaySine ).send( s );
// reserve an effects Bus
b = Bus.audio( s );
)
(
x = Synth.new( \tutorialReverb, [\inBus, b] );
y = Synth.before( x, \tutorialDecayPink, [\effectBus, b] );
z = Synth.before( x, \tutorialDecaySine, [\effectBus, b, \outBus, 1] );
)
// Change the balance of "wet" to "dry"
y.set( \direct, 1 ); // only direct PinkNoise
z.set( \direct, 1 ); // only direct Sine wave
y.set( \direct, 0 ); // only reverberated PinkNoise
z.set( \direct, 0 ); // only reverberated Sine wave
y.set( \direct, 0.5 ); // original PinkNoise
z.set( \direct, 0.5 ); // original Sine wave
( // commands to free each Object
x.free; x = nil;
y.free; y = nil;
z.free; z = nil;
b.free; b = nil;
)
I'm not going to explain this example as extensively as the previous one. It's definitely the most complex example so far. It's better if you figure out what the parts do by playing with them yourself. The bus works by routing audio from the \tutorialDecayPink
and \tutorialDecaySine
synths into the \tutorialReverb
synth. The first two synths can be controlled to put all, none, or some of their signal into the bus (so that it goes through the \tutorialReverb
synth), or straight out the audio interface (bypassing the \tutorialReverb
synth). Notice that the same effects processor is operating on two different input sources.