Modify the Capability of Your Sound Card in Raspberry Pi

Introduction: Modify the Capability of Your Sound Card in Raspberry Pi

About: Systems Administrator and Software Programmer.


In my Test Sound Card and Speaker instructable, I ran the program speaker-test to send digital sound to the sound card driver. The speaker-test program needed to call ALSA program. The ALSA program has a component called Plugin(s). Plugin is the heart of ALSA.

In this instructable, I will swap the speaker channel so that the Left Speaker will output the sound "FRONT RIGHT" and Right Speaker will output the sound "FRONT LEFT". I will NOT swap any speaker wire to achieve this. I will use an ALSA plugin.

This is not useful in itself. It is just a way for me to learn ALSA plugin.


This instructable will cover the following:

  • Create a ALSA Virtual Device by using a type of ALSA plugin to swap the speaker channel.
  • Use ALSA utilities to test sound card and sound device

This instructables will NOT cover the following

  • PulseAudio
  • OSS


My Raspberry Pi:

  • Raspberry Pi 2
  • Rasbian based on Debian Version 8.0 (a.k.a Jessie)
  • Advanced Linux Sound Architecture Driver Version k4.1.10-v7+
  • Pulse Audio and OSS are NOT installed
  • 2 speakers connected to Raspberry Pi's audio/video 3.5mm socket.

Step 1: Test Sound Card and 2XSpeakers

Step 2: Understand ALSA "Physical" Device and ALSA Virtual Device

An ALSA device refers to a specific capability of an ALSA Card. Therefore
an ALSA Card will have one or more ALSA device (to send sound) and may have another ALSA device (to receive sound) and another ALSA Device for some other capability.

ALSA created another concept called ALSA Virtual Device. ALSA Virtual Device is similar to ALSA Device in that it provides a capability to the ALSA Card. From now on, I will not use the term ALSA Device. Instead I will use the term ALSA "Physical" Device so as to be clear.

The main differences are:

  1. ALSA "Physicai" Device has an underlying physical device while the ALSA Virtual Device has none.
  2. ALSA "Physical" has a hardware address (0,0) or an alias name or both while ALSA Virtual Device has only an alias name.

Plugins are used to create ALSA virtual devices. Virtual Devices can be used like normal hardware devices but cause extra processing of the sound stream to take place.

Step 3: List the Auto-Built Virtual Devices of the Raspberry Pi

Without us lifting a finger, ALSA will auto-build a couple of virtual devices.

List all the ALSA "physical" devices and ALSA virtual devices.

Open terminal emulator:

aplay -L

The following are ALSA virtual devices:







The following are ALSA "physical" devices:



These 2 devices are real because they are described as "Direct hardware device without any conversions".

Step 4: Use an ALSA Plugin Called "route" to Create an ALSA Virtual Device

The ALSA plugin "route" is not used in any of the auto-built virtual devices. Therefore, I will have to give instructions to ALSA to create a virtual device that is built on the route plugin.

Create a file in /home/pi/.asoundrc

Open terminal

cd /home/pi
vi .asoundrc

Alternatively, use any text editor to create the file.

Write the instructions as shown in the screen shot.

Save the file.

ALSA will read the instructions and create a virtual device.

Step 5: List the New ALSA Virtual Device

Open terminal

aplay -L

The virtual device called "speaker swap" appears in the list as shown in the screenshot.

Step 6: Test the Virtual Device

Open terminal

First do a normal speaker test using the ALSA physical device:

speaker-test -D"hw:0,0" -c2 -twav

Then do it with ALSA Virtual Device called "speaker_swap"

speaker-test -Dspeaker_swap -c2 -twav

The Right speaker should output words "FRONT RIGHT".

The Left speaker should output "FRONT LEFT".

Be the First to Share


    • Big and Small Contest

      Big and Small Contest
    • For the Home Contest

      For the Home Contest
    • Make It Bridge

      Make It Bridge



    6 years ago

    Nice Instructable. Can you please help me with that. I want to transfer mike input of 1 sound card to speaker output of other sound card like the listen to this device feature in windows.