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:
- Representation:
sfor signed integer,ufor unsigned integer, orffor floating-point. - Bit Depth: The numerical bit-width of each sample
(e.g.,
8,16,24,32). - Endianness:
_lefor little-endian or_befor big-endian.
Commonly used bit-depth strings include:
- 16-bit Integer:
s16_le(signed 16-bit little-endian) ors16_be(big-endian). - 24-bit Integer:
s24_le(signed 24-bit little-endian, packed or padded depending on the audio subsystem). - 32-bit Integer:
s32_le(signed 32-bit little-endian). - 32-bit Floating-Point:
f32_le(single-precision float). - 8-bit Integer:
u8(unsigned 8-bit) ors8(signed 8-bit).
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.wavTo 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.wavIn 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.