27 lines
562 B
Plaintext
27 lines
562 B
Plaintext
(
|
|
MIDIClient.init;
|
|
MIDIIn.connectAll;
|
|
|
|
MIDIFunc.trace(true);
|
|
)
|
|
|
|
(
|
|
~synths = Array.fill(127, nil);
|
|
MIDIdef.noteOn(\on, {
|
|
arg val, num, chan,src;
|
|
if(~synths[num] == nil, { // To be absolutely save
|
|
~synths[num] = Synth(\supersaw, [
|
|
\amp, 0.1,
|
|
\freq, num.midicps,
|
|
\harm, exprand(4,20)]);
|
|
});
|
|
});
|
|
|
|
MIDIdef.noteOff(\off, {
|
|
arg val, num, chan,src;
|
|
if(~synths[num] != nil, { // To be absolutely safe
|
|
~synths[num].set(\gate, 0);
|
|
~synths[num] = nil; // Remove the reference
|
|
});
|
|
});
|
|
) |