Introduction: Create a Volume Control for USB Sound Card in Raspberry Pi

About: Systems Administrator and Software Programmer.

Introduction

After installing the USB Sound Card, I turned the volume knob and i had no effect on the audio level. On further investigation, I discovered that although this particular sound card has a hardware volume contol, the Sound Blaster X-Fi Surround 5.1 Pro sound card does NOT provide any hardware mixer. A solution to this problem is to create a "software" volume control.

Scope

This instructable will cover the following:

  • Discover whether the sound card provide hardware mixing.
  • Create a software volume control for UNSUPPORTED the hardware mixer of the sound card
  • Use ALSA utilities to test sound card and sound device

This instructables will NOT cover the following

  • PulseAudio
  • Open Sound System (OSS)

Specifications

My Raspberry Pi:

  • Raspberry Pi 2 model Raspbian 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 Whether Sound Card and Speakers Work

Step 2: Check Whether ALSA Creatd a Hardware Volume Control

Open terminal:

alsamixer

There is no volume control as shown in the screenshot. That means hardware mixer is not supported by the sound card. Bummer!

Step 3: Create a Software Volume Control

ALSA provides a "software" volume control in our case.

Open terminal

cd

To simplify this step, start with a fresh blank .asoundrc file. Backup the current .asoundrc file if you have them

mv .asoundrc asoundrc.bk
vi .asoundrc

Enter the lines as shown in the screenshot.

Save the file.

Step 4: Test Software Volume Control

Open terminal:

speaker-test -twav -c2

Open another terminal:

alsamixer

Refer to screenshot. A new bar called "Master" appears. Use the "UP" and "Down" Arrow key to control the volume.

The loudness of the sound should vary.

This "software" volume control only works in software. The volume knob on my sound card is not able to control the "software" volume control.