Supercollider Engine FAILURE IN SERVER Error

I’m seeing SuperCollider errors and no sound from my script/engine.
Error (2 for every note_on/note_off) is:

FAILURE IN SERVER /n_set Node 1013 not found

Initially I thought it was related to presets, and params:bang(), but having commented out those lines, I’m still getting the errors.

Can anyone stop any errors in my code (there may well be many - it’s a while since I did anything for Norns, and I’ve forgotten everything I learnt on my last attempt)?

Here’s the Lua script:

--
-- bline
-- A bare-minimum bassline
-- v 0.0.1 @toneburst

local ControlSpec = require 'controlspec'

engine.name = "Bline"

function init()
    ------------------
    -- Setup Params --
    ------------------

    params:add_group("Bline", 7)

    params:add_control("waveform", "waveform", ControlSpec.new(0, 127, 'lin', 0.1, 127))
    params:set_action( "waveform", function(x) engine.waveform(x); end)

    params:add_control("cutoff", "cutoff", ControlSpec.new(0, 127, 'lin', 0.01, 64))
    params:set_action( "cutoff", function(x) engine.cutoff(x); end)

    params:add_control("resonance", "resonance", ControlSpec.new(0, 127, 'lin', 0.1, 80))
    params:set_action( "resonance", function(x) engine.resonance(x); end)

    params:add_control("filter_overdrive", "filter overdrive", ControlSpec.new(0, 127, 'lin', 0.1, 0))
    params:set_action( "filter_overdrive", function(x) engine.filter_overdrive(x); end)

    params:add_control("envelope", "envelope", ControlSpec.new(0, 127, 'lin', 0.1, 100))
    params:set_action( "envelope", function(x) engine.envelope(x); end)

    params:add_control("decay", "decay", ControlSpec.new(0, 127, 'lin', 0.1, 100))
    params:set_action( "decay", function(x) engine.decay(x); end)

    params:add_control("accent", "accent", ControlSpec.new(0, 127, 'lin', 0.1, 100))
    params:set_action( "accent", function(x) engine.accent(x); end)

    -- Read params from disk if file present at 'data/<scriptname>/<scriptname>.pset'
    --params:read()
    --params:bang()

    ----------------
    -- Setup MIDI --
    ----------------

    local mo = midi.connect() -- defaults to port 1 (which is set in SYSTEM > DEVICES)

    mo.event = function(data)

        -- MIDI note
        d = midi.to_msg(data)

        if d.type == "note_on" then
            engine.note_on(d.note, d.vel)
        end -- end midi note on

        if d.type == "note_off" then
            engine.note_off(d.note)
        end -- end midi note on

    end -- end midi event

end -- end init

And the engine:

