Issue with noteOff - multiple SynthDefs

Hi All - first post here and relatively new to SuperCollider. I’m running an ORCA patch into SuperCollider (3.11.2 on Raspberry Pi, using nVim frontend) and am having issues with notes sticking.

I’m pretty sure the culprit is either the channel 3 or 4 synth below, but I can’t seem to get it to work right. Strangely enough, the “sticky” notes are happening on channels 1 and 2, but only when using channels 3 or 4 alongside the others.

I’m noticing a specific error that reads FAILURE IN SERVER /n_set Node XXXX not found with XXXX being numbers like 1056, 1250 etc. etc.

Thanks for taking a look!

SuperCollider Patch:

// boot the server

s.boot;

// initialize MIDI

(
MIDIClient.init;
MIDIIn.connectAll;

MIDIdef.noteOn(\on, {
  arg vel, num, chan, src;
  [vel, num, chan].postln;
  ~note[num] = Synth.new(~inst[chan], [\freq, num.midicps, \amp, vel/255, \gate, 1]);
});

MIDIdef.noteOff(\off, {
  arg vel, num, chan, src;
  ~note[num].release;
});
)

// arrays

(
~note = Array.newClear(128); // one slot per note in array
~inst = Array.newClear(4); // four synth voices
)

// channel 1

(
SynthDef(\tri, {
  arg freq=440, amp=0.3, gate=1;
  var sig, env;
  sig = LFTri.ar(freq)!2;
  env = EnvGen.kr(Env.adsr, gate, doneAction:2);
  sig = sig * env * amp;
  Out.ar(0, sig);
}).add;
~inst.put(0, \tri); // store in array
)

// channel 2

(
SynthDef(\bass, {
  arg freq=440, amp=0.3, gate=1, slideTime=0.17, ffreq=1100, width=0.15, detune=1.005, preamp=4;
  var sig, env;
  env = Env.adsr(0.01,0.3,0.4,0.1);
  freq = Lag.kr(freq, slideTime);
  sig = Mix(VarSaw.ar([freq, freq * detune], 0, width, preamp)).distort;
  sig = sig * amp * EnvGen.kr(env, gate, doneAction:2);
  sig = LPF.ar(sig, ffreq);
  Out.ar(0, sig);
}).add;
~inst.put(1, \bass); // store in array
)

// channel 3

(
SynthDef(\noise, {
  arg freq=440, amp=0.3;
	var sig, env;
	env = Env.perc(0.02, 0.11).kr(doneAction:2);
	sig = Mix(LFPulse.ar(
		freq: freq * [1, 5/2],
		iphase: 0.0,
		width: 0.5,
    mul: amp));
	sig = sig * env ;
	Out.ar(0, sig);
}).add;
~inst.put(2, \noise); // store in array
)

// channel 4

(SynthDef(\smash, {
  arg freq=2000, amp=0.3, rq=3, decay=0.3;
  var sig = PinkNoise.ar(freq),
  env = EnvGen.kr(Env.perc(0.01, decay), doneAction:2);
  sig = BPF.ar(sig, freq, rq, env);
  Out.ar(0, sig);
}).add;
~inst.put(3, \smash); // store in array
)

ORCA Patch

.........................................................................................................
.........................................................................................................
.........................................................................................................
........U9...............................................................................................
.........:04d............................................................................................
.........................................................................................................
........U7...............................................................................................
.........:04F............................................................................................
.........................................................................................................
........U5...............................................................................................
.........:04a............................................................................................
.........................................................................................................
........U6...............................................................................................
.........:05D............................................................................................
.........................................................................................................
.........................................................................................................
........U................................................................................................
.........:13d.7.....C9...................................................................................
..................U154TCaFd..............................................................................
..................*:06a78................................................................................
.........C9..............................................................................................
........U53T123..........................................................................................
.........:33d............................................................................................
.........................................................................................................
.........................................................................................................

If you are receiving on 4 channels, then you need to track note numbers 0…127 for each channel independently.

What happens now if you get channel 1 noteon 60 and then channel 2 noteon 60? The node for channel 1 is forgotten, because your data structure doesn’t model the channels.

~note = Array.fill(4, { Array.newClear(128) });

And then use ~note[channel][note] throughout.

The channel 3 and 4 synths don’t have a gate, so you don’t have to (i.e. shouldn’t) send note-off to the server for them.

hjh

Thank you so much! Worked perfectly!