FAILURE IN SERVER /n_set Node 1004 not found

Hi everyone, I am new in Supercollider.
I got a problem about FAILURE IN SERVER /n_set Node 1004 not found, maybe I’ve overlooked something stupid. Any way to solve this issue?

//Make sound between a frequency range
(y = {
	arg noiseKR = 8, no1KR = 12;
	var freq, amp, sig;
	// freq = LFNoise0.kr(8,400, 600);    or 
	freq = LFNoise0.kr(noiseKR).exprange(200,1000);
	amp = LFNoise1.kr(no1KR).exprange(0.02,1);
	// exprange: sound more distribution
	sig = SinOsc.ar(freq)*amp;
	//Make sound between 200-1000HZ
}.play;
)

y.set(\noiseHZ, exprand(4,64));
y.free;

Thanks!

Hello and welcome!

This code should work fine if you execute it in order, although you are setting a control (noiseHZ) that doesn’t exist in the synth (you only have noiseKR and no1KR), so it won’t have any effect.

I suspect that you ran y.free or Cmd-period before running y.set(\noiseHZ, exprand(4,64));. If you run y.set after y has already been freed, it will give you FAILURE IN SERVER /n_set Node 1004 not found.

If you executed the code in order and it’s still not working:

  1. Just to verify, after you execute the first code block, the synth should be playing on the server (you should hear it).
  2. Now, while the synth is playing, run y.set(\noiseKR, exprand(4,64));. You should hear the change. If you’re still getting the error message at this point, please report back.

Hey! Thanks for helping me.
No, I just set the noiseHZ control of noiseKR and no1KR in the beginning of the code.
After I changed the order of two lines that you mentioned, it still occurs the same error.

The first point you’ve talked about works well(has sound)
As for the second point, without executing the y.free;, it seems to work, but I am not quite sure, because the sound might have been covered by the previous code.

When I run your code in separate blocks like this:

  1. y = { ... }.play
  2. Then y.set(...)
  3. Then y.free

… then I get no error (as expected).

If I then go back to step 2 and try y.set again, then I do get the error.

This is also expected. free makes the synth node go away.

The confusion might be about the difference between the language and the server.

y.free changes the situation in the server, but it does not change the object y in the language.

y still contains a Synth, but this language-side object no longer corresponds to active audio-processing in the server.

So when you try to use this language-side object to control something on the server, you get an error, because there is nothing in the server.

After free-ing the synth, you have to make a new Synth before you can .set again.

hjh

Got it! Thanks.
Yes, I got no error when I run the separate blocks for the first time. So do I need to execute the first block, then second… , if I want to execute the blocks again?

BTW, Does the meaning of free similar to “stop”?

Sort of. It is similar to the term “stop” but not to the method.

x = {SinOsc.ar}; \\a function
x.play; \\440 Hz sine tone
x.stop; \\a function
x.free; \\stops the synth playing

You free a synth, but you stop a routine or task, which this is not.

You should make this into a SynthDef so you can reuse it more conveniently.

(
SynthDef(\mySynth, { //name it whatever you like in the first argument to the SynthDef class
	arg noiseKR = 8, no1KR = 12;
	var freq, amp, sig;
	// freq = LFNoise0.kr(8,400, 600);    or 
	freq = LFNoise0.kr(noiseKR).exprange(200,1000);
	amp = LFNoise1.kr(no1KR).exprange(0.02,1);
	// exprange: sound more distribution
	sig = SinOsc.ar(freq)*amp;
	
	Out.ar(0, sig);
	//Make sound between 200-1000HZ
}).add;
) \\now this is stored under whatever you named it

x = Synth(\mySynth);
x.free;
x=Synth(\mySynth, [\noiseKR, 10]);
x.set(\noiseKR, 2);

Oh, thanks mjsyts!! It works so well. Writing in a function is a good way to make the code clear!

In that context, free won’t release it.

Sorry to be fussy about it, but it’s such a common point of confusion for new users (about play returning a new “player” object), better to be clear about it up front.

x = {SinOsc.ar};  // a function

y = x.play;  // 440 Hz sine tone
y.stop;  // a Synth, but no effect
y.free;  // stops the synth playing

hjh

Got it! Thanks for help
So, the order of these three are always play->stop->free?

No, the point was that stop is not useful for Synths. So, forget about it.

Synth.findRespondingMethodFor(\stop);
-> Object:stop

And Object:stop looks like this:

	stop { ^this }

= do nothing.

free will always immediately cut off the synth. This may not be ideal – if the signal is not silent, you could get a click.

If the synth has a gate argument, then you can also release it. All { ... }.play synths already have this argument!

(
SynthDef(\noGate, { |out, freq = 440, amp = 0.1|
	Out.ar(out, (SinOsc.ar(freq) * amp).dup)
}).add;
)

y = Synth(\noGate);
y.release;  // no effect bc no 'gate'
y.free;  // could click

(
SynthDef(\gated, { |out, freq = 440, amp = 0.1, gate = 1|
	var eg = EnvGen.kr(Env.asr(0.01, 1, 0.02), gate, doneAction: 2);
	Out.ar(out, (SinOsc.ar(freq) * (amp * eg)).dup)
}).add;
)

y = Synth(\noGate);

y.release;  // yes!

y = { SinOsc.ar(440, 0, 0.1).dup }.play;

y.release;  // yes!

And, after free or release, don’t try to reuse the same Synth object.

hjh

1 Like