And as a more general point - control rate saves a little bit of CPU because control rate signals have a lower sample rate. If your audio sample rate is S
and your blocksize is 64, then the sample rate for control signals will be S\64
.
The way this is handled in SuperCollider depends on the UGen. In the control rate UGen itself, it will generate a new sample at the beginning of every audio block (which by default is 64 samples long). This sample will remain the same for the entirety of that block.
When an audio rate UGen receives a control rate sample on one of its inputs it will convert it to an audio rate signal. To do this it will do one of the following:
For continuous signals (e.g. freq on a SinOsc
)
- If the new sample (which remember lasts for a whole block) is the same as the last sample it wonāt do anything.
- If the new sample is different, then it will create a linear ramp over the length of the audio block where at the start of the block the sample value is the last value, and at the end of the block itās the new value. This is called interpolation.
Iām not sure what happens when you feed a control rate into an audio rate Ugen that takes a gate (I know what I think should happen, but that may not be the same thing of course).
Important Note - No such conversion happens when you feed a control rate signal into a control rate UGen (e.g. if you feed the Impulse.kr into an EnvGen.kr).
So in the case of Impulse.kr(0)
- this will generate a 1 at the beginning of the first control block. Youāll get:
- Block One - 64 samples of 1
- Block Two - 64 samples of 0.
If you feed this into an EnvGen.kr
you will get the expected result. The envelope will start at sample 1. Everything will work the way that you expect it to.
There are situations where you need values to be sample accurate, rather than block rate (FM synthesis is a good example). In these cases you should use audio rate signals, and avoid issues with conversion from control rate signals.
All of this incidentally has nothing to do with SuperCollider, itās just inherent to digital audio. SuperCollider handles the relationship between control rates and audio rate about as well as it can be handled (given that control rate signals have literally 1/64th of the information that an audio rate signal does). The reason that control rate signals use less CPU is because they contain less information (the CPU is generating 1 sample every 64 samples, rather than 64). Youāre making a tradeoff between accuracy and CPU power. Most of the time that tradeoff makes sense because you canāt hear it - when you can hear it, you should use audio rate signals instead.