When I press the mute key on my keyboard, both the Alsa master channel and the PulseAudio master channel get muted, pressing it again only unmutes the alsa master channel, the pulseaudio master channel keeps muted. Result: no sound.
How do I fix that?
PulseAudio – Mute Key Mutes Alsa and PulseAudio but Unmutes Only Alsa
alsapulseaudio
Related Solutions
Assigning a LADSPA filter to a single audio channel
We can do this with fine tuning the pulseaudio LADSPA sink module. This module loads a sink where any LADSP plugin will be applied to. It is the usual case to apply a filter to all channels but we can also define a single channel to assign a filter to by remapping and then combining channels.
The following Pulse Audio commands are involved:
Get a valid
sink_name
andchannel_map
:pacmd list-sinks
Load a LADSPA filter:
load-module module-ladspa-sink sink_name=ladspa_out master=alsa_out plugin=<filer> label=<label> control=<control>
Create a new remapped sink:
load-module remap-sink sink_name=<name> master=<sink> channels=<n> master_channel_map=<list> channel_map=<list>
Create a new combined sink:
pacmd load-module module-combine-sink sink_name=<name> sink_properties=device.description=<displayed_name> slaves=<list_of_n_sinks> channels=<n>
To get the desired effect we need to load the LADSPA filter to create a ladspa_out-sink with filtered audio from a given sink. Then we need to create separate, named sinks for each audio channel. Channels where we wish the filter to be applied need the ladspa_out-sink as master, channels we need to be clean need the unfiltered sink as master. Lastly we combine the separate channels again to give us new combined sink.
Example for two channels
pacmd load-module module-ladspa-sink sink_name=ladspa_out master=alsa_output.pci-0000_00_14.2.analog-stereo plugin=bandpass_iir_1892 label=bandpass_iir control=660.0,440.0,2
A new sink ladspa_out
is created using bandpass_iir filter with given controls applied to the audio signal from our master sink (replace with the master sink from step 1. above)
pacmd load-module module-remap-sink sink_name=remapR master=ladspa_out channels=1 master_channel_map=front-right channel_map=front-right
A filtered sink with name remapR
is created for the front right audio channel from the filtered ladspa_out
sink.
pacmd load-module module-remap-sink sink_name=remapL master=alsa_output.pci-0000_00_14.2.analog-stereo channels=1 master_channel_map=front-left channel_map=front-left
An unfiltered sink remapL
for the front left audio channel is created from our unfiltered master sink as defined above.
pacmd load-module module-combine-sink sink_name=combine sink_properties=device.description=myCombine slaves=remapL,remapR channels=2
A new sink combine
(or any other name you choose) will be created with 2
channels using the unfiltered sink remapL
for the left channel, and the filtered sink remapR
for the right channel.
Now we can choose this newly created sink (displayed as "myCombine") in audio settings to have the left channel unfiltered, and the right channel filtered with the LADSP filter from above.
In case we have more than two channels we will have to perform these steps for all channels, replacing each channel with filtered, or unfiltered signals to combine them again in the last step.
Alright, at the risk of answering my own question, I came up with a bit of a hacked together pyqt version of pvol from the link in the question above. If nothing else, maybe someone else can improve on my code. Eventually, I plan to either get rid of the parts in the script below which go unused or to take the bash scripts out of the equation and have one pyqt script handle all of the button events. Right now, the OSD times out at a constant rate from the first button press instead of staying on for a fixed amount of time after the last button press.
Just copy, paste and save the files (with the names in bold), put them all in the same directory, set the executable bits, and modify the system calls in the pyqt script according to wherever you save them, or put them all in directory that's in your path. Then map the shell scripts to Compiz commands, Openbox shortcuts, or something similar, and change the pyqt script if you're not using multimedia keyboard volume buttons.
Note: The class name Qvol was a working title, and I didn't bother to change it. Please also note that the mute button goes unhandled--This is just a prototype to express a possible avenue for fulfilling the requested features, and it is not currently associated with any kind of hosted project or standard development model. Any kind of significant development derived from the code below should probably belong on Sourceforge, GitHub or a project website. That said, feel free to edit this answer or to suggest an existing project which allows is similar in function and design.
vol_step_down
#!/bin/bash
pulseaudio --check
#if [ $? -ne 0 ] ; then
if [ $? -eq 0 ] ; then
pactl set-sink-volume 0 -- -3db
else
amixer -c0 set Master playback 3-
fi
if [ -z "$1" ] ; then
pqvol -s
fi
vol_step_up
#!/bin/bash
pulseaudio --check
#if [ $? -ne 0 ] ; then
if [ $? -eq 0 ] ; then
pactl set-sink-volume 0 -- +3db
else
amixer -c0 set Master playback 3+
fi
if [ -z "$1" ] ; then
pqvol -s
fi
pqvol
#!/usr/bin/env python2
# pvol -- Commandline audio volume utility
# with an optional GTK progressbar
# Copyright (C) 2009 Adrian C. <anrxc_sysphere_org>
# Modified by 2011 Reza Jelveh
# Ported to pyqt and renamed to pqvol 2013 by Adam R.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
import os.path
import optparse
import alsaaudio
import sys
from PyQt4 import QtGui, QtCore
from PyQt4.QtCore import QTimer
appname = "Qvol"
#appicon = "/usr/share/icons/ubuntu-mono-light/status/24/audio-volume-high-panel.svg"
DEFAULT_STYLE = """
QProgressBar{
border: 2px solid grey;
border-radius: 5px;
background-color: transparent;
}
QProgressBar::chunk {
background-color: Gainsboro;
}
"""
class AlsaMixer():
def __init__(self, pcm=False, mute=False, arg=None):
self.mixer = alsaaudio.Mixer()
self.percent = self.mixer.getvolume()[0]
print self.percent
self.label = "dB" #% name
if arg:
self.percent = min(100, max(0, self.percent + int(arg)))
self.mixer.setvolume(self.percent)
if mute:
mutestate = self.mixer.getmute()[0]
if mutestate:
self.label = "Unmuted: "
else:
self.label = "Muted: "
self.mixer.setmute(mutestate^1)
# self.label = self.label + "%.0f%%" % self.percent
class Qvol(QtGui.QWidget):
def __init__(self):
super(Qvol, self).__init__()
# self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
self.setWindowFlags(QtCore.Qt.Popup)
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
self.setWindowTitle("Qvol")
self.initUI()
def initUI(self):
self.pbar = QtGui.QProgressBar(self)
self.pbar.setGeometry(5, 5, 20, 470)
self.pbar.setOrientation(QtCore.Qt.Vertical)
self.pbar.setRange(0,100)
volume = AlsaMixer()
self.pbar.setValue(volume.percent)
self.pbar.setTextVisible(False)
self.setStyleSheet(DEFAULT_STYLE)
self.setGeometry(1260, 180, 30, 480)
self.setWindowTitle('QtGui.QProgressBar')
self.show()
QTimer.singleShot(2000, finished)
def keyPressEvent(self, event):
if event.key()==QtCore.Qt.Key_VolumeMute:
# QtGui.QWidget.paintEvent()
finished()
elif event.key()==QtCore.Qt.Key_VolumeDown:
launch_process ("vol_step_down silent")
volume=AlsaMixer()
self.pbar.setValue(volume.percent)
# finished()
elif event.key()==QtCore.Qt.Key_VolumeUp:
launch_process ("vol_step_up silent")
volume=AlsaMixer()
self.pbar.setValue(volume.percent)
# finished()
# else:
# QtGui.QWidget.keyPressEvent(self, event)
processes = set([])
def launch_process(process):
# Do something asynchronously
proc = QtCore.QProcess()
processes.add(proc)
proc.start(process)
proc.waitForFinished(-1)
def finished():
print "The process is done!"
# Quit the app
QtCore.QCoreApplication.instance().quit()
def main():
app = QtGui.QApplication(sys.argv)
ex = Qvol()
sys.exit(app.exec_())
if __name__ == '__main__':
main()
Related Question
- Ubuntu – Apply LADSPA filter to only one channel of multichannel output with Alsa and PulseAudio
- Ubuntu – fancy vertical notification OSD that works for both ALSA and pulseaudio
- Ubuntu – Setting the default ALSA device for Pulseaudio
- Ubuntu – Analog audio recognized by ALSA, but not by PulseAudio
- Ubuntu – Mute key mutes Master and Headphone/Speaker (alsa channels), but unmutes only Master
- ALSA vs Pulseaudio – Using ALSA Instead of Pulseaudio and Logout Issue
- Ubuntu – How to route a system-wide ALSA EQ (alsaequal) through the volume control and connect PulseAudio to it
Best Answer
Run this command: