Welcome!
Important information
-- Spectre and Meltdown vulnerabilities
-- Change in MX sources

News
-- MX Linux on social media: here
-- Mepis support still here

Current releases
-- MX-17.1 Final release info here
-- antiX-17 release info here

New users
-- Please read this first, and don't forget to add system and hardware information to posts!
-- Here are the Forum Rules

[Resolved] How to change default output device ?

Post Reply
Message
Author
erbou
Forum Novice
Forum  Novice
Posts: 46
Joined: Sun May 21, 2017 12:21 pm

[Resolved] How to change default output device ?

#1 Post by erbou » Sun Sep 30, 2018 9:46 pm

Hello,

I have these four sounds cards installed :

Code: Select all

$ cat /proc/asound/cards
 0 [PCH            ]: HDA-Intel - HDA Intel PCH
                      HDA Intel PCH at 0xf0210000 irq 30
 1 [HDMI           ]: HDA-Intel - HDA ATI HDMI
                      HDA ATI HDMI at 0xf0060000 irq 31
 2 [U0x46d0x825    ]: USB-Audio - USB Device 0x46d:0x825
                      USB Device 0x46d:0x825 at usb-0000:00:14.0-9, high speed
 3 [AG06AG03       ]: USB-Audio - AG06/AG03
                      Yamaha Corporation AG06/AG03 at usb-0000:00:14.0-6.1, high speed
and I want to set number 3 as the default output device.

When I run alsamixer from console then press F6 key and select number 3, the alsamixer changes its display from PulseAudio to AG06/AG03 but as soon as I press the ESC key then restart Audacious player, I'm still getting audio output from PCH.

I I've also tried to create a .conf file :

Code: Select all

$ cat /etc/asound.conf
defaults.pcm.card 3
defaults.ctl.card 3
Unfortunately, it doesn't change anything : audio still comes out from PCH.
Last edited by erbou on Thu Oct 04, 2018 10:55 am, edited 1 time in total.
1st boot: Linux ttx 4.7.0-0.bpo.1-amd64 #1 SMP MX 4.7.8-1mx16+3 (2017-02-23) x86_64 GNU/Linux
2nd boot: Windows 7 Home Edition
Processor: Intel i5-4570 - Ram: 16 Gb - NAS: Synology DS216j - DSM 6.1

User avatar
fehlix
Forum Guide
Forum Guide
Posts: 1717
Joined: Wed Apr 11, 2018 5:09 pm

Re: How to change default output device ?

#2 Post by fehlix » Mon Oct 01, 2018 5:03 am

I would probably try this:
Within MX Tools run MX Select Sound: Which makes a defined default alsa sound card device.
With pulsaudio volume control select and set the default sound card, and/or even disable unwanted sound-devices.
Gigabyte Z77M-D3H, Intel Xeon E3-1240 V2 (Quad core), 32GB RAM,
GeForce GTX 770, Samsung SSD 850 EVO 500GB, Seagate Barracuda 4TB

erbou
Forum Novice
Forum  Novice
Posts: 46
Joined: Sun May 21, 2017 12:21 pm

Re: How to change default output device ?

#3 Post by erbou » Tue Oct 02, 2018 10:10 pm

In fact, what I am looking for is a CLI to launch from a bash script.
1st boot: Linux ttx 4.7.0-0.bpo.1-amd64 #1 SMP MX 4.7.8-1mx16+3 (2017-02-23) x86_64 GNU/Linux
2nd boot: Windows 7 Home Edition
Processor: Intel i5-4570 - Ram: 16 Gb - NAS: Synology DS216j - DSM 6.1

User avatar
c4os
Forum Novice
Forum  Novice
Posts: 64
Joined: Tue Jun 19, 2018 12:28 pm

Re: How to change default output device ?

#4 Post by c4os » Wed Oct 03, 2018 1:46 pm

You need different asound.conf's. One for PCH and one for HDMI.

For example PCH asound.conf.analog:

Code: Select all

 pcm.!default {
        type hw
        card 0
        device 0
}
For HDMI asound.conf.hdmi:

Code: Select all

 pcm.!default {
	type hw
	card 1
	device 3
}
And your AG06/AG03 asound.conf.ag06:

Code: Select all

 pcm.!default {
	type hw
	card 3
	device 0
}
May you need to change the device number for your cards. Could be device 0/1/2/3. My hdmi got 3.
Find the correct number with "aplay -L" and check the DEV= value.

Then create a script which copy the created file to /etc/asound.conf.
enable-hdmi.sh

Code: Select all

#!/bin/bash
sudo cp /etc/asound.conf.hdmi /etc/asound.conf
exit 0
Make a backup of your asound.conf before.

But I assume you have to set fehlix suggestion before:
fehlix wrote:
Mon Oct 01, 2018 5:03 am
I would probably try this:
Within MX Tools run MX Select Sound: Which makes a defined default alsa sound card device.
With pulsaudio volume control select and set the default sound card, and/or even disable unwanted sound-devices.
Powered on: MX 17 Horizon x86_64
Hardware: Dell Latitude E4300 - CPU: Intel Core 2 Duo P9600 (2) @ 2.535GHz - Memory: 4GB
Style: Resolution: 1280x800 - WM Theme: Balou - Theme: Blackbird [GTK2/3] - Icons: Papirus-Dark [GTK2]

erbou
Forum Novice
Forum  Novice
Posts: 46
Joined: Sun May 21, 2017 12:21 pm

Re: How to change default output device ?

#5 Post by erbou » Thu Oct 04, 2018 10:54 am

Thanks a lot.
Eventually, I found this script which works fine, although I have to run it several times in order to switch between PCH and AG06 sound cards.

Code: Select all

#!/bin/bash

declare -i sinks=(`pacmd list-sinks | sed -n -e 's/\**[[:space:]]index:[[:space:]]\([[:digit:]]\)/\1/p'`)
declare -i sinks_count=${#sinks[*]}
declare -i active_sink_index=`pacmd list-sinks | sed -n -e 's/\*[[:space:]]index:[[:space:]]\([[:digit:]]\)/\1/p'`
declare -i next_sink_index=${sinks[0]}

#find the next sink (not always the next index number)
declare -i ord=0
while [ $ord -lt $sinks_count ];
do
echo ${sinks[$ord]}
if [ ${sinks[$ord]} -gt $active_sink_index ] ; then
    next_sink_index=${sinks[$ord]}
    break
fi
let ord++
done

#change the default sink
pacmd "set-default-sink ${next_sink_index}"

#move all inputs to the new sink
for app in $(pacmd list-sink-inputs | sed -n -e 's/index:[[:space:]]\([[:digit:]]\)/\1/p');
do
pacmd "move-sink-input $app $next_sink_index"
done

#display notification
declare -i ndx=0
pacmd list-sinks | sed -n -e 's/device.description[[:space:]]=[[:space:]]"\(.*\)"/\1/p' | while read line;
do
if [ $(( $ord % $sinks_count )) -eq $ndx ] ; then
    notify-send -i notification-audio-volume-high --hint=string:x-canonical-private-synchronous: "Sound output switched to" "$line"
    exit
fi
let ndx++
done;
1st boot: Linux ttx 4.7.0-0.bpo.1-amd64 #1 SMP MX 4.7.8-1mx16+3 (2017-02-23) x86_64 GNU/Linux
2nd boot: Windows 7 Home Edition
Processor: Intel i5-4570 - Ram: 16 Gb - NAS: Synology DS216j - DSM 6.1

Post Reply

Return to “Software / Configuration”