ALSA

From RidgeRun Developer Wiki


The Advanced Linux Sound Architecture (ALSA) is the standard sound system in modern Linux distributions. You can use ALSA commands on any Linux-based system to control, manage, and configure audio.

General/Useful commands

These commands allow you to interact with ALSA to play, record, and manage audio on your platform. Please note that the specific audio devices and configurations may vary depending on your system setup and the audio hardware on your platform.

List available playback devices:

aplay -L

List available capture devices:

arecord -L

Play an audio file:

aplay your_audio_file.wav

Capture Audio:

arecord -f cd your_recorded_audio.wav

Adjust Volume and Mixer Settings. Open the ALSA mixer interface:

alsamixer

Use arrow keys to navigate and adjust volume levels and settings. Press "Esc" to exit.


Set Default Audio Device: You can use the aplay and arecord commands with the -D option to specify the device. For example:

aplay -D hw:0,0 your_audio_file.wav
arecord -D hw:0,0 -f cd your_recorded_audio.wav

Note: hw:0,0" is a device identifier used to specify a particular hardware device for audio input or output. In ALSA there are multiple types of devices, including hardware devices (such as sound cards), software devices (like virtual mixers), and more. When you use "hw," you are selecting a hardware device for audio input or output.

Modify the hw:0,0 part according to your specific device's configuration. You can list the available devices using these commands:

aplay -L
arecord -L.

Display sound card information:

cat /proc/asound/cards

To get information about the devices available on the system, run:

cat /proc/asound/devices

It displays a list of ALSA devices and their corresponding device numbers. The information presented in this file includes details about the following types of ALSA devices:

  • Audio Playback Devices: Devices that are used for audio output, such as sound cards and playback interfaces. They can be used to play audio from applications to external speakers or headphones.
  • Audio Capture Devices: Devices that are used for audio input, such as microphones or other audio input sources. They capture audio data from external sources that can be used on applications.
  • Sequencer Devices: These are MIDI-related devices (Musical Instrument Digital Interface) used for music and sound synthesis, typically used by music production software.

Each device is listed with its corresponding device number. For example, you might see entries like "0: [ 0] : control" or "1: [ 0] : timer." The numbers inside square brackets represent the device numbers.

Here's a breakdown of the typical columns in the output:

  • Device Number: Is a numerical identifier for the device. It helps to reference the device in ALSA configurations or when using ALSA-related commands.
  • Device Type: Is related to the type of device, which can be "control" for control devices, "pcm" for audio playback or capture devices, and "timer" for timer devices, among others.
  • Description: Provides a brief description of the device, such as the device's name or purpose.

Reload the ALSA configuration without rebooting:

sudo /etc/init.d/alsa-utils restart

Check the installed ALSA version:

cat /proc/asound/version

How-to configure alsa lib configuration file

Follow this link: How-to configure ALSA lib configuration file

Audio route into headset jack on sabresd

Check

$HOME/imx-p9.0.0_2.2.0-ga/android_build/vendor/nxp-opensource/imx/alsa

And then check the following method to set the desired output:

static void select_output_device(struct imx_audio_device *adev)

Audio route into headset jacks on SabreSD

Check audio on HDMI and headset jack

This section will guide you on how to debug audio on HDMI and jack outputs.

Check for devices:

aplay -l 

That will show you a list like this:

**** List of PLAYBACK Hardware Devices ****

card 0: wm8962audio [wm8962-audio], device 0: HiFi wm8962-0 []

  Subdevices: 1/1

  Subdevice #0: subdevice #0

card 1: imxhdmisoc [imx-hdmi-soc], device 0: IMX HDMI TX mxc-hdmi-soc-0 []

  Subdevices: 1/1

  Subdevice #0: subdevice #0

Check audio on headphone jack:

speaker-test -Dplughw:0.

Double check with aplay:

cat /dev/urandom | aplay -Dplughw:0

It should show you something like this:

Playing raw data 'stdin' : Unsigned 8 bit, Rate 8000 Hz, Mono

Check audio on HDMI:

speaker-test -Dplughw:1.

Double check with aplay:

cat /dev/urandom | aplay -Dplughw:1

It should show you something like this:

Playing raw data 'stdin' : Unsigned 8 bit, Rate 8000 Hz, Mono


More information: Getting HDMI audio to work on Sabre sd



For direct inquiries, please refer to the contact information available on our Contact page. Alternatively, you may complete and submit the form provided at the same link. We will respond to your request at our earliest opportunity.


Links to RidgeRun Resources and RidgeRun Artificial Intelligence Solutions can be found in the footer below.