Based on this example
we can solve the problem.
If your sound card can't control the volume on the hardware side or the driver
doesn't support this feature of your sound card, a possible workaround is to
define a new virtual pcm device in the ~/.asoundrc
file, which controls the volume
on the software side.
First we need to know the name of our soundcard, thus
aplay -L
is the helpful command here. The actual card name will be displayed after CARD=
and the device name (number) after DEV=
.
We can test the device with
speaker-test -D <card name> -c <channel count> -twav
Now we create a new softvol
device by adding
pcm.softvol {
type softvol
slave {
pcm "<card name>,<device name>"
}
control {
name "<control name>"
card "<card name>"
}
}
to ~/.asoundrc
. (If the file doesn't exist, we have to create the file)
In this case should be Master
, please see additional information on control names in the link above.
Now we test the new device with
speaker-test -D softvol -c <channel count> -twav
Open alsamixer, you should see the new control Master
now and should be able to change the volume using alsamixer.
It may be necessary to additionally set the device as default in /etc/asound.conf
with:
pcm.!default {
type hw
card <card name>
}
ctl.!default {
type hw
card <card name>
}
Note that this is different from the suggestion in the link above, but that's what OP reported to work.
Now we need to set Jack interface device to softvol
and can use e.g.
amixer -q sset Master 5%+
amixer -q sset Master 5%-
amixer -q sset Master 50%
to increase or decrease the output volume by 5% respectively or set to 50%, fixed.
Amixer needs to "open" the device the first time before the Master volume commands are accessible. Start a sound-test with speaker-test -D softvol -c <channel count> -twav
while jackd
is not running and then use sudo alsactl store
to save the Master-volume state. Otherwise, a sound must be played through softvol
after each reboot for the volume control to work.
Best Answer
I managed to do it, but changes revert after rebooting. (Update: This can be worked around; see the bottom of this post.)
I did it via a GUI in python called HDA Analyzer that can be fetched and used from the ALSA website like the following:
wget -O run.py http://www.alsa-project.org/hda-analyzer.py
sudo python run.py
(Their page doesn't saysudo
, but if you don't do it withsudo
, it will download the scripts but fail to run them and complain about privileges.)Now this will make the GUI start, but its usage is not explained, and it's not exactly newbie-friendly. So to make life easier I'll explain how I did it. In my case, it was a matter of two clicks; the tricky part was locating exactly what needs to be clicked.
(Note: You may explore all the nodes one by one, but don't modify anything you don't understand. Any modification (e.g. ticking a checkbox) becomes effective immediately; there's no apply button.)
The list contains many nodes called
Node[0x##]
followed by any ofAUD_OUT
,AUD_IN
,AUD_MIX
,PIN
andVENDOR
. The only ones you have to look in are thePIN
ones.There are multiple types of PIN nodes; the type we want will fill the whole window with panels/control groups (It helps to stretch or maximize the window), as in this screenshot. (The site prevented me from inserting the image inline, sorry.)
Inside the Config Default field, some nodes will have in the first line
Jack Connection: N/A
; we need the ones that sayJack Connection: Jack
as in the screenshot.To change a Line-In to an output jack, look until you find the node that says
Jack Type: Line In
. (And notice theJack Location2: Rear
andJack Color: Blue
.)Then, in the three checkboxes in the Widget Control group below, uncheck IN and check OUT.
Using the same way, you can assign any of the front or rear jacks to either input or output.
Now if you close the window, it will ask whether you want to revert changes. Saying yes reverts them immediately; saying no keeps them but only for this session.
If you want to keep your changes permanently, don't close HDA Analyzer yet. Instead, click "Exp" (Export) at the bottom-left and use Save As to write the python script to a file. Now copy that file to something like
/etc/hda-mods.py
and edit/etc/rc.local
as root (e.g. usinggksudo gedit /etc/rc.local
) and add the linepython /etc/hda-mods.py
right before theexit 0
line, then save it and reboot. Your changes should survive.