1
0

feat: load synthef on startup

This commit is contained in:
2025-06-14 16:41:54 +02:00
parent fddbf09d99
commit 6f90b4d1cf
26 changed files with 214 additions and 152 deletions

View File

@ -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)