s i s t e m a o p e r a c i o n a l m a g n u x l i n u x | ~/ · documentação · suporte · sobre |
Next
Previous
Contents
6. Testing and usingNow you should test if the sound driver really is available, then try to use it. 6.1 The /proc filesystemYou can find a lot of useful information about your system in the /proc subdirectory. /proc is a "virtual" filesystem, meaning that it does not exist in real life, but merely is a mapping to various processes and tasks in your computer. In order for /proc to work, you need to have support for it compiled into your kernel. Most linux distributions have this as a default, but if you compiled a kernel and left /proc out obviously there won't be anything in /proc. /proc/modules gives information about loaded modules. Once the ALSA sound drivers are loaded, if you type cat /proc/modules you should see something like:
If something went wrong during the installation of the driver, you will
still see a couple of "snd" devices, but there won't be sound support.
For example (Note: you should never issue this command as follows, the cs4236 driver needs options):
You can check the existence of a soundcard by looking in /proc/asound/cards.
For example:
In the previous example (where I forgot the options) the output would have
been:
A working CS4236 card would produce
If you checked and doublechecked your settings and still see no sound card,
take a look at the troubleshooting section.
The If
this means that your driver is ready to go, but
is not doing anything right now. (So everything went well).
For users of a 2.0.x kernel there is a third method to find information about the sound devices, namely if you inserted the OSS compatible driver there is a /dev/sndstat device. The ALSA drivers kindly request that you not to rely on this information as it is only there for compatibility with the OSS drivers and better information can easily be obtained from /proc/asound/. In kernel 2.2.x ALSA uses the kernel soundcore and therefor cannot emulate /dev/sndstat, since it would interfere with the OSS drivers.
6.2 The mixerOnce the drivers for your sound card have been installed and your /proc filesystem tells you so, you can try to make a real sound. To do this, you need to set the mixer volumes to a reasonable value. You need the ``amixer'' from the alsa-utils package for this. First of all, install the utility package, or at least put the "amixer" command in some reasonable place (like /usr/local/bin). Version 0.3.2 and later have an interface that differs from the OSS drivers. If you type just ``amixer'' you will see the mixer elements and their value. One of these elements could be ``Master volume'' for example, and could look like:
Unfortunately, I do not know how to set left and right volumes independently. With amixer, you can change volumes with the ``amixer set'' command. For example, to change the Master volume, you would issue a
Please note that the names of the elements can be different for different types of sound cards. Also note that amixer is case dependent, so ``amixer set masteR 10'' will not work. For more information, please look in the amixer man page.
If you have a 0.3.0-pre4 ALSA, then amixer works just like normal mixer programs. You can look at the mixer settings by typing ``amixer''. This command lists the ``mixer settings'', or as you would normally call it, the volume settings of the various parts of the soundcard. The output from amixer can greatly differ from card to card. My Soundblaster 16 shows:
If you only get a message like ``amixer: Specify command...'', then you are using the ALSA 3.2 utilities. I suggest you to upgrade to 0.4.1e or later, or to go back to 0.3.0-pre4.
Mixer settings for playingYou have noticed the "Mute" entry for some devices. This means that this particular device will be zeroed out, whatever volume setting you use. Some cards (the CS4237B in the example) even mute their master channel. So, for the CS4237B, I would have to type
to even be able to produce any sound at all. The Soundblaster does not have muted output, but
would set the volume to 100% - and unmute it if it would have been muted. You can use a number, a word like "mute" or "unmute", or both. Type
to set the CS4237B card to maximum master volume and unmute PCM volume and set it to maximum. If you use an older version of amixer, you need to leave out the ``set'' part of the command, so you would just type
Mixer partsThe various mixer parts may confuse you if you have no knowledge of digital sound production. The sound-HOWTO may help a bit, but a very short introduction is here. You will probably only need few mixer elements: one of them is the ``CD'' setting (this is analog sound of your CD player, most CD players are connected with a 3 or 4 wire red/white/black cable). The ``PCM'' setting is used for most applications. Programs like mpg123, xmms, speakfreely, realplayer and most others use the PCM channel. ``MIC'' stands for microphone, ``line-in'' is an (optional) extra input at the back of your sound card. The various ``gain'' parts offer extra amplification for various uses and are pretty self-explanatory. (Like: record-gain is extra amplification for the recording channel, which can be useful if you use a microphone).
Mixer settings for recordingYou would set the CD channel to record by typing
and stop the recording setting again by typing
Note that older amixer programs use ``amixer CD rec'' and ``amixer CD norec'' for this. If you would like to record something from the microphone, you would probably use
(Using the microphone input unmuted will produce loud high-pitched sound if your mic picks up its own signal from the speakers again). Most microphones have a ``gain'' setting to boost the microphone volume; you are most likely going to need it to pick up any sound from the microphone at all. Again, older amixer programs use ``amixer "input gain" 100; amixer mic 100 rec mute''.
Other mixer settingsUnfortunately I have not been able to change the volume of the "3d center" and "3d space" settings with amixer 0.3.0-pre4. I haven't tried yet with 0.4.1e (this particular machine is still running 2.0.38). If anyone succeeds please let me know. I can use alsamixer for this job, but alsamixer was not ported to the 0.4.1e version yet. The ALSA FAQ says that it is possible to restore mixer settings with
6.3 The /dev/snd/ devicesThe alsa drivers have native sound-devices in the /dev/snd/ directory. If you have one card you might see the following devices:
The first number means the number of the soundcard, the second number (if
any) is the number of the device. A sound card with two PCM devices would
have a pcmC0D0 and pcmC0D1 device.
Please note: the ALSA devices have changed between the previous version. Older
ALSA drivers use /dev/snd/pcm00 (first number is the card, second number is the device).
If this HOWTO uses the older notation, please drop me a line so I can correct it.
Now you are ready to put any soundfile you want into the PCM device
of the first card. So try to cat any textfile (any file) to /dev/snd/pcmC0D0,
like this: The default setting of your sound device is 8000 Hz, 8 bit. That means that the "english.au" file mentioned above will produce speech, other test files will probably just produce noise. If you do not hear anything, check your speakers, try to run "amixer" again or consult a doctor. (Later on you can easily use the full 48 KHz, 16 bit features of your sound card, by using your favourite sound player like sox or mpg123). If you loaded the ``snd-pcm1-oss'' module, you can also use the OSS-compatibility to access your sound card. The following mappings are made:
You probaly want to use the ``snd-mixer-oss'' module as wel, so you can use the backwards compatible mixer.
6.4 Additional informationThe INSTALL file in the ALSA driver directory mentions some tricks to tell the driver which settings to use. If you need these commands it will depend on the application you use to play sound. Regular sound playing applications, like mpg123, sox (mostly called with the ``play'' command), or X11 applications like RealPlayer will probably do fine without these. I never used these anyway. /proc/asound/#/pcm#0
Examples:
/proc/asound/#card#/sb16
Example: For further reference, please consult the INSTALL file. Next Previous Contents |