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,interleaving

To 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 alsa

In this command:

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 default

Common supported sample formats for the first argument include:

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.