Overview
Symphonia provides a comprehensive PCM decoder supporting a wide range of uncompressed audio formats including raw PCM (signed/unsigned integers and floating-point) and log-PCM codecs (A-law and μ-law).Feature Flag
To enable PCM support, add thepcm feature to your Cargo.toml:
Status
Status: Excellent- Decoding: Fully supported for all variants
- Gapless Playback: Yes (inherent to PCM)
- Performance: Minimal overhead
Decoder
The PCM decoder is implemented by thePcmDecoder struct:
Supported Formats
Signed Integer PCM
| Format | Codec Type | Bit Depth | Endianness |
|---|---|---|---|
| S8 | CODEC_TYPE_PCM_S8 | 8-bit | N/A |
| S16LE | CODEC_TYPE_PCM_S16LE | 16-bit | Little |
| S16BE | CODEC_TYPE_PCM_S16BE | 16-bit | Big |
| S24LE | CODEC_TYPE_PCM_S24LE | 24-bit | Little |
| S24BE | CODEC_TYPE_PCM_S24BE | 24-bit | Big |
| S32LE | CODEC_TYPE_PCM_S32LE | 32-bit | Little |
| S32BE | CODEC_TYPE_PCM_S32BE | 32-bit | Big |
Unsigned Integer PCM
| Format | Codec Type | Bit Depth | Endianness |
|---|---|---|---|
| U8 | CODEC_TYPE_PCM_U8 | 8-bit | N/A |
| U16LE | CODEC_TYPE_PCM_U16LE | 16-bit | Little |
| U16BE | CODEC_TYPE_PCM_U16BE | 16-bit | Big |
| U24LE | CODEC_TYPE_PCM_U24LE | 24-bit | Little |
| U24BE | CODEC_TYPE_PCM_U24BE | 24-bit | Big |
| U32LE | CODEC_TYPE_PCM_U32LE | 32-bit | Little |
| U32BE | CODEC_TYPE_PCM_U32BE | 32-bit | Big |
Floating-Point PCM
| Format | Codec Type | Precision | Endianness |
|---|---|---|---|
| F32LE | CODEC_TYPE_PCM_F32LE | 32-bit | Little |
| F32BE | CODEC_TYPE_PCM_F32BE | 32-bit | Big |
| F64LE | CODEC_TYPE_PCM_F64LE | 64-bit | Little |
| F64BE | CODEC_TYPE_PCM_F64BE | 64-bit | Big |
Log-PCM (Companded)
| Format | Codec Type | Description |
|---|---|---|
| A-law | CODEC_TYPE_PCM_ALAW | ITU-T G.711 A-law |
| μ-law | CODEC_TYPE_PCM_MULAW | ITU-T G.711 μ-law |
Codec Types
Container Support
PCM is commonly used in:- WAV (RIFF WAVE)
- AIFF (Audio Interchange File Format)
- CAF (Core Audio Format)
- Raw audio files
Codec Parameters
PCM decoding requires specific parameters:Bit Depth Handling
PCM supports variable bit depths within a format:Sample Rates
Supports all sample rates, common ones include:- 8 kHz (telephony)
- 11.025 kHz, 22.05 kHz, 44.1 kHz (CD quality)
- 16 kHz, 32 kHz, 48 kHz, 96 kHz, 192 kHz
- 88.2 kHz, 176.4 kHz (high-resolution)
Channel Support
Supports any channel configuration from mono to many channels.Usage Example
Working with Different Sample Formats
A-law and μ-law Decoding
Log-PCM formats are automatically converted to linear PCM:A-law
Used primarily in European telephony:- Better signal-to-noise ratio for low amplitude signals
- Dynamic range: ~13-bit equivalent
μ-law
Used primarily in North American and Japanese telephony:- Slightly different companding curve
- Dynamic range: ~13-bit equivalent
Performance
- Pure Rust implementation with no unsafe code
- Minimal overhead: Direct memory copies for most formats
- Zero-copy where possible
- Efficient bit-packing handling for 24-bit formats
- Optimized transfer functions for A-law and μ-law
Sample Format Conversion
Use Symphonia’s conversion utilities to convert between sample formats:Limitations
- Planar PCM formats are not yet supported
- No encoding support (decode-only)
Common Use Cases
CD Audio (CDDA)
Professional Audio
Telephony
High-Resolution Audio
Documentation
- crates.io
- API Documentation
- ITU-T G.711 (A-law and μ-law)