Dear users,
The method .play
in the following two codes runs two Synth
simultaneously when being evaluated:
// code 1:
(
fork{
SynthDef(\test, { |delay = #[0, 0]|
var sig = SinOsc.ar * Env.perc.kr(doneAction: Done.freeSelf) * 0.1;
sig = DelayC.ar(sig, 0.1, delay);
FreeSelf.kr(TDelay.ar(sig, 0.2));
OffsetOut.ar(0, sig)
}
).add;
s.sync;
3.do{
(
instrument: \test,
delay: [1, -1] * 0.01.rand2
).play;
1.wait;
s.queryAllNodes;
1.wait
}
}
)
// code 2:
(
fork{
SynthDef(\test, { |delay = #[0, 0]|
var sig = SinOsc.ar * Env.perc.kr(doneAction: Done.freeSelf) * 0.1;
sig = DelayC.ar(sig, 0.1, delay);
FreeSelf.kr(TDelay.ar(sig, 0.2));
OffsetOut.ar(0, sig)
}
).add;
s.sync;
{ s.plotTree }.defer;
Pbind(
\instrument, \test,
\delay, [1, -1] * Pwhite(-0.02, 0.02, 3).trace(prefix: "delay: "),
\dur, 2
).play
};
)
I think it is because their outputs are an array with two items. I should read the help documents, but it would be beneficial if someone gave me some clues.
Anyway, I tried to rewrite each code in two ways as follows:
// code 3:
(
fork{
SynthDef(\test, { |delay = #[0, 0]|
var sig = SinOsc.ar * Env.perc.kr(doneAction: Done.freeSelf) * 0.1;
sig = DelayC.ar(sig, 0.1, delay);
FreeSelf.kr(TDelay.ar(sig, 0.2));
OffsetOut.ar(0, sig)
}
).add;
s.sync;
3.do{
(
instrument: \test,
#[delay]: [1, -1] * 0.01.rand2
).play;
1.wait;
s.queryAllNodes;
1.wait
}
}
)
// code 4:
(
fork{
SynthDef(\test, { |delay = #[0, 0]|
var sig = SinOsc.ar * Env.perc.kr(doneAction: Done.freeSelf) * 0.1;
sig = DelayC.ar(sig, 0.1, delay);
FreeSelf.kr(TDelay.ar(sig, 0.2));
OffsetOut.ar(0, sig)
}
).add;
s.sync;
3.do{
(
instrument: \test,
delay: `[1, -1] * 0.01.rand2
).play;
1.wait;
s.queryAllNodes;
1.wait
}
}
)
// code 5:
(
fork{
SynthDef(\test, { |delay = #[0, 0]|
var sig = SinOsc.ar * Env.perc.kr(doneAction: Done.freeSelf) * 0.1;
sig = DelayC.ar(sig, 0.1, delay);
FreeSelf.kr(TDelay.ar(sig, 0.2));
OffsetOut.ar(0, sig)
}
).add;
s.sync;
{ s.plotTree }.defer;
Pbind(
\instrument, \test,
#[delay], [1, -1] * Pwhite(-0.02, 0.02, 3).trace(prefix: "delay: "),
\dur, 2
).play
};
)
// code 6:
(
fork{
SynthDef(\test, { |delay = #[0, 0]|
var sig = SinOsc.ar * Env.perc.kr(doneAction: Done.freeSelf) * 0.1;
sig = DelayC.ar(sig, 0.1, delay);
FreeSelf.kr(TDelay.ar(sig, 0.2));
OffsetOut.ar(0, sig)
}
).add;
s.sync;
{ s.plotTree }.defer;
Pbind(
\instrument, \test,
\delay, `([1, -1] * Pwhite(-0.02, 0.02, 3)),
\dur, 2
).play
}
)
Codes 3, 4, and 5 work correctly.
However, the last code, code 6, needs to be corrected. The method â.playâ does not run two Synths, but it does not end after playing the third sound. Why does it happen? What is the correct notation for this?
I appreciate any help you can provide.