feat: load synthef on startup
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
// connect all midi devices
|
||||
(
|
||||
MIDIClient.init;
|
||||
MIDIIn.connectAll;
|
||||
@ -5,23 +6,31 @@ 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;
|
||||
if(~synths[num] == nil, { // To be absolutely save
|
||||
~synths[num] = Synth(\supersaw, [
|
||||
// To be absolutely safe
|
||||
if(~synths[num] == nil, {
|
||||
~synths[num] = Synth(\pad, [
|
||||
\amp, 0.1,
|
||||
\freq, num.midicps,
|
||||
\harm, exprand(4,20)]);
|
||||
\harm, exprand(4,20),
|
||||
\gate, 1]);
|
||||
});
|
||||
});
|
||||
|
||||
MIDIdef.noteOff(\off, {
|
||||
arg val, num, chan,src;
|
||||
if(~synths[num] != nil, { // To be absolutely safe
|
||||
// To be absolutely safe
|
||||
if(~synths[num] != nil, {
|
||||
~synths[num].set(\gate, 0);
|
||||
~synths[num] = nil; // Remove the reference
|
||||
// Remove the reference
|
||||
~synths[num] = nil;
|
||||
});
|
||||
});
|
||||
)
|
||||
)
|
||||
|
||||
Synth(\pad)
|
||||
Reference in New Issue
Block a user