Multichannel bus control as UGen

I want to use individual channels of a multichannel bus as a kr UGen.
~sl = Bus.control(s,8);
and then basically have something like

MIDIFunc.cc({arg val;~slider[1].value = val.linexp(0.0,127.0,0.001,1.0);}, 77);
~slider[1].kr

But it throws and error. Any suggestions?

You’ll need to use the .set (to assign all channels as an array) or .setn methods to write values to the control bus, and then .getnSynchronous to read the current values of the control bus.

b = Bus.control(s, 4);
b.setn([100, 200, 300, 400];) // set all channels simultaneously
b.setAt(0, 150); // set only channel 0
b.getnSynchronous // returns [ 150.0, 200.0, 300.0, 400.0 ]
b.getnSynchronous[1] // returns 200.0

Best, Lawton

Thanks Lawton for your reply.
I wont be able to use the bus as .kr to control SynthDefs, for example. My idea is to steam the data from the MidiFunc continuously.

MIDI isn’t continuous. You get incoming atomic messages. When the controller isn’t moving, there are no messages.

Setting a control bus in response to MIDI CC messages works very well and makes sense.

hjh