// CroneEngine_Bline
// Crappy 303
Engine_Bline : CroneEngine {

	var pg;

	//////////////////////////
	// Default Param Values //
	//////////////////////////

	var waveform = 1;
	var cutoff = 250;
	var resonance = 0.5;
	var filterDist = 0.0;
	var decay = 2.5;
	var mod = 2;
	var accent = 0.75;
	var slideTime = 0.2;
	var accentDecay = 0.2;
	var accThreshold = 0.9;
	var dist = 0;
	var amp = 0.5;

	// Active notes array
	var activeFreqs;

	var bline;

	*new { arg context, doneCallback;
		^super.new(context, doneCallback);
	}

	alloc {

		pg = ParGroup.tail(context.xg);

		activeFreqs = Array.new(10);

        //////////////////
        // Define Synth //
        //////////////////

		SynthDef(\bline, { |out = 0,
			amp = 0.5, pan = 0,
			gate = 0, velocity = 0,
			freq = 440, freqLagTime = 0, freqLagCurve = -2, detune = 0,
			waveform = 0, subLvl = 0,
			ffreq = 250, ffreqMod = 2, ffreqDcy = 20, fRes = 0.75, fDist = 0,
			ampAtk = 0.001, ampRel = 0.1,
			accent = 0.75, accThreshold = 0.9, accAmp = 1.1, accFfreqMod = 1.0, accDcy = 0.2,
			dist = 0|

			// Declare vars
			var sig, freqLagged, accentSwitch, ampEnv, vcfEnv, cutoffModAmt, finalCutoff, finalAmp;

			// Osc freq, with linear lag on legato notes
			freqLagged = VarLag.kr(freq, freqLagTime, freqLagCurve);
			//freqLagged = [freqLagged, freqLagged + (freqLagged * detune)];

			// Oscillator mix pulse > saw
			sig = XFade2.ar(Mix.new(PulseDPW.ar(freqLagged)), Mix.new(SawDPW.ar(freqLagged)), LinLin.ar(waveform, 0.0, 1.0, -1.0, 1.0));

			// Accent switch
			accentSwitch = Select.kr(velocity > accThreshold, [0, 1]);

			// Amp envelope
			ampEnv = EnvGen.kr(
				Env.asr(
					attackTime: ampAtk,
					sustainLevel: 1.0,
					releaseTime: ampRel,
					curve: -4.0
			), gate, doneAction: 0);

			// Filter/Amp accent envelope
			vcfEnv = EnvGen.kr(
				Env.perc(
					attackTime: ampAtk,
					releaseTime: Select.kr(accentSwitch, [ffreqDcy, accDcy]),
					level: 1.0,
					curve: -4.0
				), gate, doneAction: 0);

			// Calculate filter cutoff env mod unaccented/accented
			cutoffModAmt = ffreqMod + ((accFfreqMod * accent) * accentSwitch);

			// Calculate final filter cutoff
			finalCutoff = ffreq + (ffreq * (vcfEnv * cutoffModAmt));
			finalCutoff = finalCutoff.clip(50, 5000);

			// Amp unaccented/accented (add VCF envelope to AMP env)
			finalAmp = (ampEnv + ((vcfEnv * accAmp) * accentSwitch)) * amp;

			// Filter oscillator
			sig = RLPFD.ar(sig, finalCutoff, fRes, fDist, mul:3.0);

			// Distortion
			sig = (sig * linlin(dist, 0, 1, 1, 30)).distort * XFade2.kr(1, 0.2, dist);

			// Output
			Out.ar(out, Pan2.ar(sig, pan, finalAmp));
		}).add;

		// Set initial params (may not be needed (use Norns param default values?))
		bline = Synth(\bline, [\out,0, \amp,amp, \waveform,waveform, \ffreq,cutoff, \ffreqDcy,decay, \ffreqMod,mod, \accent,accent, \accDcy,accentDecay, \accThreshold,accThreshold, \freqLagTime,slideTime, \dist,dist], target:pg);

        /////////////////////
        // Control Interface //
        /////////////////////

		this.addCommand("note_on", "ii", { arg msg;
			var freq = msg[1].midicps;
			if(activeFreqs.isEmpty) {
				// Non-Legato note
				bline.set(\gate, 1, \velocity, msg[2]/127, \freqLagTime, 0);
			} {
				// Legato note
				bline.set(\freqLagTime, slideTime);
			};
			bline.set(\freq, freq);
			activeFreqs = activeFreqs.add(freq);
		});

		this.addCommand("note_off", "i", { arg msg;
			var freq = msg[1].midicps;
			activeFreqs.remove(freq);
			if(activeFreqs.isEmpty) {
				// Non-legato release
				bline.set(\freq, freq, \gate, 0);
			} {
				// Legato release
				bline.set(\freq, activeFreqs.last);
			};
		});

		this.addCommand("waveform", "f", { arg msg;
			waveform = msg[1].linlin(0, 127, 0, 1);
			bline.set(\ffreq, cutoff);
		});

		this.addCommand("cutoff", "f", { arg msg;
			cutoff = msg[1].linlin(0, 127, 80, 2000);
			bline.set(\ffreq, cutoff);
		});

		this.addCommand("resonance", "f", { arg msg;
			resonance = msg[1].linlin(0, 127, 0, 0.8);
			bline.set(\fRes, resonance);
		});

		this.addCommand("filter_overdrive", "f", { arg msg;
			filterDist = msg[1].linlin(0, 127, 0, 1);
			bline.set(\fDist, filterDist);
		});

		this.addCommand("envelope", "f", { arg msg;
			mod = msg[1].linlin(0, 127, 0.1, 2);
			bline.set(\ffreqMod, mod);
		});

		this.addCommand("decay", "f", { arg msg;
			decay = msg[1].linexp(0, 127, accentDecay, 4);
			bline.set(\ffreqDcy, decay);
		});

		this.addCommand("accent", "f", { arg msg;
			accent = msg[1].linlin(0, 127, 0, 1);
			bline.set(\accent, accent);
		});

		this.addCommand("distortion", "f", { arg msg;
			dist = msg[1].linlin(0, 127, 0, 1);
			bline.set(\dist, dist);
		});

	} // end alloc

	free {
		bline.free;
	}

} // end class

add Server.default.sync after defining the synthdef and before constructing the synth

Hi @zebra your original message was more fun :wink:

I didn’t spot that line in any of the engine scripts I looked at.

Thanks very much, once again!