Importing Raw Audio Streams into Ecasound

Raw audio streams lack file headers, meaning they do not contain metadata describing how the binary data is organized. To import and process raw audio streams using the Ecasound command-line utility, you must explicitly declare the audio format parameters before declaring the input source. This guide details the mandatory parameters—specifically sample format, channel count, and sample rate—required by Ecasound to accurately read and process raw PCM data.

The Audio Format Parameter Option (-f)

In Ecasound, stream properties are configured using the -f (format) option. When reading raw files or streams (such as input piped from standard input or a .raw file), the -f option must precede the input option (-i).

The general syntax for defining format parameters is:

-f:sample_format,channels,sample_rate,interleaving

To properly interpret raw audio, you must provide the following three core parameters, along with an optional fourth parameter:

1. Sample Format (sample_format)

This defines the bit depth, data type, and byte order (endianness) of the raw audio data. Common values include:

2. Channel Count (channels)

This specifies the number of discrete audio tracks contained within the raw stream. Common values are:

3. Sample Rate (sample_rate)

This defines the frequency at which the analog signal was digitized, expressed in Hertz (Hz). Typical values include:

4. Interleaving Mode (interleaving)

This optional parameter specifies how multi-channel data is arranged. If omitted, Ecasound defaults to standard interleaved data.

Command-Line Application

Because raw audio provides no self-identifying markers, Ecasound relies on parameter ordering. The format configuration must be declared directly before the target input source.

Example 1: Importing a raw stereo file To play a 16-bit signed, little-endian, 44.1 kHz stereo raw file:

ecasound -f:s16_le,2,44100 -i:audio_data.raw -o:alsa

Example 2: Reading a raw stream from standard input To capture and convert a 48 kHz, 24-bit mono stream piped from another application via stdin:

cat input_stream | ecasound -f:s24_le,1,48000 -i:stdin -o:output.wav

If any of the three primary parameters (sample format, channels, or sample rate) are omitted or misidentified, Ecasound will either fail to initialize the chainsetup or produce severely distorted output, such as white noise or incorrect playback speeds.