This forum has been archived. All content is frozen. Please use KDE Discuss instead.

automatically assign Master to current playback device

Tags: None
(comma "," separated)
apache
Registered Member
Posts
302
Karma
0
OS
I have three sound cards.
cat /proc/asound/cards
Code: Select all
 0 [NVidia         ]: HDA-Intel - HDA NVidia
                      HDA NVidia at 0xd2000000 irq 17
 1 [Intel          ]: HDA-Intel - HDA Intel
                      HDA Intel at 0xd5100000 irq 44
 2 [CUBE           ]: USB-Audio - Audiotrak ProDigy CUBE
                      GYROCOM C&C Co., LTD Audiotrak ProDigy CUBE at usb-0000:00:1d.2-1, full speed


Intel is set as default. I want some applications to use Intel, and some (Music) use Cube.
As default for all except Music I have Intel analog-stereo (alsa_output.pci-0000_00_1b.0.analog-stereo)
http://i.imgur.com/wZrbQXi.png
and for Music Cube
http://i.imgur.com/83LJCXS.png
When I play video it uses Intel and when I play music it uses Cube, which is what I wanted.

I use keyboard shortcut to change volume. The problem is that Master channel is assigned to default device Intel and when I use different sound source: Music I need to assign Master channel to different playback device to be able to control volume with keyboard shortcut.

Is there any way to automatically assign Master to current playback device?
I found a script
http://pablo-blog.blueoakdb.com/2012/07 ... aster.html
and tried to apply to my case but with no luck.
When I add it to KDE start up scripts (before KDE starts option) I get info that KDE only accepts .sh scripts and it doesn't work but when I change extension it to .sh it hangs KDE at start up. Maybe I didn't adjusted it correctly. I would appreciate if someone could check.
http://pastebin.com/08TdXju5


Or is there any way to switch playback devices with keyboard shortcut?


Code: Select all
qdbus org.kde.kmix /Mixers org.kde.KMix.MixSet.currentMasterMixer
PulseAudio::Playback_Devices:1

qdbus org.kde.kmix /Mixers org.kde.KMix.MixSet.currentMasterControl
alsa_output.pci-0000_00_1b.0.analog-stereo

