quick menu

2. First steps

In this chapter we should discover some first steps of playing with sounds. We'll see how to play a sound, how to record a sound and how to process a sound. All those actions will be demonstrated in their simplest manners.

Table of contents

2.1 How to play a sound

How to play a sound on your soundcard. Most of these examples will be for simple cases. I assume, that you have one simple soundcard, like those small onboard devices. With more complicated soundcards, even playback can sometimes be tricky. But don't be afraid, you'll find one way, that will work!

2.1.1 How to play a sound with aplay

The most basic tool for playback is probably: aplay. It is included in your alsa-distribution. Aplay is a small command-line program, that can play .wav-files and simple raw audio. It can output to _ANY_ alsa-device, if you know its name.

So let's start with the most basic usage possible. Find some .wav-file, usually you can find one in /usr/share/sounds/alsa. Change to that directory and type:
aplay test.wav

Now you should hear some music on your speakers or headphone. If you don't, try the alsamixer or amixer program to raise your volume and unmute the channels. (See 2.4 adjusting the volume)

Now as I said, this is only the most basic form of using aplay. If you have more than one soundcard in your computer, you can also specifiy, which soundcard aplay should use for output. To achieve the same result as above, you can also type:
aplay -D hw:0 test.wav

The "-D" option specifies a device to use. "hw" means hardware. As in most computer programs, alsa starts counting at 0. So "-D hw:0" means the first hardware device, or in other words: your first soundcard. If you have a second soundcard, you could try:
aplay -D hw:1 test.wav

ALSA offers another nice feature: you can "create" some devices yourself. How this is done, I won't and can't really show. But there are some standard devices. One of thme is called "default". Default usually marks the first playback device found. Those named devices are called: plugins. To play a sound on "defulat" you'd type:
aplay -D plug:default test.wav

If you want to know more about special alsa-devices, how to work with them and how to create them yourself, then take a look at the ALSA website. You should also see the ALSA Wiki.

2.1.2 How to play a sound with ecasound

With ecasound ther are a lot of ways to play a sound, too. I will show some of these ways here. For more basic help on using ecasound take a look at the ecasound examples page. This is the best place to start with ecasound in any case. At the main ecasound site you'll find ore documentation and small guides. Just take a look at the "Documentation section".

Playing a simple .wav-file. find some .wav-file - i.e. the alsa testfile in /usr/share/sounds/alsa. Then type:
ecasound test.wav

This is the simplest and fastest way to play a soundfile with ecasound. Ecasound has a configuration-file, where a standard output device is set, so you don't need to supply one. You can however do so with:
ecasound -i test.wav -o /dev/dsp
ecasound -i test.wav -o alsa,default

the first form you can only use, if your ALSA-oss-emulation is compiled and running. You'll see, that again we used the "default"-plugin. You can also try:
ecasound -i test.wav -o alsahw,0,0
This would tell ecasound to use the first soundcard of your computer and there, the first playback-device it can find.

A word on alsa and alsahw. If you use alsa,something, this means the next word is a name of an ALSA-plugin (like default). It is the same as "plug:" with aplay's -D option. The alsahw, is similar to aplay's hw.
NOTE: With ecasound you don't use a colon ':', but a comma ','.

With ecasound you can play .wav, .cdr (raw 16BIT, STEREO, 44.1KHz), .snd and .aif files. If you installed mpg321 or mpg123, ogg123 and timidity, you can also play mp3, ogg and midifiles. Ecasound can use those external programs to play and convert those formats.

Playing an mp3-file or an ogg-file looks as simple as before:
ecasound music.mp3
ecasound song.ogg

2.1.3 How to play a sound with mplayer

Mplayer has the great advantage, that - properly installed - it can not only play wav, mp3 and ogg, but also RealAudio, RealVideo, .mov-files and a lot more. Mplayer can use the windows-libraries to play all those proprietary formats.

How to play a simple audio-file with mplayer: Very simple.
mplayer song.mp3
mplayer soundstream.ra

Playing a video with mplayer under console, will require one more option: the -vo (video output) option. This option specifies, which interface to use for output. It can use the ascii-arts-library (if available):
mplayer -vo aa my_video.mov
or the vesa output:
mplayer -vo vesa my_video.mpg
or you can deactivate video-output:
mplayer -vo null my_video.rv

All of the mentioned outputs work with a console (NO NEED FOR X11 to be started!). But beware: In VESA-mode you can't read anything with a braille-display!

For a more detailed overview of mplayer, you'll have to wait or read mplayer's manpage. There's also an mplayer-mailinglist somewhere.

2.2 How to record a sound with ecasound

This can as well be very simple. The easiest way this can work is with:
ecasound -i /dev/dsp -o recorded_sound.wav
Again this only works if your ALSA-oss-emultation is running. If this isn't the case, you should try:
ecasound -i alsa,default -o recorded_sound.wav

Recording can be more dificult, because of the soundcard devices. If you have a simple soundcard "alsa,default" will work. If you have a more complex card, you might have to try different hardware devices like in:
ecasound -i alsahw,0,0 -o recorded_sound.wav
The second number is the device number on a card. so "alsahw,0,1" is the second device on you first soundcard (remember that we start counting from 0!).

If you have a nicely written .asoundrc, you can also use the devices listed in there. I.e., if you have defined a device pcm.in1 you can type:
ecasound -i alsa,in1 -o recorded_sound.wav

We will deal with more complex recording - including recording with JACK - later.

2.3 How to hear some sound-effects

Now that we've done some simple recording, we might find, that our recorded sounds are boring. So we'd like some interesting effects. This can be done with ecasound again. Let's see a simple example and discover its meaning:
ecasound -i my_sound.wav -o alsa,default -ete:50,70,40

So, what have we done? We played back our soundfile - my_sound.wav - using alsa,default. Then we use another option: "-ete". What is that. That is a simple reverb-effect. There are three parameters, separated each by a comma ','.

Ecasound has a few built-in effects, there are some delays (echos), chorus, flanger and phaser etc. Let's try one delay now and for the other effects, RTFM (man ecasound).
ecasound -i sound.wav -o alsa,default -etd:125,2,4,60
So what is -etd. This is a simple delay effect. Well there are simplerones, but there'll be no problem in understanding it. Let's take a look at the parameters.

So, you have seen simple effects-processing. Now you can browse through ecasound's manpage and discover filters, flanger, chorus or another delay.

NOTE: All options you wanna try are the -e...-options. Some of the filters are dificult to set. Don't worry, even I don't understand them all. :-)Also the -eca (compressor) is dificult to use, we'll see that one later.

Back to top of page E-mail me someday the copyright notice :-)
Last modified : Feb 12
Rendered with bug.sh version: 0.3