Digital volume controls
'Digital volume control' can refer to several different technologies, ranging from digitally controlling analog volume to software-based volume control for digital audio. With digital volume control of analog audio, discrete gain steps or attenuation steps (volume-up or volume-down, respectively) are applied to the analog audio signal. With digital volume control of digital audio, software-based math functions are used to calculate the appropriate change in volume.
Digital Volume Control of Analog Audio
More information will be added on this subject. Check back soon.
Digital Volume Control of Digital Audio
To apply gain or attenuation to a digital audio signal, a multiplication is performed on each digital sample that collectively create the digital audio signal. The reason this works is because digital samples are actually just numbers - binary numbers - that represent the amplitude of the original analog audio signal at that particular point in time (with a value range 000000000000000000000000 - 111111111111111111111111 for 24-bit; that is equal to 0 - 16,777,216 in decimal). (Read more about how digital audio works).
After the multiplication of a sample is performed, the new value of the sample is a scaled representation of the corresponding original sample. This same multiplication is done to each consecutive sample of the digital audio signal, consequently affecting the amplitude of the signal as a whole. For example, if the user slides the volume control down, the program multiplies each sample by some fraction, and the resulting collection of samples represent a digital audio signal with an amplitude of lesser magnitude then the original signal, resulting in a lower volume.
Distortion resulting from software-based digital volume controls
Disasterous distortion can potentially arise when a digital volume control is implemented. This is because digital samples have a discrete number of digits that can be used to represent its value (read more about word-length; also known as bit-depth). Binary numbers, just like decimal numbers, do not always multiply and divide evenly. There are often remainders - extra digits that are a result of the multiplication.
EXAMPLE (decimal numbers are used for simplicity): When multipling 21 by 0.5 (equation: 21 * 0.5), the result is 10.5. The result (10.5) requires three digits to represent it, where as the two multiples (21 and 0.5) only had two digits.
In digital (discrete) systems, there is a limited amount of digits you can use to represent the sample. This limit introduces errors in accuracy (distortion) when dealing with remainders. In our example above, if we were working in a 2-digit system, the result could only be represented with two digits. We would have to choose to round-down to 10, or round-up to 11, neither of which are accurate (~5% error or distortion).
When the digital volume control is set to 100% (or 0.0dB, or Unity Gain, depending on nomenclature), no multiplication is performed, and this distortion is not present.
* There is a way to compensate for this distortion to minimize its effects. It requires dithering, a technique which helps the new samples more accurately estimate the audio qualities of the original samples.