Ecasound Examples - The Best Place to Get Started with Ecasound

Remember to also check out the Ecasound Tutorials and Articles page, the ecasound(1) manpage, and the Ecasound User’s Guide.

The console mode user-interface, ecasound, is used in all the following examples. Other ecasound frontends may use a different syntax, but the basic principles are the still the same as long as ecasound is used as the backend engine.

Format Conversions

  1. ecasound -i:somefile.wav -o:somefile.cdr
  2. ecasound -i somefile.wav -o somefile.cdr
  3. These do the same thing, convert somefile.wav to somefile.cdr. As no chains are specified, default chain is used.

  4. ecasound -a:1,2 -i somefile.wav -a:1 -o somefile.cdr -a:2 -o somefile.mp3
  5. This is not a very useful example, but hopefully helps to understand the way chains work. First, two new chains 1 and 2 (you can also use strings: '-a:some_name_with_no_whitespaces,some_other_name') are created. They are now the active chains. After this, input somefile.wav is connected to both these chains. The rest follows the same scheme. Chain '1' is set active and output somefile.cdr is attached to it. In the same way, somefile.mp3 is attached to chain '2'.

  6. ecasound -c -i somefile.wav -o somefile.cdr
  7. Like before, but ecasound is now started in interactive mode.

Format Conversions - Resampling

  1. ecasound -f:16,2,96000 -i resample,auto,foo44100.wav -o bar96k.wav
  2. ecasound -f:16,2,44100 -i resample,auto,bar96k.wav -o foo44100.wav
  3. ecasound -f:16,2,44100 -i resample-hq,48k,foo48k.wav -o bar.wav
  4. ecasound -f:16,2,44100 -i resample,96k,third.raw -o foo44100.wav
  5. To do resampling, a special 'resample' input type must be used. In the first example above, the 44100Hz file foo44100.wav is resampled to 96kHz and the result is written to bar96k.wav. In the second example the reverse is done, sample rate is converted from 96khz to 44100Hz. In the last example, the from rate has to be specified explicitly as raw audio files do not contain the necessary header information.

    In the last example we do a 48000Hz to 44100Hz conversion using the 'resample-hq' input type. If Ecasound was built with support for the libsamplerate package, 'resample-hq' selects the high-quality conversion mode. In this mode the conversion process requires more CPU power, but the results are of higher quality. Using libsamplerate also improves quality of the default 'resample' mode.

Realtime Outputs (soundcard playback)

  1. ecasound somefile.wav
  2. ecasound -i somefile.wav
  3. ecasound -i:somefile.wav
  4. ecasound -i somefile.wav -o /dev/dsp
  5. If you haven't touched your ~/.ecasound/ecasoundrc configuration file, these should all do the same thing, output somefile.wav to /dev/dsp using the default chain. If no inputs are specified, ecasound tries to use the first non-option argument on the command line as a default input. If no chains are specified, the chain 'default' is created and set active. If no outputs are specified, the default-output defined in ~/.ecasound/ecasoundrc is used. This is normally /dev/dsp.

  6. ecasound -i somefile.mp3 -o alsahw,0,0
  7. ecasound -i somefile.mp3 -o alsaplugin,0,0
  8. ecasound -i somefile.mp3 -o alsa,soundcard_name
  9. The ALSA drivers have a somewhat different option syntax. You first specify either "alsahw" (to indicate you want use the ALSA direct hw interface) or "alsaplugin" (for ALSA plugin layer), and then specify the card number and the device number (optionally also subdevice can be given). The plugin layer is able to handle some type conversions automatically. The third option is specific to ALSA 0.9.x (and newer). 'soundcard_name' must be defined in the ALSA configuration files (either ~/.asoundrc or the global settings file). Otherwise ALSA inputs/outputs work just like OSS-devices.

  10. mpg123 -s sometune.mp3 | ecasound -i:stdin -o alsahw,0,0
  11. Send the output of mpg123 to standard output (-s option) and read it from standard input with ecasound (-i:stdin option). If you want to use native ALSA support with OSS-programs, this is one way to do it easily. This can also be used to add effects to standard streams containing audio data.

Realtime inputs (recording from soundcard)

  1. ecasound -i:/dev/dsp0 -o somefile.wav
  2. ecasound -i:/dev/dsp0 -o somefile.wav -c
  3. ecasound -i alsahw,1,0 -o somefile.wav
  4. These are simple examples of recording. Notice that when recording it's often useful to run ecasound in interactive mode (-c).