pacmd list-sinks                                                   
Welcome to PulseAudio! Use "help" for usage information.
>>> 3 sink(s) available.
  * index: 0
        name: <alsa_output.pci-0000_00_1b.0.analog-stereo>
        driver: <module-alsa-card.c>
        flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
        state: IDLE
        suspend cause:
        priority: 9959
        volume: 0:  67% 1:  67%
                0: -10,61 dB 1: -10,61 dB
                balance 0,00
        base volume: 100%
                     0,00 dB
        volume steps: 65537
        muted: no
        current latency: 19,84 ms
        max request: 3 KiB
        max rewind: 64 KiB
        monitor source: 0
        sample spec: s16le 2ch 44100Hz
        channel map: front-left,front-right
                     Stereo
        used by: 0
        linked by: 1
        configured latency: 20,00 ms; range is 2,00 .. 371,52 ms
        card: 1 <alsa_card.pci-0000_00_1b.0>
        module: 6
        properties:
                alsa.resolution_bits = "16"
                device.api = "alsa"
                device.class = "sound"
                alsa.class = "generic"
                alsa.subclass = "generic-mix"
                alsa.name = "ALC888 Analog"
                alsa.id = "ALC888 Analog"
                alsa.subdevice = "0"
                alsa.subdevice_name = "subdevice #0"
                alsa.device = "0"
                alsa.card = "1"
                alsa.card_name = "HDA Intel"
                alsa.long_card_name = "HDA Intel at 0xd5100000 irq 44"
                alsa.driver_name = "snd_hda_intel"
                device.bus_path = "pci-0000:00:1b.0"
                sysfs.path = "/devices/pci0000:00/0000:00:1b.0/sound/card1"
                device.bus = "pci"
                device.vendor.id = "8086"
                device.vendor.name = "Intel Corporation"
                device.product.id = "27d8"
                device.product.name = "GA-D525TUD (Realtek ALC887)"
                device.form_factor = "internal"
                device.string = "front:1"
                device.buffering.buffer_size = "65536"
                device.buffering.fragment_size = "32768"
                device.access_mode = "mmap+timer"
                device.profile.name = "analog-stereo"
                device.profile.description = "Analogowe stereo"
                device.description = "Wbudowany dźwięk Analogowe stereo"
                alsa.mixer_name = "Realtek ALC888"
                alsa.components = "HDA:10ec0888,1458e601,00100001"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card-pci"
        ports:
                analog-output: Wyjście analogowe (priority 9900, latency offset 0 usec, available: unknown)
                        properties:

                analog-output-headphones: Słuchawki (priority 9000, latency offset 0 usec, available: no)
                        properties:
                                device.icon_name = "audio-headphones"
        active port: <analog-output>
    index: 1
        name: <alsa_output.usb-GYROCOM_C_C_Co.__LTD_Audiotrak_ProDigy_CUBE-01-CUBE.analog-stereo>
        driver: <module-alsa-card.c>
        flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
        state: IDLE
        suspend cause:
        priority: 9049
        volume: 0:  38% 1:  38%
                0: -25,41 dB 1: -25,41 dB
                balance 0,00
        base volume: 100%
                     0,00 dB
        volume steps: 65537
        muted: no
        current latency: 24,09 ms
        max request: 3 KiB
        max rewind: 344 KiB
        monitor source: 1
        sample spec: s16le 2ch 44100Hz
        channel map: front-left,front-right
                     Stereo
        used by: 0
        linked by: 1
        configured latency: 20,00 ms; range is 4,00 .. 2000,00 ms
        card: 2 <alsa_card.usb-GYROCOM_C_C_Co.__LTD_Audiotrak_ProDigy_CUBE-01-CUBE>
        module: 7
        properties:
                alsa.resolution_bits = "16"
                device.api = "alsa"
                device.class = "sound"
                alsa.class = "generic"
                alsa.subclass = "generic-mix"
                alsa.name = "USB Audio"
                alsa.id = "USB Audio"
                alsa.subdevice = "0"
                alsa.subdevice_name = "subdevice #0"
                alsa.device = "0"
                alsa.card = "2"
                alsa.card_name = "Audiotrak ProDigy CUBE"
                alsa.long_card_name = "GYROCOM C&C Co., LTD Audiotrak ProDigy CUBE at usb-0000:00:1d.2-1, full speed"
                alsa.driver_name = "snd_usb_audio"
                device.bus_path = "pci-0000:00:1d.2-usb-0:1:1.1"
                sysfs.path = "/devices/pci0000:00/0000:00:1d.2/usb4/4-1/4-1:1.1/sound/card2"
                udev.id = "usb-GYROCOM_C_C_Co.__LTD_Audiotrak_ProDigy_CUBE-01-CUBE"
                device.bus = "usb"
                device.vendor.id = "1852"
                device.vendor.name = "GYROCOM C&C Co., LTD"
                device.product.id = "7921"
                device.product.name = "Audiotrak ProDigy CUBE"
                device.serial = "GYROCOM_C_C_Co.__LTD_Audiotrak_ProDigy_CUBE"
                device.string = "front:2"
                device.buffering.buffer_size = "352800"
                device.buffering.fragment_size = "176400"
                device.access_mode = "mmap+timer"
                device.profile.name = "analog-stereo"
                device.profile.description = "Analogowe stereo"
                device.description = "Audiotrak ProDigy CUBE Analogowe stereo"
                alsa.mixer_name = "USB Mixer"
                alsa.components = "USB1852:7921"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card-usb"
        ports:
                analog-output: Wyjście analogowe (priority 9900, latency offset 0 usec, available: unknown)
                        properties:

        active port: <analog-output>
    index: 2
        name: <alsa_output.pci-0000_01_00.1.hdmi-stereo>
        driver: <module-alsa-card.c>
        flags: HARDWARE DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
        state: IDLE
        suspend cause:
        priority: 9050
        volume: 0:   1% 1:   1%
                0: -120,01 dB 1: -120,01 dB
                balance 0,00
        base volume: 100%
                     0,00 dB
        volume steps: 65537
        muted: yes
        current latency: 19,95 ms
        max request: 3 KiB
        max rewind: 64 KiB
        monitor source: 2
        sample spec: s16le 2ch 44100Hz
        channel map: front-left,front-right
                     Stereo
        used by: 0
        linked by: 1
        configured latency: 20,00 ms; range is 2,00 .. 371,52 ms
        card: 0 <alsa_card.pci-0000_01_00.1>
        module: 5
        properties:
                alsa.resolution_bits = "16"
                device.api = "alsa"
                device.class = "sound"
                alsa.class = "generic"
                alsa.subclass = "generic-mix"
                alsa.name = "HDMI 0"
                alsa.id = "HDMI 0"
                alsa.subdevice = "0"
                alsa.subdevice_name = "subdevice #0"
                alsa.device = "3"
                alsa.card = "0"
                alsa.card_name = "HDA NVidia"
                alsa.long_card_name = "HDA NVidia at 0xd2000000 irq 17"
                alsa.driver_name = "snd_hda_intel"
                device.bus_path = "pci-0000:01:00.1"
                sysfs.path = "/devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card0"
                device.bus = "pci"
                device.vendor.id = "10de"
                device.vendor.name = "NVIDIA Corporation"
                device.product.id = "0be3"
                device.product.name = "High Definition Audio Controller"
                device.string = "hdmi:0"
                device.buffering.buffer_size = "65536"
                device.buffering.fragment_size = "32768"
                device.access_mode = "mmap+timer"
                device.profile.name = "hdmi-stereo"
                device.profile.description = "Digital Stereo (HDMI)"
                device.description = "High Definition Audio Controller Digital Stereo (HDMI)"
                alsa.mixer_name = "Nvidia GPU 0b HDMI/DP"
                alsa.components = "HDA:10de000b,10de0101,00100200"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card-pci"
        ports:
                hdmi-output-0: HDMI / DisplayPort (priority 5900, latency offset 0 usec, available: no)
                        properties:
                                device.icon_name = "video-display"
        active port: <hdmi-output-0>
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
I would suggest checking out my post here for some help on changing the master device from a script: viewtopic.php?f=19&t=119373&p=300937&hilit=org.kde.kmix+org.kde.KMix.MixSet.setPreferredMaster#p300937


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
apache
Registered Member
Posts
302
Karma
0
OS
I read this topic but it is to difficult for me to figure out how to apply it to my settings. And I don't know what id's are and how to find this information. Some guidance would be appreciated.
Some more output
Code: Select all
qdbus org.kde.kmix /Mixers
property read QString org.kde.KMix.MixSet.currentMasterControl
property read QString org.kde.KMix.MixSet.currentMasterMixer
property read QStringList org.kde.KMix.MixSet.mixers
property read QString org.kde.KMix.MixSet.preferredMasterControl
property read QString org.kde.KMix.MixSet.preferredMasterMixer
signal void org.kde.KMix.MixSet.masterChanged()
signal void org.kde.KMix.MixSet.mixersChanged()
method void org.kde.KMix.MixSet.setCurrentMaster(QString mixer, QString control)
method void org.kde.KMix.MixSet.setPreferredMaster(QString mixer, QString control)
method QDBusVariant org.freedesktop.DBus.Properties.Get(QString interface_name, QString property_name)
method QVariantMap org.freedesktop.DBus.Properties.GetAll(QString interface_name)
method void org.freedesktop.DBus.Properties.Set(QString interface_name, QString property_name, QDBusVariant value)
method QString org.freedesktop.DBus.Introspectable.Introspect()
method QString org.freedesktop.DBus.Peer.GetMachineId()
method void org.freedesktop.DBus.Peer.Ping()


