09-15-2021, 01:39 AM
(This post was last modified: 09-16-2021, 07:02 PM by Ladermeister.)
hint: If you already have a running setup and your audio from Hifiberrry is playing slowly / sounding like pitched down or like with a wrong sample rate, this can be caused by pigpiod. See my updated post with solution here:
SOLVED and rootcause found: Pitched down sound with OAP and Hifiberry Digi2 pro
This is a guide how to get a fresh install of OpenAuto Pro 13.2 to work with HifiBerry Digi2 Pro (and Digi+ Pro).
This guide has been tested by me on a fresh install.
After flashing the SD card, boot the system and enter your OAP key when requested to do so.
Exit OPA (via power button symbol on bottom in open auto pro) and follow the instructions on Raspberry desktop to set locals, password, network etc.
Run the command raspi-config from a console (local or ssh) and set I2C to on in „Interfaces“ (which basically only changes/adds an entry in /boot/config.txt so that it now contains the line: dtparam=i2c_arm=on)
Now we manually need to edit /boot/config.txt and enable I2S interface (digital Audio interface). I personally do that by using the editor „nano“ from a console: sudo nano /boot/config.txt
hint: CTRL-O and enter saves the file, CTRL-X closes the editor.
Add to boot/config.txt:
dtparam=i2s=on
So that /boot/config.txt now contains:
dtparam=i2c_arm=on
dtparam=i2s=on
Then, further below, we add
dtoverlay=hifiberry-digi-pro
So that this lower section of /boot.config.txt now should look like this:
dtparam=audio=off
dtoverlay=disable-bt
disable_splash=1
dtoverlay=vc4-fkms-v3d
dtoverlay=hifiberry-digi-pro
Safe and close the file.
Again, this is done by
CTRL-O and enter to save the file and CTRL-X to close the editor.
Now we enter in a console(ssh or locally): sudo reboot
After reboot we enter in console:
aplay -l
Which should now show us that Hifiberrry Digi+ pro is recognized, and also we should see no more entries from the onboard sound (because /boot/cfonfig.txt contains the line dtparam=audio=off which disables onboard audio):
pi@raspberrypi:~ $ aplay -l
**** Liste der Hardware-Geräte (PLAYBACK) ****
Karte 0: sndrpihifiberry [snd_rpi_hifiberry_digi], Gerät 0: HiFiBerry Digi+ Pro HiFi wm8804-spdif-0 [HiFiBerry Digi+ Pro HiFi wm8804-spdif-0]
Sub-Geräte: 0/1
Sub-Gerät #0: subdevice #0
Then we enter the command
pacmd list-sinks | grep -e 'name:' -e 'index:'
That should list us the audio sinks that pulseaudio creates:
pi@raspberrypi:~ $ pacmd list-sinks | grep -e 'name:' -e 'index:'
index: 0
name: alsa_output.platform-soc_sound.iec958-stereo
* index: 1
name: equalizer_sink
index: 2
name: equalizer_sink.echo-cancel
What do we see here?
alsa_output.platform-soc_sound.iec958-stereo is the stereo sink to transport sound to HiFiBerry
equalizer_sink is an audio sink that we actually want to play music from OAP to, because equalizer_sink allows us to modify sound by equalizer settings. The output of that modified audio will then be sent to the sink alsa_output.platform-soc_sound.iec958-stereo. Pulseaudio does that on its own.
equalizer_sink.echo-cancel is used to modify the audio stream further by cancelling out echo, e.g. when using a microphone for hands-free phone calls (the microphone picks up the audio from the spreakers and equalizer_sink.echo-cancel removes that digitally).
So for now we are set good with our three audio sinks.
But music cannot play yet, because the Raspbian system does not yet have the right settings.
For that we need to run pavucontrol from a console, which will open a settings window. To do so, we first exit OpenAuto Pro to Raspian Desktop.
Now we open a console and enter the command:
pavucontrol
A Window opens, and in the tabs on top we go to the one on the right called „Configuration“.
Might be optional:
(In the drop down menu for Internal Audio we select:
OFF)
NOT optional:
Then we open the drop down menu again and select:
Digital Stereo (IEC958)-Output
Now we can close the window.
Now the audio should already be redirected to pulseaudio and our HifiBerry board, but the Hifiberrry board is set do SPDIF by default and we need to set it to AIF.
To do so, we go to
Start-Menu (Raspberry symbol in tastbar)
—>Settings
—>Audio device settings
In the window that opens now, the soundcard called
„snd_rpi_hifiberry_digi(Alsa mixer)“
should already be selected, because in our example it’s the only one available. If you have additional sound cards, like additional USB sound cards, another one might be selected, then simply change to sound card: snd_rpi_hifiberry_digi(Alsa mixer).
You will then find the button „select elements“ on the bottom left side, press that and select „Tx Source“.
Now set Tx source to AIF.
Now press Close and then OK to close the settings window.
Now we need to tell the equalizer module to which sink it should send the audio stream.
We do that by editing /home/pi/.config/pulse/default.pa :
sudo nano /home/pi/.config/pulse/default.pa
Now we look for the Equalizer section that begins with
### Equalizer module
You can look around line 60 (in my case) or search in nano editor for equalizer by hitting CTRL+W and entering the phrase you want to search for (and confirm with enter).
To see which line you are in when using nano editor you can press CTRL+C.
The equalizer section needs to be modified so that it looks like this (THREE lines, and basically we only add
master=alsa_output.platform-soc_sound.iec958-stereo
to the end of second line):
### Equalizer module
load-module module-dbus-protocol
load-module module-ladspa-sink sink_name=equalizer_sink plugin=mbeq_1197 label=mbeq control=-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10 master=alsa_output.platform-soc_sound.iec958-stereo
set-default-sink equalizer_sink
Now we also need to modify at the end of the file (add ONE line that is not commented out):
### Make some devices default
#set-default-sink output
set-default-sink alsa_ouput.platform-soc_sound.iec958-stereo
#set-default-source input
Save the file with CTRL-O and enter and then press CTRL-X to close nano editor.
Now it is time for a reboot:
sudo reboot
I now had to do the steps with settings in pavucontrol again because for some reason it didn’t take the selection of Digital Stereo (IEC958)-Output, but after repeating that step and rebooting it worked perfectly - volume control works and equalizer works as well.
Audio output through HiFiBerry optical out now works flawlessly.
SOLVED and rootcause found: Pitched down sound with OAP and Hifiberry Digi2 pro
This is a guide how to get a fresh install of OpenAuto Pro 13.2 to work with HifiBerry Digi2 Pro (and Digi+ Pro).
This guide has been tested by me on a fresh install.
After flashing the SD card, boot the system and enter your OAP key when requested to do so.
Exit OPA (via power button symbol on bottom in open auto pro) and follow the instructions on Raspberry desktop to set locals, password, network etc.
Run the command raspi-config from a console (local or ssh) and set I2C to on in „Interfaces“ (which basically only changes/adds an entry in /boot/config.txt so that it now contains the line: dtparam=i2c_arm=on)
Now we manually need to edit /boot/config.txt and enable I2S interface (digital Audio interface). I personally do that by using the editor „nano“ from a console: sudo nano /boot/config.txt
hint: CTRL-O and enter saves the file, CTRL-X closes the editor.
Add to boot/config.txt:
dtparam=i2s=on
So that /boot/config.txt now contains:
dtparam=i2c_arm=on
dtparam=i2s=on
Then, further below, we add
dtoverlay=hifiberry-digi-pro
So that this lower section of /boot.config.txt now should look like this:
dtparam=audio=off
dtoverlay=disable-bt
disable_splash=1
dtoverlay=vc4-fkms-v3d
dtoverlay=hifiberry-digi-pro
Safe and close the file.
Again, this is done by
CTRL-O and enter to save the file and CTRL-X to close the editor.
Now we enter in a console(ssh or locally): sudo reboot
After reboot we enter in console:
aplay -l
Which should now show us that Hifiberrry Digi+ pro is recognized, and also we should see no more entries from the onboard sound (because /boot/cfonfig.txt contains the line dtparam=audio=off which disables onboard audio):
pi@raspberrypi:~ $ aplay -l
**** Liste der Hardware-Geräte (PLAYBACK) ****
Karte 0: sndrpihifiberry [snd_rpi_hifiberry_digi], Gerät 0: HiFiBerry Digi+ Pro HiFi wm8804-spdif-0 [HiFiBerry Digi+ Pro HiFi wm8804-spdif-0]
Sub-Geräte: 0/1
Sub-Gerät #0: subdevice #0
Then we enter the command
pacmd list-sinks | grep -e 'name:' -e 'index:'
That should list us the audio sinks that pulseaudio creates:
pi@raspberrypi:~ $ pacmd list-sinks | grep -e 'name:' -e 'index:'
index: 0
name: alsa_output.platform-soc_sound.iec958-stereo
* index: 1
name: equalizer_sink
index: 2
name: equalizer_sink.echo-cancel
What do we see here?
alsa_output.platform-soc_sound.iec958-stereo is the stereo sink to transport sound to HiFiBerry
equalizer_sink is an audio sink that we actually want to play music from OAP to, because equalizer_sink allows us to modify sound by equalizer settings. The output of that modified audio will then be sent to the sink alsa_output.platform-soc_sound.iec958-stereo. Pulseaudio does that on its own.
equalizer_sink.echo-cancel is used to modify the audio stream further by cancelling out echo, e.g. when using a microphone for hands-free phone calls (the microphone picks up the audio from the spreakers and equalizer_sink.echo-cancel removes that digitally).
So for now we are set good with our three audio sinks.
But music cannot play yet, because the Raspbian system does not yet have the right settings.
For that we need to run pavucontrol from a console, which will open a settings window. To do so, we first exit OpenAuto Pro to Raspian Desktop.
Now we open a console and enter the command:
pavucontrol
A Window opens, and in the tabs on top we go to the one on the right called „Configuration“.
Might be optional:
(In the drop down menu for Internal Audio we select:
OFF)
NOT optional:
Then we open the drop down menu again and select:
Digital Stereo (IEC958)-Output
Now we can close the window.
Now the audio should already be redirected to pulseaudio and our HifiBerry board, but the Hifiberrry board is set do SPDIF by default and we need to set it to AIF.
To do so, we go to
Start-Menu (Raspberry symbol in tastbar)
—>Settings
—>Audio device settings
In the window that opens now, the soundcard called
„snd_rpi_hifiberry_digi(Alsa mixer)“
should already be selected, because in our example it’s the only one available. If you have additional sound cards, like additional USB sound cards, another one might be selected, then simply change to sound card: snd_rpi_hifiberry_digi(Alsa mixer).
You will then find the button „select elements“ on the bottom left side, press that and select „Tx Source“.
Now set Tx source to AIF.
Now press Close and then OK to close the settings window.
Now we need to tell the equalizer module to which sink it should send the audio stream.
We do that by editing /home/pi/.config/pulse/default.pa :
sudo nano /home/pi/.config/pulse/default.pa
Now we look for the Equalizer section that begins with
### Equalizer module
You can look around line 60 (in my case) or search in nano editor for equalizer by hitting CTRL+W and entering the phrase you want to search for (and confirm with enter).
To see which line you are in when using nano editor you can press CTRL+C.
The equalizer section needs to be modified so that it looks like this (THREE lines, and basically we only add
master=alsa_output.platform-soc_sound.iec958-stereo
to the end of second line):
### Equalizer module
load-module module-dbus-protocol
load-module module-ladspa-sink sink_name=equalizer_sink plugin=mbeq_1197 label=mbeq control=-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10 master=alsa_output.platform-soc_sound.iec958-stereo
set-default-sink equalizer_sink
Now we also need to modify at the end of the file (add ONE line that is not commented out):
### Make some devices default
#set-default-sink output
set-default-sink alsa_ouput.platform-soc_sound.iec958-stereo
#set-default-source input
Save the file with CTRL-O and enter and then press CTRL-X to close nano editor.
Now it is time for a reboot:
sudo reboot
I now had to do the steps with settings in pavucontrol again because for some reason it didn’t take the selection of Digital Stereo (IEC958)-Output, but after repeating that step and rebooting it worked perfectly - volume control works and equalizer works as well.
Audio output through HiFiBerry optical out now works flawlessly.