USB Audio and RetroPie 3.4 for Better Sound on the Raspberry Pi 2

đź“… February 9, 2016
usbaudio1The Raspberry Pi 2 is a convenient miniature computer for a multitude of weekend projects, but its audio output quality is lackluster.

White noise, background hiss, low-volume, subdued bass, and missing trebles leave room for improvement — especially when using the Raspberry Pi with audio-enjoyment software, such as RetroPie and Kodi.

Is there a way to upgrade the Pi’s audio quality?

Yes! Using a small USB audio device that plugs into any of the Pi’s USB ports, audio can be rerouted to the USB audio device for improved audio quality.

This tutorial shows how to use the Plugable USB Audio Adapter
with a Raspberry Pi 2 Model B running RetroPie 3.4 to produce a boost in sound quality.

Note: Nobody sponsors this. Any links to Amazon are affiliate links to help readers locate the items and to help cover the time spent writing this article at no cost to readers.

About the Plugable USB Audio Adapter

The idea is to plug this device into a standard USB port and hear/record audio. It functions as a regular sound card. Keep in mind that the quality might not be on par with more expensive audio gear, but this inexpensive device provides far superior audio than the Pi’s built-in audio.

a

The Plugable USB Audio Adapter with back of packaging. No drivers needed. The Raspberry Pi 2 Model B running RetroPie 3.4 detects it upon boot.

a

Port-side of the adapter. There are two 3.5mm jacks. The red jack on the left connects a microphone to allow recording (not tested in this tutorial), and the green jack on the right provides line-level audio output for sound playback.

a

Not certain if this is by design or if it is a flaw with the product, but the USB plug on my adapter was slightly bent as seen in the image. It still works, but it causes the bulk of the adapter to bend downward enough to restrict it to a bottom USB port on the Pi. If plugged into a top USB port, it becomes difficult to plug any other USB device into the port immediately below.

This adapter has a black aluminum shell that feels somewhat sturdy.

 

“Is this compatible with Linux?”

Yes. Since RetroPie is Linux, compatibility is 100%. I have not experienced any incompatibility issues. It is also compatible with other operating systems and computers, not the Pi alone.

 

“What audio quality can be expected compared to the Pi’s audio?”

  • Louder sound output. No need to turn the volume up as much.
  • Stronger, deeper bass. Bass is almost missing with the Pi’s built-in audio.
  • High frequencies sound more distinct. Cymbals, glass, and trebles sound better.
  • More clarity.
  • Almost no noise. The Pi had a constant background noise (white noise) when playing sound. During moments of silence during the sound playback, the noise was distractingly audible. This adapter greatly reduces the noise. It does not eliminate it completely because faint noise can be heard if the volume on an amplifier is turned up to uncomfortable levels. However, the noise is practically in audible a normal listening levels.

Take note that sound quality also depends upon your speaker system and sound gear. While this adapter does improve the sound quality, if you are using cheap, tinny earphones, then you will probably not hear much of a difference. If you are using higher-quality headphones or speakers, then the sound difference will become noticeable.

Setting Up the Raspberry Pi 2 and the USB Audio

This tutorial assumes that you already have RetroPie 3.4 installed and running. There is no need to reinstall RetroPie. With the Pi turned off, simply plug the USB audio into any free USB port on the Pi.

I recommend using bottom right USB port. Due to the width of this device, it will cover the adjacent horizontal USB port making that port unusable. This leaves you with two free ports on the Pi.

Since my USB device had a bent USB connector, I choose the bottom USB port. If plugged in at the top, the bottom port became unusable due to the device covering it by bending downward and preventing another USB device from being plugged in below it.

Plugged In, but No Audio. Why?

Merely plugging in the USB audio device and turning on the Raspberry Pi will not produce audio through the USB audio. The Pi will still use its built-in audio. RetroPie must be configured to use USB audio instead.

Is the USB Audio Detected?

RetroPie will automatically register the USB device during boot. To test if RetroPie sees the device, go to the RetroPie terminal (either CTRL+ALT+F1 or ssh into RetroPie) and enter lsusb.

lsusb
a

lsusb shows what USB devices are connected. C-Media is the Plugable USB Audio Adapter.

This shows a list of all connected USB devices. What we are interested in is the C-Media Electronics, Inc. line. If visible, then that means the USB audio is connected, detected, and ready for use.

aplay

Next, enter aplay -l to see more detail about all detected audio devices.

aplay -l
a

aplay -l shows all available audio cards for playback.

This shows two “sound cards” connected to the operating system. Card 0 should always be the built-in Pi sound hardware (bcm2835), and Card 1 is the USB audio.

We can see that the Plugable USB audio device is identified as Card 1: [USB Audio Device]. So far, so good. Now, we need to edit a configuration file that tells the Pi to use this instead of the built-in audio.

  • Card 0 – bcm2835 (Built-in Pi Audio)
  • Card 1 – Plugable USB Audio Device

Edit /etc/asound.conf

For RetroPie 3.4 (Raspian Jessie), we must edit the /etc/asound.conf file. Previous versions of RetroPie required a different method involving /etc/modprobe.d/alsa-base.conf, but that does not work with RetroPie 3.4.

In the RetroPie terminal, open the config file:

sudo nano /etc/asound.conf

The file might be empty, and that is okay. Add these lines:

pcm.!default {
 type hw card 1
}
ctl.!default {
 type hw card 1
}

Simply put, this tells ALSA (Advanced Linux Sound Architecture) to use the USB audio instead of the built-in audio. Save and exit.

Restart

Now, restart RetroPie. Choosing “Restart System” from the EmulationStation “Quit” menu allows for proper shutdown.

The pi should now automatically detect and use the USB audio. Pick a game from EmulationStation and play. Be sure to remember to plug your speaker system into the USB audio’s green line-out jack using a 3.5mm plug and to turn up the volume for your speakers. It’s easy to forget this obvious step.

Adjusting Volume Output

You might want to adjust the mixer settings to your liking. In EmulationStation, enter the RetroPie settings, and choose “Configure Audio.” Then, choose “Mixer.” This opens AlsaMixer.

a

AlsaMixer. Adjusts the volume output.

From here, you can control the volume of the USB audio. F6 lets you select which sound device to edit. In this case, I have Speaker (the green line out jack on the adapter) set to 81, which provides adequate line-level output without distortion. The Mic is set to 0 since it is not needed. Gain is set to 0 since, for my configuration, the volume is comfortable at these levels.

Once fine tuning is complete, the Pi should play audio through the USB audio adapter. For me, everything just works, and I have not experienced any issues.

Conclusion

For such an inexpensive device, the Plugable USB Audio Adapter works wonders by greatly enhancing the sound quality of the Raspberry Pi.

Many USB audio devices similar to the Plugable are available, so, in theory, they should work too. I have been more than happy with the Plugable, and I would definitely recommend this to aspiring Pi enthusiasts who seek better quality sound output. This is a device that certainly delivers.

, , ,

  1. Leave a comment

Leave a comment