Hi everyone,
I’m facing an issue playing audio with my verdin imx8m-plus.
Currently I have the following setup:
I have an application running on a container
(in the dockerfile I install alsa-utils libasound2 libasound2-plugins)
and copying the following asound.conf file in /etc/asound.conf
then I run the container passing ALSA_CARD: audiohdmi
and play audio via aplay ./path/to/file.wav
This works but if I run the same audio (for example) one time per second, the volume is unstable (sometimes is high, sometime is low).
I’m trying to control the volume of the sound card using amixer.
I’m not able to control the volume of the sound card.
running amixer scontrols and amixer scontents gives me empty output.
running alsamixer -c 0 gives me the following:
Hi, I’m the Toradex AI Assistant. The Toradex Support team will follow up with you shortly!
Did you like my answer?
Based on the context provided, here are some steps you can take to address the issue of unstable audio volume and the inability to control the volume using amixer on the Verdin iMX8M Plus:
Verify ALSA Configuration:
Double-check your asound.conf file to ensure it is correctly configured for your specific audio hardware. The dmix plugin is used for mixing multiple audio streams, but ensure that it is properly set up for your use case.
Audio Card Recognition:
The empty outputs from amixer suggest that the sound card might not be properly recognized. Ensure that the ALSA_CARD environment variable is correctly set to the appropriate audio card. You might need to verify the actual card name or number using aplay -l to list all sound cards and devices.
Driver Compatibility:
Check if the necessary audio drivers are installed and loaded correctly for the Verdin iMX8M Plus. There might be a compatibility issue with the drivers that could affect volume control.
Test Outside Container:
Try running the audio playback and volume control commands outside of the Docker container to see if the issue persists. This can help determine if the problem is related to the container environment.
Alternative Audio Management Tools:
Consider using other audio management tools or libraries that might offer better control over audio playback and volume stabilization. For example, PulseAudio or PipeWire might provide more robust solutions for managing audio in a containerized environment.
Hardware and Software Updates:
Ensure that your system is up to date with the latest firmware and software updates from Toradex, as these might include fixes or improvements for audio handling on the Verdin iMX8M Plus.
By following these steps, you should be able to better diagnose and potentially resolve the issue with unstable audio volume and lack of volume control.
Please, also check if these links can help you solve your problem:
I tested this here and got to the following conclusions:
The HDMI audio does not provide a volume interface for alsamixer. This is likely due to the fact that digital audio is being transmitted and the volume control is expected on the display.
The audio from the display was at a consistent volume when playing the same file repeatedly.
How are you playing the audio one time per second?
Maybe we are doing something slightly different here.
Hello @bruno.tx
I confirm that with your asound.conf I can see the control on alsamixer as in your picture.
I’m able to change the volume with both the alsamixer UI and amixer set Master 100% command.
So, basically, the volume can be controlled.
I try to describe with different words what is the issue, with a simple scenario:
if you play a sound, everything is ok (the volume is what it should be)
if you use a script to play the same short sound 3 times every 1" (1 second), the volume is wrong. Most of the time the volume of the first sound is higher (or lower) than the others.
And this is frustrating.
This is the bash script to play the spound (from a container with alsa installed inside):
for i in {1..3}
do
aplay ./public/sounds/ding.wav &
sleep 1
done
I was able to reproduce a similar issue.
The first time the audio is played, it seems that the HDMI audio has not initialized yet, so the beginning of the file gets cut.
This makes it seem that the sound is quieter, but we are just getting the quieter part of the audio.
The cause here is not clear, and seems to be present in other systems.
It may be worth testing with pulseaudio as well.
A workaround that I tested was to play a silent audio file before playing the actual file:
aplay -d 1 silence_10s.wav && aplay ding.wav
Adding a silent part at the start of the file should also do the trick.
Hi @bruno.tx
based on my tests I can say that playing a silent sound has an impact on solving the issue.
But the situation is not 100% clear.
I need some further investigation, but it sounds strange to me that Ubuntu suffer of such a weird behavior.
But it seems so.
This seems to be an Alsa issue. Here you can see a similar problem with a desktop application.
It is possible that the problem can be avoided by using pulseaudio instead.
From some limited testing, using pulseaudio with chromium does not appear to be the simplest thing to do, at least when starting from our chromium container.
Do you also have this audio playback issue when playing audios from Chromium?
If yes, we can look into the possibility of using pulseaudio as an alternative.
Upon further investigation the chromium package we provide is built with a hard dependency to alsa.
Using it with pulseaudio will require chromium to be rebuilt with support for pulseaudio.
Therefore, I would recommend that you use the silent audio workaround if possible.