Blog
Techtalk: Dealing with 24bit audio
When CDs were introduced, they supported a sample rate of 44,100 samples per second with 16-bit resolution. At the time, this was considered sufficient for high-quality music reproduction. The 16-bit audio format allows for a dynamic range of 96 dB—a substantial range. In most home environments, experiencing the full 96 dB dynamic range is unlikely unless you live in a remote area or have a soundproof studio.
Today, however, audio recording and playback often use 24-bit formats, and in some cases, even 32-bit. Why?
Advantages of Higher Bit Depth
1. Improved Performance of Modern DACs and ADCs
Modern Digital-to-Analog Converters (DACs) and Analog-to-Digital Converters (ADCs) often have dynamic ranges between 110 and 120 dB, with some manufacturers claiming up to 130 dB. These capabilities exceed the limits of 16-bit formats, which cannot represent such a wide dynamic range effectively.
2. Digital Volume Control
While analog volume knobs were standard in traditional audio systems, many modern setups use digital volume control. In digital systems, lowering the volume reduces the effective bit depth, decreasing the dynamic range. Extra bits in a 24-bit or 32-bit format help retain quality even when volume adjustments are made digitally.
3. Audio Processing in Recording
Recording workflows often involve various processes, such as applying effects, adjusting volumes, or mixing signals. Each operation can degrade the original signal slightly. Using a higher bit depth provides a buffer or “reserve bits” to preserve audio quality across multiple processing stages. This is why recording at 24-bit is standard in professional environments.
Handling 24-bit Audio on Modern Systems
Let’s say you’re using a device like the DAC2 ADC Pro to record 24-bit audio at a sample rate of 44,100 Hz. Intuitively, you might expect to read 3 bytes (24 bits) of audio data per sample. However, modern computers are optimized for 32-bit or 64-bit operations. To accommodate this, a technique called “padding” is used.
Padding fills the unused bits with zeros, allowing the system to process 32 bits (or more) at a time while still storing only 24 bits of meaningful audio data. This approach simplifies computations without requiring the computer to handle non-aligned data sizes explicitly.
Sample Formats for 24-bit Audio
Three common sample formats are used for storing 24-bit audio data:
- S24_LE (24-bit Little Endian): The 24 bits of audio data are stored in the least significant bytes, with padding in the most significant byte.
- S32_LE (32-bit Little Endian): The 24 bits of audio data are stored in the least significant bytes, with padding in the least significant byte.
- S24_3LE (Packed 24-bit Little Endian): Only the 24 bits of audio data are stored, with no padding. This format uses exactly 3 bytes per sample.
Choosing the Right Format
While all three formats store the same 24 bits of “real” audio data, the padding differs. The choice of format depends on your requirements:
- S24_LE: This format assumes that the most significant byte is always zero. It’s less commonly used for modern applications.
- S32_LE: This format does not assume that the least significant byte is zero, making it more flexible and reliable for processing. It’s the default choice for many modern systems, including the Raspberry Pi, and is often used internally by audio software for processing 24-bit or higher audio data.
- S24_3LE: This format avoids padding altogether but is less compatible with many tools and systems. It’s generally not recommended due to potential compatibility issues.
Recommendations
For most use cases, S32_LE is the best format to work with for 24-bit audio. It’s widely supported, aligns well with modern hardware capabilities, and ensures consistent performance during processing. If you need to convert to another format for specific purposes, use tools like sox as the final step after completing all audio processing.
January 3, 2025