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:
s16_le: Signed 16-bit integer, little-endian (standard for CD audio and most PC systems).s16_be: Signed 16-bit integer, big-endian.s24_le: Signed 24-bit integer, little-endian.s32_le: Signed 32-bit integer, little-endian.f32_le: 32-bit floating point, little-endian.u8: Unsigned 8-bit integer.
2. Channel Count
(channels)
This specifies the number of discrete audio tracks contained within the raw stream. Common values are:
1: Mono2: Stereo- Values greater than
2for multi-channel surround setups.
3. Sample Rate
(sample_rate)
This defines the frequency at which the analog signal was digitized, expressed in Hertz (Hz). Typical values include:
44100: CD quality (44.1 kHz).48000: Standard broadcast and video audio (48 kHz).96000: High-resolution audio (96 kHz).
4. Interleaving Mode
(interleaving)
This optional parameter specifies how multi-channel data is arranged. If omitted, Ecasound defaults to standard interleaved data.
i: Interleaved (samples alternate by channel: L, R, L, R...).n: Non-interleaved (all samples for channel 1 occur before channel 2).
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:alsaExample 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.wavIf 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.