Balena Sound: How to force to HDMI audio?

How do I force the sound to HDMI (Pi 3 B+) audio regardless if the Raspberry sees an HDMI plugged in? I have the following settings under device configuration in BalenaCloud.

BALENA_HOST_CONFIG_hdmi_force_hotplug 1

BALENA_HOST_CONFIG_hdmi_drive 2

When I pulled the SD card I see config.txt has the following:
hdmi_drive=2
hdmi_force_hotplug=1
disable_splash=1
dtparam=i2c_arm=on
dtparam=spi=on
dtparam=audio=on
enable_uart=1
gpu_mem=16

Is there something else that needs adding? Audio is being forced out the analog 3.5 port even with these settings.

Hi,

Could you also try setting hdmi_force_edid_audio=1?

That seems to have done the trick, thank you!

So for the record, I’m using this HDMI audio splitter to feed audio via optical link to my stereo system. The audio coming from the analog 3.5mm port was weak and muddled. The digital audio is a much cleaner solution.

The config.txt file now reads as follows:

hdmi_drive=2
hdmi_force_edid_audio=1
hdmi_force_hotplug=1
disable_splash=1
dtparam=i2c_arm=on
dtparam=spi=on
dtparam=audio=on
enable_uart=1
gpu_mem=16

Thanks for coming back and confirming that hdmi_force_edid_audio=1 worked for you!

I finally got this working with a Raspberry Pi 3b but the audio timing is “spurty”, that is, the speed of the music speeds up and slows down, but the pitch is normal. Any ideas on that?

Hi, does the audio timing being spurty happens continuously or just when it starts up?

Hi, I want to make a similar project but I cant get the sound to come from the HDMI. With the above configs I get sound from the jack 3.5mm on the RPI 4.

Is there any other change I should make?

Thanks

Hey @mistformultimus, can you paste the contents of your config.txt? Are you using balenaSound or a custom application?

Sorry for the late late response. I am using the balenaSound.
This issue is resolved. I had to move back to the balenaOS v2.51, the latest at that time had a issue with the hdmi port.

Hi there - the current OS for the Pi4 is 2.65.0+rev1. I’ve just tested the HDMI audio and it’s working fine as long as my HDMI cable is in HDMI0 (the port nearest the power connector).

Phil

I tried with the 2.67+rev4 and is not working.
I will try with 2.65

In the 2.65 is not working for me…

Hi everyone, just to clarify on the HDMI output. You don’t need any config.txt or RESIN_CONFIG_/BALENA_CONFIG_ env var setting to get it to work if you are using either balenaSound or the audio block in one of your projects.

The easy way to do it is to use the AUDIO_OUTPUT environment variable and set it to RPI_HDMI0 as detailed in our docs here for balenaSound and here for the audio block. To double check I just confirmed this is working on balenaOS 2.65 and 2.67.

If you came here because you are working on an audio project that does not involve either (balenaSound or audio block) I do suggest you check out and use the audio block we built for just that purpose, to make using audio in balenaOS and containers easy.