Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting channel volume in ALSA

My app plays raw PCM audio data through various channels using ALSA. I'm allocating a new audio channel by using snd_pcm_open(), then setting the PCM format via the snd_pcm_hw_params_xxx() calls and finally feeding raw PCM audio data to ALSA by using the snd_pcm_writei() API.

This is all working fine so far but I haven't found any way to tell ALSA to reduce the volume of a sound channel allocated in the way outlined above. Of course, I could just manually apply volume scaling to the PCM data before sending it to ALSA via snd_pcm_writei() but is there really no way to have ALSA do this on its own?

like image 723
Andreas Avatar asked Dec 21 '25 23:12

Andreas


1 Answers

ALSA has no such function.

You have to do the scaling yourself, or use a sound server like PulseAudio.

like image 59
CL. Avatar answered Dec 23 '25 14:12

CL.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!