Effect Processing

    Ecasound is an extremely versatile tool when it comes to effect processing. After all, it was originally programmed for non-realtime dsp processing. Because of this, these examples just scratch the surface.

  1. ecasound -i somefile.mp3 -o /dev/dsp -ea:120
  2. ecasound -a:default -i somefile.mp3 -o /dev/dsp -ea:120
  3. Let's start with a simple one. These do the same thing: mp3 input, OSS output and an amplify effect, which amplifies the signal by 120%, are added to the default chain.

  4. ecasound -i somefile.mp3 -o /dev/dsp -etr:40,0,55 -ea:120
  5. Like the previous example, but now a reverb effect, with a delay of 40 milliseconds, surround disabled and mix-% of 55, is added to chain before the amplify effect. In other words the signal is first processed with the reverb and then amplified. This way you can add as many effects as you like. If you ran out of CPU power, you can always use output to a file.

  6. ecasound -a:1,2 -i somefile.mp3 -a:all -o /dev/dsp \
  7. Ok, let's do some parallel processing. This time two chains are created and the input file is assigned to both of them. The output file is assigned to a special chain called all. '-a:1,2' would also work. This way we can use one signal in multiple chains and process each chains with different effects. You can create as many chains as you want.

Using controller sources with effects

  1. ecasound -i somefile.wav -o /dev/dsp -ef3:800,1.5,0.9 -kos:1,400,4200,0.2,0 -kos:2,0.1,1.5,0.15,0
  2. ecasound -i somefile.wav -o /dev/dsp -ef3:800,1.5,0.9 -km:1,400,4200,74,1 -km:2,0.1,1.5,71,1
  3. The first example uses two sine oscillators ('-kos:parameter,range_low,range_high,speed_in_Hz,initial_phase') to control a resonant lowpass filter. The cutoff frequency varies betweeen 400 and 4200 Hz, while resonance varies between 0.1 and 1.5. The initial phase is 0 (times pi). The second example uses MIDI continuous controllers ('-km:parameter,range_low,range_high,controller_number,midi-channel') as controller sources. The ranges are the same as in the in first example. Controller numbers used are 74 (cutoff) and 71 (resonance). In other words you can use your synth's cutoff and resonance knobs.

    It's also possible to control controllers with other controllers using the '-kx' option. Normally when you add a controller, you're controlling the last specified chain operator. '-kx' changes this. Let's take an example:

  4. ecasound -i file.wav -o /dev/dsp -ea:100 -kos:1,0,100,0.5,0 -kx -kos:4,0.1,5,0.5,0

    Same as before, but now another 0.5Hz sine oscillator is controlling the frequency of the first oscillator.

  5. ecasound -i file.wav -o /dev/dsp -ef3:1000,1.0,1.0 -kos:1,500,2000,1,0 \
    -kos:2,0.2,1.0,0.5,0 \
    -kx -km:1,0.1,1.5,2,1
  6. Ok, let's get real whacky. Here a 1Hz sine oscillator is assigned to the cutoff frequency, while other controller is controlling resonance. Now we add a MIDI-controller, that controls the second sine oscillator.