Code: Select all
qdbus org.kde.kmix /Mixers/PulseAudio__Playback_Devices_1 controls

/Mixers/PulseAudio__Playback_Devices_1/alsa_output_pci_0000_00_1b_0_analog_stereo

/Mixers/PulseAudio__Playback_Devices_1/alsa_output_usb_GYROCOM_C_C_Co___LTD_Audiotrak_ProDigy_CUBE_01_CUBE_analog_stereo


When I have in kmix Cube chosen terminal shows
Code: Select all
qdbus org.kde.kmix /Mixers org.kde.KMix.MixSet.setCurrentMaster /Mixers/PulseAudio__Playback_Devices_1/alsa_output_pci_0000_00_1b_0_analog_stereo
Invalid number of parameters


When I set in kmix analog_stereo as Master terminal output is
Code: Select all
qdbus org.kde.kmix /Mixers org.kde.KMix.MixSet.setCurrentMaster /Mixers/PulseAudio__Playback_Devices_1/alsa_output_usb_GYROCOM_C_C_Co___LTD_Audiotrak_ProDigy_CUBE_01_CUBE_analog_stereo
Invalid number of parameters


I don't understand this part:
Otherwise, try passing the value of "id" from the mixer and control respectively to the command instead.

Code: Select all
qdbus org.kde.kmix /Mixers/0 id
qdbus org.kde.kmix /Mixers/0/alsa_output_pci_0000_00_1b_0_analog_stereo id


Can you tell me how to find id and how to apply it to "qdbus org.kde.kmix /Mixers org.kde.KMix.MixSet.setCurrentMaster" ?

The next step will be how to setCurrentMaster from keyboard shortcut
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Your command is nearly correct. Please try the following.
Code: Select all
qdbus org.kde.kmix /Mixers org.kde.KMix.MixSet.setCurrentMaster /Mixers/PulseAudio__Playback_Devices_1 alsa_output_pci_0000_00_1b_0_analog_stereo


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
apache
Registered Member
Posts
302
Karma
0
OS
This one doesn't report errors but in kmix, settings remain unchanged.

There are a few id's in "pacmd list-sinks" output. How would correct command with id look like?


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], ourcraft