I have a bit of a specific question:
Being a musician, I use Ubuntu for software monitoring and I would like to control my output master volume with my mouse wheel.
For this purpose, I currently use EasyStroke with the commands amixer -D pulse sset Master 5%+
(Mouse wheel up) and amixer -D pulse sset Master 5%-
(Mouse wheel down), which works fine.
The problem is that I use some programs that have a direct JACK output, such as Reaper, my DAW, and also some media players.
As long as the software uses the PulseAudio JACK Sink output, I can control the output volume via mouse wheel, but when the software does not use PulseAudio, it is directly connected to JACK and always at max volume.
If you refer to the screenshot: I am able to manipulate the master volume of the red-marked output (PulseAudio JACK Sink), but I actually need to access the one marked green to control all sound (system out).
Unfortunately, I can not control my ALSA master volume via amixer -q sset Master X
, because ALSA does not offer any controls for my only USB sound card.
Is there any way to control the JACK Output volume via terminal that I could replace my mouse button commands with?
Or alternatively, is there a way to add a PulseAudio input module to the right side of the JACK connections to connect Reaper and all other JACK software and route them through the PulseAudio JACK Sink? (PulseAudio JACK Source is only used for microphones and won't play back the input.)
Update July 21, 2019
From a professional music website for Linux:
There are two answers posted and this one is the most helpful:
The simplest solution then is to install JackMix:
"Ever struggled with a number of jack applications on your desktop everyone using its own master volume-fader but not one common place for all the volumes directly accessible?"
"The solution to your problem is JackMix, a mixer app for jack that looks exactly like the mixer you would use if you had to connect your analog equipment."
There are other applications for Jack which you can find listed here.
Original answer
I must confess to be musically-challenged but I think this script is where you are heading:
UPDATE 1
Just so I can give a quick explanation before a longer write up.
Even If PCM is not available (not just invisible in amixer) then we can still use PulseAudio to manage JACK because dbus will discover it.
Before anything else make sure you have the kernel modules loaded for your usb sound card with:
sudo modprobe snd-usb-audio
because this might be why your sound card controls are not showing up in amixer. Just to confirm please execute
aplay -l
andaplay -L
and post the output of these two commands.Next, we start by installing the corresponding pulseaudio packages:
sudo apt-get update && sudo apt-get install pulseaudio-module-jack
and then loading its corresponding module:
pactl load-module module-jack-sink channels=2
and finally setting the default sink to JACK
pacmd set-default-sink jack_out
As far as
sudo pactl load-module module-alsa-sink control=PCM
, this line enables pulseaudio to create a new sink-source that handles the pulse code modulation volume level at the ALSA API sound card level. OP's sound card has to be capable of converting the digital audio stream to an analog one through pulse modulation, as there is audio coming out of the system and through the speakers.You should first add a sink that controls the pcm device as an output with:
sudo pactl load-module module-alsa-sink control=PCM
then (just to double-check, see if you see the new output visible through the
pavucontrol
i.e. pulseaudio volume control GUI)you can control PCM sink output volume directly with
pactl set-sink-volume [pcm-sink-name likely something along the lines of alsa.default] 50%
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
is the helpful command here. The actual card name will be displayed after
CARD=
and the device name (number) afterDEV=
.We can test the device with
Now we create a new
softvol
device by addingto
~/.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
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: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.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
whilejackd
is not running and then usesudo alsactl store
to save the Master-volume state. Otherwise, a sound must be played throughsoftvol
after each reboot for the volume control to work.