Multitrack Recording

  1. ecasound -c -b:256 -r -f:16,2,44100 \
  2. It really is this simple. To minimize syncronization problems, a small buffersize is set with '-b:buffer_size_in_samples'. This time I set it to 256 samples. To ensure flawless recording, runtime priority is risen with '-r'. Then a default sample format is set with '-f:bits,channels,sample_rate'. Now all that's left is to specify two chains: one for monitoring and one for recording. When using the above command, you need to have some way of monitoring the signal that's been recorded. A common way is to enable hw-monitoring (unmute/adjust the line-in level from your mixer app). If you want to use ecasound for monitoring, you have to add a separate chain for it:

  3. ecasound -c -b:256 \
  4. One thing to note that there are some differences in how OSS soundcard drivers handle full-duplex (playback and recording at the same time) operation. Some drivers allow the same device to be opened multiple times (like in above example we open '/dev/dsp' once for recording and once for playback.

    You can always do test recordings until you find the optimal volume levels (using the soundcard mixer apps and adjusting source volume), but ecasound offers a better way to do this. This is a bit ugly, but what's most important, it works in text-mode:

  5. ecasound -c -f:16,2,44100 -a:1 -i /dev/dsp0 -o /dev/dsp3 -ev
  6. Basicly this just records from one OSS input, puts the signal through an analyze ('-ev') effect and outputs to an OSS output. The secret here is that you can get volume statistics with the estatus (or es) command in interactive mode. Newer ecasound versions (1.8.5 and newer) come with 'ecasignalview', which is a standalone app that can monitor signal level in realtime.


    Here's a few real-life mixdown examples.

  1. ecasound -c \
  2. First of all, interactive-mode is selected with '-c'. Then four inputs (all stereo) are added. All four chains are then assigned to one output, which this time is the soundcard (/dev/dsp). That's all.

  3. ecasound -c -r \
  4. This second example is more complex. The same inputs are used, but this time effects (amplify '-ea:mix_percent' and normal pan '-epp:left_right_balance') are also used. Additionally we want to route the full mix to both the soundcard and to a file. We can accomplish this by using a virtual loop device. Here the first four chains are routed to a loop device 'loop,1', which again feeds the audio to both the soundcard '/dev/dsp' and to a WAVE file 'current-mix.wav'. In this example, runtime priority is also risen with '-r' (requires root privileges).

Cut, Copy and Paste

  1. ecasound -i bigfile.wav -o part1.wav -t:60.0
  2. ecasound -i bigfile.wav -y:60.0 -o part2.wav
  3. Here's a simple example where first 60 seconds of bigfile.wav is written to part1.wav and the rest to part2.wav. If you want to combine these files back to one big file:

  4. ecasound -i part2.wav -o part1.wav -y:500
  5. part2.wav is appended to part1.wav.

Multichannel Processing

    You need to worry about channel routing only if input and output channel counts don't match. Here's how you divide a 4-channel audio file into 4 mono files.

  1. ecasound -a:1,2,3,4 -i 4-channel-file.raw \

Signal Routing through External Devices

  1. ecasound -c -b:128 -r -f:16,2,44100 \
  2. So basicly, this is just like multirack recording. The only difference is that realtime input and output are externally connected.

Presets and LADSPA Effect Plugins

  1. ecasound -i null -o /dev/dsp -el:sine_fcac,440,1
  2. This produces a 440Hz sine tone (great for tuning your instruments!). For the above to work, LADSPA SDK needs to be installed (see

  3. ecasound -i:null -o:/dev/dsp -el:sine_fcac,880,1 -eemb:120,10 -efl:2000
  4. This results in audible metrome signal with tempo of 120BPM. Now the syntax might look a bit difficult for everyday use. Luckily ecasound's preset system will help in this situation. You can get the same exact result with:

  5. ecasound -i:null -o:/dev/dsp -pn:metronome,120
  6. See the file 'effect_presets' for a list of available effect presets. By default, location of this file is '/usr/local/share/ecasound/effect_presets'.

Use with JACK audio server

  1. ecasound -i foo.wav -o jack_alsa
  2. ecasound -i foo.wav -o jack
  3. This will create a separate JACK output port for each channel of foo.wav, and automatically connect these Ecasound ports to the ALSA PCM output ports in the JACK server. The second example will create JACK output ports, but does not establish any connections (you have to do this yourself with jack_connect, qjackconnet, qjackctl, or other similar tool).

  4. ecasound -c -i foo.wav -o jack_alsa -G:jack,eca_slave,recv
  5. Like in previous examples, but the ecasound client name (as shown to other JACK clients) is set to "eca_slave", and ecasound is configured to react to incoming transport changes (play, stop, seek, etc). By default ecasound both sends and reacts to transport events.

More MIDI examples

  1. ecasound -i somefile.wav -o /dev/dsp -efl:400 -km:1,400,4200,74,1
  2. The above is a simple example how MIDI is used to control an effect - here the low-pass filter -efl. The above uses OSS rawmidi access, which is equivalent to adding -Md:rawmidi,/dev/midi to the command line. To do the same with ALSA, the syntax is as follows:

  3. ecasound -i somefile.wav -o alsa -efl:400 -km:1,400,4200,74,1 -Md:rawmidi,/dev/snd/midiC0D0
  4. ecasound -i somefile.wav -o alsa -efl:400 -km:1,400,4200,74,1 -Md:alsaseq,80:1
  5. ecasound -i somefile.wav -o alsa -efl:400 -km:1,400,4200,74,1 -Md:alsaseq,KMidimon
  6. The first one uses the ALSA rawmidi interface and opens an ALSA device (card 0, device 0) for raw MIDI I/0. The second example uses the ALSA sequencer API, which is more powerful as you can route MIDI packets from and to other applications supporting the sequencer API. "80,1" and "KMidimon" are sequencr ports to which ecasound should connect. You can use the "aconnect" (part of alsa-utils) tool to list all available sequencer ports.

    Note: For ALSA sequencer support, you need ecasound-2.4.3 or newer.

Back to index.