Product SiteDocumentation Site

11.3.11.4.3. Special Note about Control-Rate Busses
Control-rate Bus'ses are a great way to enhance the flexibility of your program. The best part is that, in order to use a control-rate Bus, the UGen doesn't even need to have been written to accomodate it.
{ SinOsc.ar( freq:In.kr( controlRateBus, 1 ), mul:0.2 ); }.play;
Now you've managed to spice up an otherwise-boring synth!
Also, control-rate Bus'ses don't need to be constantly changing. Unlike an audio-rate Bus, a control-rate Bus will hold the last-inputted value until another value is provided. You can the value of a control-rate Bus with the set message (and a single argument, which is the value). You can also get the current value, whether created by set or a UGen, by using the get message, and sending a Function with one argument.
(
   var bus = Bus.control( s );
   bus.set( 12 );
   bus.get( { arg val; val.postln; } );
   bus.free; bus = nil;
)
When running this example, you'll notice that the 12 doesn't get posted until after the program finishes with nil. This is because of the latency between when the interpreter asks the server to do something, and when the server does it. The amount of time it takes for the server to complete a command is usually very small, but as you can see, it can make an important difference to your program. This latency is also the reason that you can't call SynthDef.new( ... ) and Synth.new( ... ) at the exact same time.
This latency is also the reason that we have to provide a single-argument function as an argument to the get function. Since the function won't immediately be able to get the value of the bus from the server, we can't expect the value to be returned by the function. Instead, when "get" gets the value of the bus from the server, it runs the function that you gave it.