Ndef with array source hanging server

NodeProxy accepts an array as 4th argument of its default constructor and will initialize the sources array to this, e.g.

~fa = [{ 0.5 * SinOsc.ar(777) !2}, {0.5 * SinOsc.ar(333) !2}]
x = NodeProxy(s, \audio, 2, ~fa).play
x[1] = nil // turn off just one

But Ndef seems to have an odd behavior when passed an array like that:

Ndef(\ah, ~fa).play

hangs the sever with 100% one-core CPU utilization. The server still can be manually force stopped though, i.e. crashed.

Why is that last line causing that live-lock behavior?

I did figure out that that is calling into the equivalent of NodeProxy.source (not the plural sources) and the singular method of NodeProxy goes haywire as well if passed an array:

~fa = [{ 0.5 * SinOsc.ar(777) !2}, {0.5 * SinOsc.ar(333) !2}]
NodeProxy(s, \audio, 2).source_(~fa) // server hang

But I haven’t traced the code paths any further. I’m not sure if this normal behavior or not.

A small clue: [function, function] isn’t recognized as a synthdef-generator.

Ndef(\ah).objects;
-> Order[ a StreamControl ]

// vs
Ndef(\bh, { SinOsc.ar(440) });
Ndef(\bh).objects;
-> Order[ a SynthDefControl ]

Edit: Educated guess, but it could cause the server to hang if it’s trying to translate the array into a Demand tree, where some element has zero size and is repeating infinitely. I haven’t come up with something else that would infloop in the server.

I guess a helper function might behave better. Perhaps this could be folded into JITLib eventually.

f = { |ndefKey, array, startIndex = 0|
	array.do { |item, i|
		Ndef(ndefKey).put(i + startIndex, item);
	};
	Ndef(ndefKey)
};

hjh