Those DAC exist in several versions :
Raspberry Pi A+, B+, 2 and 3
DAC+ Standard RCA
DAC+ Standard Phone
Raspberry Pi A et B
DAC Standard version with RCA connectors
The characteristics of the different cards can be compared on hifiberry.com. DAC+ cards can be connected directly to the GPIO of the Pi. Pins not used by the DAC can be reused for other uses, in which case additional pins must be soldered to the DAC+ card.
Below is the wiring diagram of a DAC+ HifiBerry :
On recalbox, you just need to add the right DTB in
/boot/config.txt, with the right parameters (depending on your card) :
Then you have to select the default sound card : just edit
/etc/asound.conf (create the file if not already present) with the following content :
type hw card 0
type hw card 0
Reboot your Pi.
Now you should hear the sound through your HiFiBerry card.
ALSA sound cards (and this is the case of HiFiBerry) can be controlled by Alsamixer, which is a graphical user interface, whereas Amixer works in text mode, especially for scripts.
Since alsa-utils is installed on Recalbox, HifiBerry will work without additional utilities.
amixer command you will get a text version of the various DAC settings. The best way to change the volume is to change the Overall volume. Its name may differ depending on the card: PCM, Digital, Master, just try one of them.
The following commands allow you to change the volume via the terminal :
amixer sset ‘Master’ -- 90% (not recommended because the scale is logarithmic)
amixer sset ‘Master’ -- -3dB (in decibels, recommended setting)
amixer sset ‘Master’ – 2000 (unité empirique, déconseillé)
Here is an example in python to manage the volume.
First, import the sub-process command :
from subprocess import callcall(["amixer", "sset", "Digital", "--", str(YourDesiredVolume)+"dB"])
This script can especially be used to change the volume by using the GPIO
Below are some available commands with amixer :
amixer sset 'PCM' 70% (percentage)
amixer sset 'Master' 3dB (Decibel)
amixer sset 'Mic' 4 (hardware values)
amixer sset 'PCM' 10%+ (increase in the current value, the unit can be % or dB)
amixer sset 'Line' cap (Recording on/off: cap, nocap)
amixer sset 'Mic' mute (Playback on/off: mute, unmute)
amixer sset 'Master' off (On/Off: on/off)
amixer sset 'Mic Select' 'Mic1' (device name)