Update:
Audio is solved!
I have a totally working solution for the “garbled IP barker” that is a trivial fix, and does not require messing with the kernel.
Summary:
To eliminate the audio garbling on the IP address barker:
- Remove the
-d hw:CARD=Headphones
from each of the four lines in /opt/Sam_Dev/install/ip_feedback.sh.
- Edit the
set-default-sink
value in /etc/pulse/default.pa
and /etc/pulse/system.pa
to direct the default audio output to either HDMI or the audio jack.
Issue:
When the IP address is read through the headphone jack at initial startup, the sound is garbled as if it were being modulated with a 20Hz interfering signal, however normal espeak-ng output works fine.
Problem:
In the file /opt/Sam_Dev/install/ip_feedback.sh there are three lines:
su -c "espeak-ng -d hw:CARD=Headphones 'WiFi IP'" pi
su -c "espeak-ng -d hw:CARD=Headphones $IP_NUMBER" pi
su -c "espeak-ng -d hw:CARD=Headphones repeating " pi
su -c "espeak-ng -d hw:CARD=Headphones $IP_NUMBER" pi
at lines 40-43 in this file.
The particular part of these lines is the -d hw:CARD=Headphones
part. This was deliberately placed to force output through the audio jack regardless of what the normal system settings might be.
Solution / Workaround:
Remove the -d hw:CARD=Headphones
part of those three lines.
Viz.:
su -c "espeak-ng 'f'" pi
su -c "espeak-ng 'WiFi IP'" pi
su -c "espeak-ng $IP_NUMBER" pi
su -c "espeak-ng repeating " pi
su -c "espeak-ng $IP_NUMBER" pi
Note that the first line, (“f”), is not heard, but produces enough of a pause so that the entire second line’s phrase is spoken.
Removing the hard-coded redirection to the headphones resolves the garbled audio.
It has the unfortunate, (depending on the use-case), side effect of allowing the IP-address barker to use the system specified audio device, either HDMI or the audio jack.
Workaround:
In /etc/pulse
there are two configuration files: default.pa and system.pa. The very last line in each of the two files is set-default-sink x
where “x” is the device to use.
- “set-default-sink 0” supposedly means “automatic”, which I am assuming is set by the presence or absence of the particular audio setup line in /boot/config.txt - either HDMI or the audio jack.
- “set-default-sink 1” sets the default system audio output to the headphone jack.
“set-default-sink 2” sets the default system audio output to HDMI audio output.
Update:
It appears that the documentation lags behind the current functionality just a bit.
The correct mapping, (as best as I can figure out), is:
- “set-default-sink 0” sets the default system audio output to HDMI.
- “set-default-sink 1” sets the default system audio output to the headphone jack.
/Update
Note that, when set this way, any device that produces audio and does not specify a different audio output device will use whatever is set here.
Since the “default.pa” is, (supposedly) used for userland audio processes and system.pa is used for audio calls from the system itself, I set both to the same value. I have NOT tried setting them differently.
What I suspect is happening is that setting any “-d” value for espeak-ng writes directly to the output hardware device bypassing audio buffering and stream handling as setting it to either an HDMI device or the audio jack produces garbled sound.
Please experiment with this and tell me what you find.