1
0
Files
scoobidules/midi_in_gate.scd
2025-02-26 07:36:13 +01:00

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
});
});
)