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.
These do the same thing, convert somefile.wav to somefile.cdr. As no chains are specified, default chain is used.
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'.
Like before, but ecasound is now started in interactive mode.
Format Conversions - Resampling
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)
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.
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.
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)
These are simple examples of recording. Notice that when recording it's often useful to run ecasound in interactive mode (-c).
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.
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.
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.
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
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:
Same as before, but now another 0.5Hz sine oscillator is controlling the frequency of the first oscillator.
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.
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:
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:
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.
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.
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
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:
Signal Routing through External Devices
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
This produces a 440Hz sine tone (great for tuning your instruments!). For the above to work, LADSPA SDK needs to be installed (see www.ladspa.org).
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:
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
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).
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
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:
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.