Skip to content
Advertisement

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?

Advertisement

Answer

ALSA has no such function.

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

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement