I have an I2S audio device working with my Rock PI 4 right now. But I cannot control the volume in any way I’m used to (I’m porting a project from an RPi 4 system).
I’ve tried alsamixer and no device settings seem to affect the output volume.
I’ve tried amixer from the command line (amixer sset PCM 20%)
Thanks for the idea. I’ve tried things like this and while they devices show up, they don’t do anything. That is, I can do
amixer sget PCM
amixer sset PCM 50%
and see the results change in the text returned, but it doesn’t affect anything on the audio volume.
What I did get to work was this:
pactl set-sink-input-volume 7 10%
That is, it’s using PulseAudio (which is fine with me… I don’t care HOW I play sounds so long as I can and can control the volume). I’m playing notification sounds, only.
All was great! But then I rebooted and now the pactl stuff doesn’t work. No idea why (but happy for ideas!)
pactl list sink-inputs
shows nothing, now, where-as it showed one device (numbered 7, oddly) before.
So I’m back to square one; why on earth this would go away after rebooting I have no idea!
The weird thing about softvols is you have to play them first or they don’t exist.
So you need to change the above to work with the i2s index and pcm.
Just aplay -Darray gain or whatever you call the softvol ctrl+c
Then set you softvol via alsamixer or amixer
Then aplay again.
Dunno if you did it that way as having to play first to initialise the softvol has thrown me before.
Thanks and yep, I tried that, but it’s not happy. I have a new device but it’s not controlling anything. It’s like the “Master” device I had, originally.
pcm.soft_vol {
type softvol
slave {
pcm “default”
}
control {
name “SoftMaster”
card 1
}
}
pi@master:~$ aplay -Dsoft_vol beep.wav
Playing WAVE ‘beep.wav’ : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
aplay: set_params:1270: Broken configuration for this PCM: no configurations available
pi@master:~$ aplay -Ddefault /opt/code/pi_orchestration/lib/tones/beep.wav
Works just perfectly (but no volume control)!
Crazy that I had things working via pulseaudio and now that’s broken, too. I’ve tried removing the /etc/asound.conf file (also .asoundrc as I tried that, too) but that changes nothing, as well.
I even tried the asound.conf file from my RPi but no go on that, too. Really odd…
aplay -Dpulse works (plays through the pulseaudio driver).
pi@master:~$ aplay -L
default
Playback/recording through the PulseAudio sound server
null
Discard all samples (playback) or generate zero samples (capture)
pulse
PulseAudio Sound Server
soft_vol
sysdefault:CARD=sndrpihifiberry
snd_rpi_hifiberry_dac,
Default Audio Device
…
I’ve been looking over the Alsa docs to try and configure the soft_vol to work with the pulse audio driver and can’t make that work. Nothing I do will play a sound except if I play through -Dpulse.
I’m sure I’m confused and likely merging multiple things that should not be, but this is how the system booted up. I’m OK using anything that will give me I2S audio output and volume control! But I think things are screwed up with multiple drivers and I just haven’t been able to unravel it, yet.
# Use PulseAudio by default
pcm.!default {
type pulse
fallback "sysdefault"
hint {
show on
description "Default ALSA Output (currently PulseAudio Sound Server)"
}
}
ctl.!default {
type pulse
fallback "sysdefault"
}
# vim:set ft=alsaconf:
Then reboot or restart pulse audio and pacmd set the default sink/source
Thanks for sticking with me on all of this. I’ve learned a bit more about how this is all supposed to work and have a solution that’s working for me, now. I never could get the amixer stuff working and I think I know (partially) why.
Seems the pulseaudio server has issues when started for a user at system startup (in rc.local for example) and then the user wants to use it from a login shell.
That is, in rc.local I have this:
sudo -i -u pi -- sh -c "aplay -D Pulse /var/tones/beep.wav"
Works, great! Plays a beep and the pulseaudio server is running under user “pi.”
But if I then log in (ssh) to my system and do
aplay -D Pulse /var/tones/beep.wav
Nothing happens. Likewise, if I try to use the pa* controls (pactl, pacmd, etc) they all fail. I have to do
sudo -i -u pi -- sh -c "aplay -D Pulse /var/tones/beep.wav"
or sudo -i -u pi -- sh -c "pactl set-sink-volume 2 10%"
When I do that, all is fine. Works as expected. So that’s simply what I’m going to do. I have all of this scripted, anyway, so it’s easy for me to change my “beep.sh” script to use sudo. I still don’t know why this is an issue (if I “sudu -u pi” then user pi should be able to use it, I would think. But for another day… I have other things I need to get working, then I can come back and optimize.)
I’m not starting any services, outside of what’s being done by the standard install of the sound system, and doing nothing as root.
I want to play a sound when my system completes booting and I to an “aplay” in rc.local (which I have done for years). I do it with sudo -u pi so it’s not running as root, but as user pi (and it is if I look at the process). But the fact that I did a sudo means that I must then ALWAYS use sudo -u pi to play sounds or adjust the pulseaudio system.
If I do NOT play the sound in rc.local, then I can use the pi login from the command line to do so. But I need to play the startup sound