Hello,
I am very beginner here, don’t have much music theory and because I fail in distinguish oscillators I am trying to replicate an exercise described in this Ear Training for Sound Design video in SuperCollider. It’s about playing a random wave and guessing by ear. This is what I arrived to:
(
SynthDef(\sine, { |out = 0, freq = 440, amp = 0.1|
Out.ar(out, SinOsc.ar(freq, 0, amp))
}).add;
SynthDef(\saw, { |out = 0, freq = 440, amp = 0.1|
Out.ar(out, Saw.ar(freq, amp))
}).add;
SynthDef(\tri, { |out = 0, freq = 440, amp = 0.1|
Out.ar(out, LFTri.ar(freq, 0.5, amp))
}).add;
SynthDef(\pulse, { |out = 0, freq = 440, amp = 0.1|
Out.ar(out, Pulse.ar(freq, 0.5, amp))
}).add;
~synthDefs = [\sine, \saw, \tri, \pulse];
)
(
SynthDef(\env, { |in, out = 0|
var sig, env;
sig = In.ar(in, 1);
env = EnvGen.kr(Env([0, 1, 0], [1, 0.1]), \doneAction: 2);
sig = sig * env;
sig = sig ! 2;
Out.ar(out, sig);
}).add;
)
(
~randomSynth = {
Synth(\env, [\in, 1]);
Synth(~synthDefs.choose, [
\freq, (60 + Scale.major.semitones).midicps.choose,
\amp, rrand(0.1, 0.4),
\out, 1,
]);
};
)
~randomSynth.();
Here I have four types of oscillators and I want to play a random one each time I execute the function. Because I only want them to last for one second, I am sending their output to an envelope that is supposed to free after use. Also I would like to be stereo.
I have both problems, they are not freed, and they are not in stereo. I somehow listen the synth for one second in my left ear, but on the right is keep going. This makes me think that I am applying the envelope only to the left signal, but in the code I am duplicating the result signal * envelope
afterwards.
Could you point out what is that have incorrect please?
Also interested in know how would you do code this exercise in SuperCollider.
Thanks,
Juan