I'm trying to write a script that automatically changes the playback/capture audio levels based on the device that is connected.

I'm using a MAYA44 USB+ sound with 4 ch in/out.

Thanks to a similar question here: https://askubuntu.com/questions/97936/terminal-command-to-set-audio-volume

I learned to use the following command:

amixer -c 2 sset Line,1 50%

The problem I have is that it seems like the capture control shares the same name as a playback control: Line

enter image description here


amixer -c 2 sset Line 50%

Changes the values of BOTH controls.

As mentioned above, I'm writing a script to do this automatically so I don't want to manually go into alsamixer and do it manually.

Is there a way to rename the controls so that there isn't a naming clash? Otherwise, is there some sore of suffix or prefix I can add to the 'Line' value to specify that I want to affect the CAPTURE device? Would using pulse audio in some way be another option?

Basically, how I can change the capture control values without affecting the playback values?

Thanks in advance!


I asked this same question here: https://raspberrypi.stackexchange.com/questions/50596/how-to-change-audio-levels-of-sound-card-with-same-control-names

and got the answer from CL.

Use amixer -c2 controls to list all the low-level controls.

Then you can use amixer -c2 cset .. to select specific controls by their unique ID number.

Running the command on my device:

>amixer -c 2 controls
numid=7,iface=MIXER,name='Master Playback Switch'
numid=8,iface=MIXER,name='Master Playback Volume'
numid=3,iface=MIXER,name='Line Playback Switch'
numid=5,iface=MIXER,name='Line Playback Switch',index=1
numid=4,iface=MIXER,name='Line Playback Volume'
numid=6,iface=MIXER,name='Line Playback Volume',index=1
numid=9,iface=MIXER,name='Line Capture Switch'
numid=10,iface=MIXER,name='Line Capture Volume'
numid=2,iface=PCM,name='Capture Channel Map'
numid=1,iface=PCM,name='Playback Channel Map'

I had initially tried this but I couldn't get it to work. Only once I tinkered with it a bit more did I realize that the ID was in fact 'numid=10' and not simply the integer 10.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.