Setting Audio Bit Depth in Ecasound via CLI

This article provides a concise overview of how Ecasound configures audio bit depth through its command-line interface. It covers the syntax of the audio format flag, the specific naming conventions used for integer and floating-point bit depths, how placement order determines input and output parameters, and how the internal audio engine processes varying bit depths.

The Audio Format Option (-f)

Ecasound controls bit depth using the -f (format) command-line parameter. The argument accepts up to four comma-separated values specifying the sample format, channel count, sampling rate, and channel interleaving style:

-f:sample_format,channels,sample_rate,interleave

The first field, sample_format, dictates the bit depth and representation of the audio samples. If you only need to define or change the bit depth while leaving other parameters at their defaults or auto-detected values, you can provide the format and leave trailing fields empty, such as -f:s24_le.

Bit-Depth Format Specifiers

Ecasound identifies bit depth using standard ALSA/OSS-style sample format strings. The format descriptor typically combines three components:

  1. Representation: s for signed integer, u for unsigned integer, or f for floating-point.
  2. Bit Depth: The numerical bit-width of each sample (e.g., 8, 16, 24, 32).
  3. Endianness: _le for little-endian or _be for big-endian.

Commonly used bit-depth strings include:

Command-Line Placement and Scope

Ecasound parses options sequentially from left to right. When an -f flag is issued, it sets the active format for all subsequently defined audio inputs (-i) and outputs (-o) until another -f argument alters the configuration.

To read a file at its native format but output a specific bit depth:

ecasound -i input.wav -f:s16_le,2,44100 -o output_16bit.wav

To enforce distinct bit depths on both the input stream (such as a hardware sound card capture) and the output file:

ecasound -f:s32_le,2,96000 -i alsa,default -f:s24_le,2,96000 -o recording_24bit.wav

In this command, the capture device is read as 32-bit integer audio, and the resulting file is encoded down to 24-bit.

Internal Processing and Bit-Depth Conversion

Regardless of the bit depth chosen on the command line for inputs and outputs, Ecasound converts incoming audio samples to 32-bit or 64-bit floating-point internally for processing, effects, and mixing. When writing to an output target with a reduced bit depth (such as converting 24-bit input to 16-bit output), Ecasound handles the quantization conversion automatically during the output write stage.