How to Set Global Sample Rate in Ecasound
This article explains how to define the global sample rate for an Ecasound audio processing session using standard command-line flags. Ecasound manages audio parameters using format flags that define bit depth, channel counts, and sampling frequency across the active chainsetup. By applying these flags correctly at the start of your command, you can ensure consistent sampling rates across inputs, processing chains, and outputs.
Using the Audio Format Flag
(-f)
In Ecasound, sample rate is controlled using the -f
(audio format) chainsetup option. The syntax for this flag accepts up to
four comma-separated parameters:
-f:sample_format,channels,sample_rate,interleavingTo set the global sample rate across the entire session, place the
-f flag before specifying your inputs (-i) and
outputs (-o).
Specifying Only the Sample Rate
If you only want to set the sample rate while leaving sample format, channel count, and interleaving at their default values, leave the other fields blank while retaining the commas:
ecasound -f:,,48000 -i input.wav -o alsaIn this command:
- The first parameter (
sample_format) is omitted (defaults to 16-bit signed little-endian or system default). - The second parameter (
channels) is omitted (defaults to 2). - The third parameter is explicitly set to
48000Hz (48 kHz).
Specifying a Complete Audio Format
To prevent ambiguity or unexpected audio resampling, define the complete audio format alongside the sample rate:
ecasound -f:s16_le,2,44100 -i somefile.wav -o defaultCommon supported sample formats for the first argument include:
s16_le: 16-bit signed integer, little-endians24_le: 24-bit signed integer, little-endians32_le: 32-bit signed integer, little-endianf32_le: 32-bit floating point, little-endian
How Ecasound Applies the Rate
When declared at the chainsetup level prior to inputs and outputs,
the -f option sets the internal processing rate for the
session. If an audio input differs from the specified session rate,
Ecasound automatically inserts an internal resampler to match the target
sample rate before routing audio to the specified outputs.