RadioReference on Facebook   RadioReference on Twitter   RadioReference Blog
 
Wiki Home
Page
View source
History


Personal Tools

Search the Wiki





 

ALSA


Contents

Introduction

This document provides a basic overview of configuring ALSA on a Debian system so that it is useful with things like liquidsoap and darkice.

These instructions are based on setup with Debian Jessie with a minimal installation based on the "Basic system utilities" selection in tasksel.

Getting Started

To begin, you'll probably need to install alsa-utils if you're running a minimal system. To install alsa-utils, run this command as root:

apt-get install alsa-utils

Once this package is installed, you'll have tools to make use of ALSA on your system. Verify that you have the correct permissions and configuration for ALSA by checking for capture devices using this command as root:

arecord -l

You should receive a list of the capture devices in the system similar to this:

**** List of CAPTURE Hardware Devices ****
card 0: SB [HDA ATI SB], device 0: AD1983 Analog [AD1983 Analog]
  Subdevices: 0/1
  Subdevice #0: subdevice #0

If not, you may not be a member of the group audio on your system. You can correct this by adding yourself to the group with this command (run as root):

usermod -aG audio <username>

Substitute <username> with the literal name of your account, such as tom. For example:

usermod -aG audio tom

In order for the command above to take affect, you must log out of your session and back in. If the list looks normal, move on to the next section.

Basic Setup and Testing

The first thing we need to do is determine which capture card you will be using for your audio input and output. Connect an input audio source (like a scanner) to the line-in on your sound card (do not use the mic input). Connect a set of headphones or speakers to the headphone jack on the same sound card. Make sure your scanner has enough traffic for good monitoring or temporarily switch it over to a weather station so that you have regular sound input. Once you're ready to monitor, run this command as root:

alsamixer

This will produce a text-mode sound mixing console where you can configure the attributes of the sound card. We will be using this tool to determine which sound card you're using and what input should be selected. The tool shows channels across the screen with the various levels and selections made for each channel.

To begin, press F6 to select your sound card. If you only see three options, you most likely only have one sound card that is detected. If you only have one, just press escape. If not, select the card that contains your input devices and press Enter.

Once the correct device is selected, press F3 to ensure that we're in PLAYBACK mode. We'll locate the input device this way using monitoring. Next, we need to unmute the sound system generally speaking. Using your arrow keys, make sure that the Master is highlighted red as shown below:

ALSAMixer.png

Press M to unmute the channel (master is muted by default). The MM on the channel should change to 00 to indicate that it is unmuted. Using your up/down arrow keys, increase the level up to ~65. Next, use your left/right arrow keys to navigate over to the Line channel and ensure that it is unmuted as well. Bring the level of the Line channel up to ~65 as well.

If you're using a headphone jack and you have a headphone channel (as shown in the picture above), also unmute and set the level on this channel. Finally, scroll all the way to the right and keep pressing the right arrow to check for additional channels. If there is a channel named Loopback Mixing, use the up/down arrow keys to ensure that it shows Enabled (otherwise you'll never heard anything while monitoring).

At this point, you should now hear your input device through your monitoring device. If you do not, check your connections and validate that you have unmuted everything as instructed. If you still do not hear input, check for other channels on playback that may need to be unmuted. As a tip, you can unmute beep and then press Escape to exit alsamixer. If you press Tab at the command prompt with no data, you should hear a beep on your monitoring device. If not, your setup may require additional work outside of the scope of this article.

Configuring the Capture Device Levels

Once you've validated input through alsamixer, go ahead and set a good input volume for your feed by adjusting the Line channel volume up and down with the up/down arrow keys. Once you've set your desired volume, remember this value. Press F4 to switch to CAPTURE mode.

Locate the Line channel using your left/right arrow keys and, once it is selected, press the Space Bar to set this device for capture. The text above should change from dashes to CAPTURE. If you have a level on the Line device, set it to the same as what you found previously while monitoring. If not, check for a Capture device setting and set the level there.

If you wish the leave monitoring active, you can just press Escape to exit alsamixer. If you want to disable monitoring, press F3 to return to PLAYBACK mode. Select the Master channel and press M to mute the device. Press Escape to exit alsamixer.

You've now validated that ALSA functions properly on your system. This is not the end, however, if you plan to use this for applications that do not run as root (such as liquidsoap and darkice). See the next section for additional steps.

Setting User Permissions for Audio

In order to capture audio as a non-root user (this is very much recommended), you should add each user that will be running audio capture applications to the audio user group on the system. For liquidsoap default installations, the user account is liquidsoap. Check the documentation for your application to determine which user account it will use.

For each use account that requires access to the audio capture hardware, add them to the audio group with this command as root:

usermod -aG audio <username>

Substitute <username> with the literal name of the user such as liquidsoap. For example:

usermod -aG audio liquidsoap

Repeat this for each user account you need to use. Next, test the audio permissions as each user to ensure that they work properly. As root, become each user using this command:

su -m <username>

You may receive some errors but this will give you a shell as that user account. Run this command to verify that you receive a list of sound cards:

arecord -l

If you do, this user has the needed permissions for audio work. If not, you'll need to investigate the problem further as it is outside of the scope of this article. Once you have tested a user account, type 'exit' to leave the su session and return to root.

Getting Around Soundcard Sharing/Enumeration Issues

There can be many reasons why you may have problems trying to use your sound card on the system with audio capture applications. For this reason, it is recommended that you create a simple virtual capture device that represents your audio hardware. Using the output of 'arecord -l', we get a list of the sound cards. Locate your card in this list and then determine which sub-device you need to use. This will form a device reference for ALSA: hw:<device>,<subdevice>.

For instance, in the examples above, we're using hw:0,0. We can configure an easy virtual device for this hardware by editing /etc/asound.conf as the root user and adding an entry like this:

pcm.<name> {
        type plug
        slave { pcm "hw:<device>,<subdevice>" }
}

For example, this is the one in use on the audio server from this article:

pcm.liquidsoap {
        type plug
        slave { pcm "hw:0,0" }
}

Using this method will also prevent exclusive access problems in case you want to use the sound device for more than one application but the sound card does not permit this. In your applications, you will refer to the sound device as the name you've specified in this setup, such as pcm.liquidsoap from the example.




Return to Wiki page: Liquidsoap
(No matching DB page)


Copyright 2018 by RadioReference.com LLC Privacy Policy  |  Terms and Conditions