Ecasound -f Flag: Format, Channels, Sample Rate

The -f flag in Ecasound sets the audio stream parameters for inputs, outputs, and internal processing chains by defining the sample format, channel count, and sampling rate. It is critical when dealing with raw, headerless audio files or when converting between different formats in a signal chain. By using a strict, comma-separated syntax, the -f option tells Ecasound precisely how to interpret or encode binary audio data.

Syntax of the -f Flag

The -f argument accepts values in a structured, comma-separated string:

-f:sample_format,channels,sample_rate[,interleaving]

Each parameter must appear in this exact order. The fourth parameter (interleaving) is optional and defaults to standard interleaved audio.

Parameter Breakdown

1. Sample Format (sample_format)

The sample format defines the bit depth, numeric type, and endianness of each audio sample. Common format descriptors include:

Common examples:

2. Channel Count (channels)

This parameter defines the number of discrete audio channels as an integer:

3. Sample Rate (sample_rate)

The sample rate defines the sampling frequency measured in Hertz (Hz):

Scope and Positioning

In Ecasound, order of execution matters. The -f flag affects the objects that follow it or sets global defaults depending on its position:

Practical Examples

Configuring a standard CD-quality raw file:

ecasound -f:s16_le,2,44100 -i raw_audio.raw -o output.wav

Converting a 44.1 kHz stereo file to 48 kHz, 32-bit floating-point mono output:

ecasound -i input.wav -f:f32_le,1,48000 -o output.wav