How Ecasound Handles Integer Bit Depths

This article provides an overview of how the Ecasound command-line digital audio workstation handles integer sample bit depths, specifically 16-bit, 24-bit, and 32-bit formats. It explores Ecasound's internal processing pipeline, the conversion mechanisms used when reading and writing integer streams, format configuration syntax, and important considerations regarding quantization and clipping.

Internal Floating-Point Architecture

Regardless of the input or output format, Ecasound does not process audio using integer arithmetic. Internally, Ecasound converts all incoming audio streams into single-precision 32-bit floating-point samples (represented as the sample_t type). This internal pipeline ensures that mixing, level adjustments, filtering, and effects processing maintain high precision and avoid the dynamic range limitations, truncation noise, and headroom issues associated with fixed-point integer calculations.

Ingestion: Converting Integers to Floats

When an audio source with an integer format is ingested—whether from a file, an ALSA/JACK device, or standard input—Ecasound unpacks the integer data and normalizes it to a normalized floating-point range of [-1.0, 1.0]:

Format Specification Syntax

Ecasound uses the -f flag to define format parameters for inputs and outputs that do not contain explicit header information (such as raw PCM streams, soundcard devices, or headerless files). The syntax follows this order:

-f:sample_format,channels,sample_rate,interleaving

Common integer format identifiers include:

For standard container formats like WAV or AIFF, Ecasound reads the bit depth directly from the file header, converting the designated integer type to floating-point automatically upon import.

Output: Quantization and Clamping

When routing internal audio to an integer output target (such as writing a 16-bit or 24-bit WAV file, or sending a stream to a hardware soundcard), Ecasound performs the reverse conversion:

  1. Clamping: Because floating-point operations can exceed +1.0 or -1.0 during mixing or amplification, the audio engine clips any values outside this boundary before converting to integer formats. If internal signals peak above 0 dBFS, digital clipping will occur in the integer output.
  2. Quantization: The float values within [-1.0, 1.0] are multiplied back into the integer range of the target bit depth and rounded. For example, rendering to 16-bit integer multiplies the float values by 32,767.0 and casts them to signed 16-bit integers.
  3. Dithering Considerations: Ecasound focuses primarily on fast, real-time routing and processing. Direct sample-format downsampling (such as converting internal floats to 16-bit outputs) relies on standard truncation and rounding unless explicitly routed through a dedicated dithering plugin or external processor. For high-resolution mastering, processing at 24-bit or 32-bit float output preserves resolution and minimizes quantization distortion.