Hi there
So I have the following code:
MIDIClient.init;
MIDIIn.connectAll;
(
SynthDef(\gera_1, {
arg out=0, freq=300, gate=1;
var snd, sndenv, rev, mix, revenv;
sndenv = EnvGen.ar(Env.adsr(0.03,0.1,0.9,0.2,curve:-2),gate:gate, doneAction:2);
snd = Saw.ar(freq,0.5)
+Saw.ar(freq*1.02,0.3);
snd = snd*sndenv;
Out.ar(out,snd!2);
}).add
)
(
SynthDef(\gera_1_fx, {
arg gate=1, out=0;
var input, dec, decenv;
input = In.ar(0,2);
decenv = EnvGen.ar(Env([0,1,0],[0.2,0.5]),gate:gate, doneAction:2);
dec = Decay.ar(input,0.2);
dec = dec*decenv;
Out.ar(out,dec);
}).add
)
a = Group.basicNew(s,1);
(
var notes;
notes = Array.newClear(128);
MIDIdef.noteOn(\on_gera, { arg veloc, num, chan, src;
notes[num] = Synth.head(a, \gera_1, [
\freq, num.midicps,
]);
Synth.tail(a, \gera_1_fx);
});
MIDIdef.noteOff(\off_gera, { arg veloc, num, chan, src;
notes[num].release;
});
)
My basic idea would be to use two SynthDefs: one for defining things like the wave form or frequency and so on and another one for effects and to be able to use individual envelopes for each of them.
When I use my MIDI keyboard the sound production to me seems to be kind of blocked when I play a little faster.
Sorry, I am probably misunderstanding some very basic concepts on how to do what I am looking for.