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

Picture of Create a Volume Control for USB Sound Card in Raspberry Pi

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

Picture of 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

Picture of 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

Picture of 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.

Comments

TedM43 (author)2017-01-20

For copy/paste instead of typing it in. Formatting got clobber on the paste.

pcm.volume {

type softvol

slave {

pcm "surround51"

}

control {

name "Master"

card 0

}

hint {

show {

@func refer

name defaults.namehint.extended

}

description "Software Volume Control "

}

}

pcm.!default {

type plug# with a plug device, so rate is converted automatically

slave {

pcm "volume"

}

hint {

show {

@func refer

name defaults.namehint.extended

}

description "Playback in Surround 5.1 "

}

}

About This Instructable

4,886views

7favorites

Bio: Systems Administrator and Software Programmer.
More by mirza irwan osman:Install Modem USB Device in Raspberry PiMake the Volume Knob of Sound Blaster X-Fi Surround 5.1 Pro Sound Card Work in Raspberry PiCreate a Volume Control for USB Sound Card in Raspberry Pi
Add instructable to: