3
votes

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?

2

2 Answers

2
votes

ALSA has no such function.

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

2
votes

You can via amixer:

amixer cset name='Headphone Playback Volume' 98%,100%

To get the name value - check alsamixer, appending 'Playback Volume' to each.

And via alsamixer:

Keyboard z is left channel decrease.

q is left increase.

and

c is right decrease.

e is right increase