Closed jsgalarraga closed 1 year ago
Hi,
First of all, thanks for your work on this library and sorry for the ping here since the issue is not with the python library itself. I'm working on C program that uses directly the ALSA library, and I'm trying to set the volume to a specific percentage value. I've tried to follow your implementation but I'm having one issue, when I set the element name to "Master" (as done here) I encounter the following error: snd_mixer_selem_get_playback_volume_range: Assertion 'elem' failed. However if I set element name to "PCM" the volume range retrieval works fine, but I'm not able to set the percentage properly...
From what I remember, mixers default to setting/getting the raw volume. With amixer -c x scontents you should be able to see the limits.
What is a bit weird is that amixer shows a card which does have a ‘Master’ control, maybe there are multiple cards and you are selecting the wrong one in addition to th eproblem above?
Hope this helps,
I finally figured out my problem. I was executing my script with sudo
:
sudo ./audio
However the behavior is not the same as if you run it without sudo
, so the solution was to run it just like:
./audio
The reason why I was running with sudo was because I'm also accessing to the GPIO in the same program, which requires root privileges
Glad that you figured it out. If you need to run your program as root, maybe you need to add root
to the audio
group.
I ended up changing the program ownership and permissions, and worked great
sudo chown root:root audio
sudo chmod 4755 audio
./audio
First of all, thanks for your work on this library and sorry for the ping here since the issue is not with the python library itself.
I'm working on C program that uses directly the ALSA library, and I'm trying to set the volume to a specific percentage value. I've tried to follow your implementation but I'm having one issue, when I set the element name to
"Master"
(as done here) I encounter the following error:snd_mixer_selem_get_playback_volume_range: Assertion 'elem' failed
. However if I set element name to"PCM"
the volume range retrieval works fine, but I'm not able to set the percentage properly...I'm working on a Raspberry Pi 4.
Also when I run
amixer scontrols
in the terminal the output is:Here's the code that I'm using:
I'm using the following command to compile it
gcc -o audio audio.c -lasound