Function problem "WARNING: Synth output should be a flat array"

I am having problems with this function:

~f = {arg f1Freq=0.1,nFreq=440, m1Ratio=1,amp=0.1, dur=55, ampM=0.84 , pan=0;var sig, car1, mod1, env, index;index = LFNoise1.kr(0.2).range(2, 12);env = EnvGen.kr(Env.new([0, 0.70, 0.70, 0], [dur*0.333, dur*0.333, dur*0.333]), doneAction:2);mod1 = SinOsc.ar([nFreq * m1Ratio, nFreq+0.7 * m1Ratio], mul:nFreq * m1Ratio * index) * ampM;
car1 = SinOsc.ar(f1Freq + mod1); sig = car1* env * amp;sig = Pan2.ar(sig, pan);}

Maybe I’m getting myself into a problem that is at the moment beyond my means. The function when I pass it to the server returns:

WARNING: Synth output should be a flat array.
[ [ an OutputProxy, an OutputProxy ], [ an OutputProxy, an OutputProxy ] ]
Flattened to: [ an OutputProxy, an OutputProxy, an OutputProxy, an OutputProxy ]
See NodeProxy helpfile:routing


NodeProxy.audio(localhost, 2): wrapped channels from 4 to 2 channels
-> a Function

Is there a way to fix this problem?
Thank you

An array of ugens represents multichannel audio…

[left, right, back_left, back_right...upstairsBehindTheCupboard]

As they correspond to sequential outputs on you audio device.

But nested arrays have no physical meaning.

You probably just need to call .sum. Could you format the codes so it’s readable and I’ll have a look in detail?

the code would be:

( ~f.play; ~f.awake_(falso); ~f = {arg f1Freq=0.1,nFreq=440, m1Ratio=1,amp=0.1, dur=55, ampM=0.84 , pan=0;var sig, car1, mod1, env, index;index = LFNoise1.kr(0.2).range(2, 12);env = EnvGen.kr(Env.new([0, 0.70, 0, 0], [dur*0.333, dur*0.333, dur*0.333]), doneAction:2);mod1 = SinOsc.ar([nFreq * m1Ratio, nFreq+0.7 * m1Ratio], mul:nFreq * m1Ratio * index) * ampM; car1 = SinOsc.ar(f1Freq + mod1); sig = car1* env * amp;sig = Pan2.ar(sig, pan);} )
~seq = Tdef(\seq, {
	 ~f.spawn([..........]); 
          x.yield;
           ~f.spawn([.......]); 
           x.yield;
          ~f.spawn([.......]); 
           x.yield;
 }) 

First thing is, ~f being written in one long line, which you have to scroll to read in the forum – this is going to discourage people from getting involved.

Second, the error probably has a lot to do with the ..... bits that you omitted. Still a lot of missing information.

Jordan is asking you to post the full synth function and arguments.

hjh

Forgive me for the incorrect way of expressing myself. Let me explain the context. I’m preparing a set for live coding with some preset configurations. I have three documents in a setup folder: Setup.scd, snippets.scd and synhtdefs.scd. It’s an approach from theseanco (S Cotterill) · GitHub that I liked a lot to start with. I’m creating my own synths and snippets to add to the documents
synthdef.scd and snippets.scd to suit my taste and needs. As I said before I have problems to manage the audios in the ProxySpace environment, on the one hand, on the other hand this function has no more code than the one I published in my last post. This function is part of a synthdef that I found out there to make a drone sound that included two instances of car and mod that I excluded to simplify the function and because I wanted to start with a simpler texture. So, the code and the bug that the code returns is as follows:


(“Setup/Setup.scd”).loadRelative;

(
~mix.ar;
(
~verb = {
XFade2.ar(
LPF.ar(
GVerb.ar(
~mix.ar(1), 80,8, maxroomsize:1000),
8500
),
~mix, \pan.kr(0,0.5),\rel.kr(0.15)
)
};
~verb.play;
)
)

(
~f.play; ~f.awake_(false);
~f = {arg f1Freq=0.1,nFreq=440, m1Ratio=1,amp=0.1, dur=55, ampM=0.84 , pan=0;var sig, car1, mod1, env, index;index = LFNoise1.kr(0.2).range(2, 12);env = EnvGen.kr(Env.new([0, 0.70, 0.70, 0], [dur0.333, dur0.333, dur0.333]), doneAction:2);mod1 = SinOsc.ar([nFreq * m1Ratio, nFreq+0.7 * m1Ratio], mul:nFreq * m1Ratio * index) * ampM;
car1 = SinOsc.ar(f1Freq + mod1); sig = car1
env * amp;sig = Pan2.ar(sig, pan);}
)

~seq = Tdef(\seq, {
~f.spawn()
})

y me devuelve:


→ NodeProxy.audio(localhost, 2)
WARNING: Synth output should be a flat array.
[ [ an OutputProxy, an OutputProxy ], [ an OutputProxy, an OutputProxy ] ]
Flattened to: [ an OutputProxy, an OutputProxy, an OutputProxy, an OutputProxy ]
See NodeProxy helpfile:routing

NodeProxy.audio(localhost, 2): wrapped channels from 4 to 2 channels
→ a Function

Un saludo!!

Instead of fixing your code, I’ll try to show you via a quick example what the problem is.

Ndef(\flat, {
	var sig = SinOsc.ar(200.0)!4;
	sig.shape.postln;
	sig;
});

will return

-> [ 4 ]
-> Ndef('flat')

so it will output 4 consecutive channels.

If we do the following instead

Ndef(\nested, {
	var sig = SinOsc.ar(200.0);
	sig = [sig!2, sig!2];
	sig.shape.postln;
	sig;
});

the output is

[ 2, 2 ]
WARNING: Synth output should be a flat array.
[ [ a SinOsc, a SinOsc ], [ a SinOsc, a SinOsc ] ]
Flattened to: [ a SinOsc, a SinOsc, a SinOsc, a SinOsc ]
See NodeProxy helpfile:routing


-> Ndef('nested')

so 2 nested arrays with each 2 channels - threfore the output is nested and not flat, so it may not be clear how the channel mapping should be applied. SuperCollider informs you that .flat has been applied to the output array as an implicit fix, but it may not be what you want.

Hope this helps you to restructure your code accordingly :slight_smile:

edit: A hint - I haven’t checked your whole code, but you are using GVerb, which expects a mono signal as its input - you should verify it is mono or apply sum on it. If you insert a multi-channel array into it, it will create nested arrays instead of flat arrays, i.e. GVerb converts a mono signal into a stereo signal, so a stereo signal would be converted to 2 x stereo signal, which is a nested array instead of a flat one.

Another recommended document is Multichannel Expansion | SuperCollider 3.13.0 Help , especially the section Pitfalls

1 Like