Skip to content
This repository has been archived by the owner on Sep 10, 2024. It is now read-only.

Adding a New Sound Card

Rob Bultman edited this page Aug 13, 2020 · 3 revisions

Adding a new sound card to the system requires several steps including changes to the code and adding an entry into the database.

Note: these notes were developed assuming that the you want to use an audio hat instead of a USB audio device. See the Sound Cards wiki page for a list of cards that should work with the pi. Note that not all of these cards are currently supported by Raspberry Jam due to lack of availability of the cards to the creators of Raspberry Jam.

Any products listed in this guide were used because the author owns them or they are common. The Raspberry Jam project and it's creators have no relationship with any suppliers of anything.

Identifying the Overlay

Device tree overlays, or just overlays, are used in the Raspberry Pi to, among other things, provide support for hardware. The Raspberry Jam image is based on Raspbian Lite and already includes underlying support for many sound cards.

In most cases, the manufacturer of your card will tell you what overlay to use in order to support their card. In the case that they don't, read the next section to try to find one.

Finding the Overlay

In order to find the overlay for your sound card, you need to look for it's name in the /boot/overlays directory on your pi. There are lots of overlays there, so finding it can be daunting. If you ls the directory, you will notice that overlay file names can give a clue to what each supports.

As an example, let's find the overlay for the Fe Pi V1 audio card We will use ls and grep to find the overlay for this card. Since "pi" is probably a common string in the file names, let's try to find overlays containing "fe":

ls /boot/overlays | grep -i fe

This returns the following:

fe-pi-audio.dtbo

Since that is the only overlay found with "fe" in the name, and the name seems like it matches the Fe Pi card, that is probably it.

What happens if we look for an overlay for a different card, maybe one from a manufacturer with more card models? The HiFi Berry products fit this, so let's do a search for that:

pi@raspberry-jam:/boot/overlays $ ls /boot/overlays | grep hifi
hifiberry-amp.dtbo
hifiberry-dac.dtbo
hifiberry-dacplusadc.dtbo
hifiberry-dacplusadcpro.dtbo
hifiberry-dacplusdsp.dtbo
hifiberry-dacplus.dtbo
hifiberry-dacplushd.dtbo
hifiberry-digi.dtbo
hifiberry-digi-pro.dtbo

This search returned many more results. Try to match the overlay to your exact sound card.

Modifying the Database

TBD

Figuring Out the Alsa Mixer commands

Each card can have a unique set of controls in alsa. Some of these controls need to be initialized properly in order to pass audio (a mute control for example), and some controlled dynamically by the UI (all cards likely have an overall volume control). To see all of the controls for your card visually, you can run alsamixer. For a list of controls, run amixer.

In order to add a card, a sound card definition file needs to be created that initializes the card correctly and maps the UI controls to alsa controls.

The controls in the current UI intended to control the card are 'Input Level', 'Output Level', 'Input Select' (mic/line) and 'Mic Gain Boost'. All of those controls may not apply to all cards. In the future the UI may dynamically update to only show controls applicable to your card, but for now the same controls appear for all cards.

Creating a Sound Card Definition File

TBD

Modifying the Source Code

TBD