Retrieving the number of channels of a Bus within a SynthDef

Not in scsynth, but well in sclang. Hence the confusion.

-> Bus(audio, 246, 10, localhost)

From a post of mine of 2 years ago : ( I think I stumble more or less on the same limitation :person_facepalming: )

With your comments I rewrote my Synth like this:

SynthDef(\mixAll, { | out=0|
    var bus=\channels.kr(-1!40); // choose some max
    var amp=\amp.kr(0.8);
    var count=0;
    var sig;

    // count how many bus are filled-in
    bus.do{|v,i|
        count=count+Select.kr(bus[i]+1,[0,1]);
    };
    
    // then play with this
    Poll.kr(Impulse.kr(10),count,"count");
    amp=amp/count;
    Poll.kr(Impulse.kr(10),amp,"amp");

    sig= bus.collect{|v,i|
        Select.ar(bus[i]+1,[DC.ar(0),In.ar(bus[i])*amp]);
    };
    
    Out.ar(out,Mix.ar(sig));
}).add;