Ndef and Group have the same nodeID

I’m trying to add a “CmdPeriod” action that will recreate the groups I need and start a Ndef acting as a mixer. And I get a duplicated nodeID error between my Ndef and the first created group.

I made the following mcve (where the the mixer is a bare sin wave for the sake of the test):

// initial definition
(
// Ndef(\sound).prime({ SinOsc.ar([600, 635], 0, SinOsc.kr(2).max(0) * 0.2) });
// ~grpMic=~grpMic??{Group.basicNew(s,Ndef(\sound).nodeID+1)};
~grpMic=~grpMic??{Group.basicNew(s)};
~grpMix=~grpMix??{Group.basicNew(s)};

~makeDefaultNodes={ |server|
	"Pushing groups to the server".postln;
	server.sendBundle(nil, ~grpMic.newMsg(nil,\addToHead));
	server.sendBundle(nil, ~grpMix.newMsg(~grpMic,\addAfter));
	// s.sync;
	"Pushing the Mixer to the server".postln;
	Ndef(\sound, { SinOsc.ar([600, 635], 0, SinOsc.kr(2).max(0) * 0.2) });
	Ndef(\sound).play(0,2,~grpMix);
}
)
\\ start server
(
s.waitForBoot({

	ServerTree.removeAll;
	s.sync;
	ServerTree.add(~makeDefaultNodes,s);

	// Server.freeAll; // stops everything and triggers the ServerTree actions
	CmdPeriod.run;
});
)

At the CmdPeriod action I’ve got the following error:

FAILURE IN SERVER /s_new duplicate node ID

because both the Ndef(\sound) and ~grpMic are receiving the ID “1000”.

I couldn’t find any solution to achieve this without this duplicate error.

Any idea ?


Rem: this ~grpMix=Group.basicNew(s); server.sendBundle(nil, ~grpMic.newMsg(nil,\addToHead)); approach come from this post.

code runs fine over here !

Well… I’m no so lucky.
When I start SC, a first run of this code gives that error.
At the level of the nodes that are created, the Ndef is indeed missing.
After all the next CmdPeriod, no more error. The Ndef is created with a next ID.

Very first run after SC start, or Interpreter reboot:

with error FAILURE IN SERVER /s_new duplicate node ID

After every next CmdPeriod:

try starting the server before executing the first block

1 Like

I moved, as you suggested, the groups creation in the s.waitForBoot({... and it’s working fine now. Thanks.