36 lines
705 B
Plaintext
36 lines
705 B
Plaintext
// connect all midi devices
|
|
(
|
|
MIDIClient.init;
|
|
MIDIIn.connectAll;
|
|
|
|
MIDIFunc.trace(true);
|
|
)
|
|
|
|
// on and off notes are tracked using an array
|
|
// the synth need to be using a gated envelope.
|
|
(
|
|
~synths = Array.fill(127, nil);
|
|
MIDIdef.noteOn(\on, {
|
|
arg val, num, chan,src;
|
|
// To be absolutely safe
|
|
if(~synths[num] == nil, {
|
|
~synths[num] = Synth(\pad, [
|
|
\amp, 0.1,
|
|
\freq, num.midicps,
|
|
\harm, exprand(4,20),
|
|
\gate, 1]);
|
|
});
|
|
});
|
|
|
|
MIDIdef.noteOff(\off, {
|
|
arg val, num, chan,src;
|
|
// To be absolutely safe
|
|
if(~synths[num] != nil, {
|
|
~synths[num].set(\gate, 0);
|
|
// Remove the reference
|
|
~synths[num] = nil;
|
|
});
|
|
});
|
|
)
|
|
|
|
Synth(\pad) |