You are not logged in.

#1 2020-01-07 19:53:16

mrOmegamilkyman
Member
Registered: 2020-01-07
Posts: 2

[SOLVED] mpd not playing through correct device

This is my first post, sorry if formatting is bad

I have PulseAudio working with ALSA  and for most things, they play out of the device I want (Blue Yeti AUX jack, Yeti is plugged in by USB), specified by pulse which I can mute or change volume with in ALSA since it's my default sound card.

Unfortunately, mpd plays through a different device from my HDA Intel PCH soundcard (Stereo speakers plugged into Line-Out) which can be controlled by the "Front" item.

What I would like is to have all audio play through both those devices and mute the one I don't need, or just switch the output device, either of those solutions work for me. Even if they were tied together somehow, that would also be fine because I can control the devices separately with their physical knobs to mute/change volume.

Some side things that I'm trying to understand when I was trying to tinker with this is (not the main issue it's ok if I don't get an answer they're kinda related):

  • Difference between muting and suspending something, I can see that muting something with pactl also mutes it in the ALSA mixer but suspend does nothing

  • Difference between sink/source and sink-input/source-output, I think pactl move-sink-input might work but I'm cautious to use it because I don't really know what it does and I wish man pactl provided an example

  • What exactly is a soundcard? I get the idea of how they work by messing around with it but the only sound cards I were aware of were either with the motherboard or external, but apparently I have 5 not counting PulseAudio

this is $ aplay -l

**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC1150 Analog [ALC1150 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 1: ALC1150 Digital [ALC1150 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia_1 [HDA NVidia], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia_1 [HDA NVidia], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia_1 [HDA NVidia], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia_1 [HDA NVidia], device 9: HDMI 3 [HDMI 3]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 9: HDMI 3 [HDMI 3]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 4: Microphone [Yeti Stereo Microphone], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Subdevices goes to 0/1 when audio is played out of device (as it should I think) but when I type $ pactl list sinks

Sink #0
        State: SUSPENDED
        Name: alsa_output.pci-0000_01_00.1.hdmi-stereo-extra2
        Description: GP102 HDMI Audio Controller Digital Stereo (HDMI 3)
        Driver: module-alsa-card.c
        Sample Specification: s16le 2ch 44100Hz
        Channel Map: front-left,front-right
        Owner Module: 6
        Mute: no
        Volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
                balance 0.00
        Base Volume: 65536 / 100% / 0.00 dB
        Monitor Source: alsa_output.pci-0000_01_00.1.hdmi-stereo-extra2.monitor
        Latency: 0 usec, configured 0 usec
        Flags: HARDWARE DECIBEL_VOLUME LATENCY SET_FORMATS
        Properties:
                alsa.resolution_bits = "16"
                device.api = "alsa"
                device.class = "sound"
                alsa.class = "generic"
                alsa.subclass = "generic-mix"
                alsa.name = "HDMI 2"
                alsa.id = "HDMI 2"
                alsa.subdevice = "0"
                alsa.subdevice_name = "subdevice #0"
                alsa.device = "8"
                alsa.card = "1"
                alsa.card_name = "HDA NVidia"
                alsa.long_card_name = "HDA NVidia at 0xdf080000 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/card1"
                device.bus = "pci"
                device.vendor.id = "10de"
                device.vendor.name = "NVIDIA Corporation"
                device.product.id = "10ef"
                device.product.name = "GP102 HDMI Audio Controller"
                device.string = "hdmi:1,2"
                device.buffering.buffer_size = "352768"
                device.buffering.fragment_size = "176384"
                device.access_mode = "mmap+timer"
                device.profile.name = "hdmi-stereo-extra2"
                device.profile.description = "Digital Stereo (HDMI 3)"
                device.description = "GP102 HDMI Audio Controller Digital Stereo (HDMI 3)"
                alsa.mixer_name = "Nvidia GPU 82 HDMI/DP"
                alsa.components = "HDA:10de0082,104385e5,00100100"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card-pci"
        Ports:
                hdmi-output-2: HDMI / DisplayPort 3 (priority: 5700, available)
        Active Port: hdmi-output-2
        Formats:
                pcm

Sink #1
        State: SUSPENDED
        Name: alsa_output.usb-Blue_Microphones_Yeti_Stereo_Microphone_REV8-00.analog-stereo
        Description: Yeti Stereo Microphone Analog Stereo
        Driver: module-alsa-card.c
        Sample Specification: s16le 2ch 44100Hz
        Channel Map: front-left,front-right
        Owner Module: 9
        Mute: no
        Volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
                balance 0.00
        Base Volume: 65536 / 100% / 0.00 dB
        Monitor Source: alsa_output.usb-Blue_Microphones_Yeti_Stereo_Microphone_REV8-00.analog-stereo.monitor
        Latency: 0 usec, configured 0 usec
        Flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY
        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 = "4"
                alsa.card_name = "Yeti Stereo Microphone"
                alsa.long_card_name = "Blue Microphones Yeti Stereo Microphone at usb-0000:00:14.0-12, full speed"
                alsa.driver_name = "snd_usb_audio"
                device.bus_path = "pci-0000:00:14.0-usb-0:12:1.0"
                sysfs.path = "/devices/pci0000:00/0000:00:14.0/usb1/1-12/1-12:1.0/sound/card4"
                udev.id = "usb-Blue_Microphones_Yeti_Stereo_Microphone_REV8-00"
                device.bus = "usb"
                device.vendor.id = "b58e"
                device.vendor.name = "Blue Microphones"
                device.product.id = "9e84"
                device.product.name = "Yeti Stereo Microphone"
                device.serial = "Blue_Microphones_Yeti_Stereo_Microphone_REV8"
                device.form_factor = "microphone"
                device.string = "front:4"
                device.buffering.buffer_size = "352800"
                device.buffering.fragment_size = "176400"
                device.access_mode = "mmap+timer"
                device.profile.name = "analog-stereo"
                device.profile.description = "Analog Stereo"
                device.description = "Yeti Stereo Microphone Analog Stereo"
                alsa.mixer_name = "USB Mixer"
                alsa.components = "USBb58e:9e84"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-input-microphone-usb"
        Ports:
                analog-output-speaker: Speakers (priority: 10000)
        Active Port: analog-output-speaker
        Formats:
                pcm

Sink #2
        State: SUSPENDED
        Name: alsa_output.pci-0000_00_1f.3.analog-stereo
        Description: Built-in Audio Analog Stereo
        Driver: module-alsa-card.c
        Sample Specification: s16le 2ch 44100Hz
        Channel Map: front-left,front-right
        Owner Module: 10
        Mute: no
        Volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
                balance 0.00
        Base Volume: 65536 / 100% / 0.00 dB
        Monitor Source: alsa_output.pci-0000_00_1f.3.analog-stereo.monitor
        Latency: 0 usec, configured 0 usec
        Flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY
        Properties:
                alsa.resolution_bits = "16"
                device.api = "alsa"
                device.class = "sound"
                alsa.class = "generic"
                alsa.subclass = "generic-mix"
                alsa.name = "ALC1150 Analog"
                alsa.id = "ALC1150 Analog"
                alsa.subdevice = "0"
                alsa.subdevice_name = "subdevice #0"
                alsa.device = "0"
                alsa.card = "0"
                alsa.card_name = "HDA Intel PCH"
                alsa.long_card_name = "HDA Intel PCH at 0xdd140000 irq 148"
                alsa.driver_name = "snd_hda_intel"
                device.bus_path = "pci-0000:00:1f.3"
                sysfs.path = "/devices/pci0000:00/0000:00:1f.3/sound/card0"
                device.bus = "pci"
                device.vendor.id = "8086"
                device.vendor.name = "Intel Corporation"
                device.product.id = "a170"
                device.product.name = "100 Series/C230 Series Chipset Family HD Audio Controller"
                device.form_factor = "internal"
                device.string = "front:0"
                device.buffering.buffer_size = "352800"
                device.buffering.fragment_size = "176400"
                device.access_mode = "mmap+timer"
                device.profile.name = "analog-stereo"
                device.profile.description = "Analog Stereo"
                device.description = "Built-in Audio Analog Stereo"
                alsa.mixer_name = "Realtek ALC1150"
                alsa.components = "HDA:10ec0900,1462da12,00100001"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card-pci"
        Ports:
                analog-output-lineout: Line Out (priority: 9000, available)
                analog-output-headphones: Headphones (priority: 9900, not available)
        Active Port: analog-output-lineout
        Formats:
                pcm

Only Sink #1's state (Blue Yeti) switches to running when audio is playing, while whether or not sink #2 (Line-Out Speakers) are playing the state is always suspended

my /etc/asound.conf reads

# Use PulseAudio by default
pcm.!default {
  type pulse
  fallback "sysdefault"
  hint {
    show on
    description "Default ALSA Output (currently PulseAudio Sound Server)"
  }
}

ctl.!default {
  type pulse
  fallback "sysdefault"
}

# vim:set ft=alsaconf:

This is my ~/.asoundrc

# Find and use input "Microphone" for input
pcm.usb
{
    type hw
    card Microphone
}
pcm.!default
{
    type asym
    playback.pcm
    {
    	# Use the dmix plug to allow multiple outputs.
        type plug
        slave.pcm "dmix"
    }
    capture.pcm
    {
        type plug
        slave.pcm "usb"
    }
}

this is my /etc/pulse/default.pa, but this is all I think I added and this post is getting kinda long so

### Make some devices default
set-default-sink alsa_output.usb-Blue_Microphones_Yeti_Stereo_Microphone_REV8-00.analog-stereo
set-default-source alsa_input.usb-Blue_Microphones_Yeti_Stereo_Microphone_REV8-00.analog-stereo

If you'd like to see anything else lmk, I appreciate the help

Last edited by mrOmegamilkyman (2020-01-08 03:02:19)

Offline

#2 2020-01-07 22:29:08

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 9,040

Re: [SOLVED] mpd not playing through correct device

Welcome to the boards, usually we'd like to have just one specific question per thread, but there's enough logical tie ins and it's a well structured post, and I like to clear up audio stuff

mrOmegamilkyman wrote:

This is my first post, sorry if formatting is bad

I wished we'd see more first posts  formatted this well.

Difference between muting and suspending something, I can see that muting something with pactl also mutes it in the ALSA mixer but suspend does nothing

Muting is logically muting the card, as you'd expect it. Suspending is only really relevant for pulseaudio and means pulseaudio "releases" the card so that it can be used by other applications (if you are confused here - and not to toot my own horn, but it's a good place to explain this mechanic and also incidentally a direct tie in with your actual problem with mpd - you should read this post

Difference between sink/source and sink-input/source-output, I think pactl move-sink-input might work but I'm cautious to use it because I don't really know what it does and I wish man pactl provided an example

sink (audio cards) is a point where sink-inputs (applications) dump their audio, source (microphones) is a point where source-outputs (applications) grab their audio

You can have virtual sinks/sources for all sorts of cool stuff. When you are just starting out and what's relevant for 90% of usecases: Sinks are your audio output cards, sink-inputs are your applications playing audio, Sources are your microphones, source-outputs are your applications recording audio.

The pactl commands for moving do just that, you can transparently move whatever an application is playing to a completely different device (and back) You can't really do anything irreversible with this.  e.g. I'm playing something in an audio player on my USB headset, sink-inputs tells me

    index: 11
        driver: <protocol-native.c>
        flags: START_CORKED 
        state: CORKED
        sink: 0 <alsa_output.usb-Astro_Gaming_Astro_A50-00.analog-stereo>

So my audio player has gotten the index 11 for the input and is playing to my headset, but I want something on my speakers, so

pacmd move-sink-input 11 alsa_output.pci-0000_0c_04.0.analog-surround-51 #You can also use the sink index here e.g. 1

now I'm playing over my speakers. You can move that same 11 multiple times however you feel like (when you stop and restart playback you will have to recheck the number here)

I suggest you install and use pavucontrol here, it will help with visualizing this concept in a more approachable manner.

What exactly is a soundcard? I get the idea of how they work by messing around with it but the only sound cards I were aware of were either with the motherboard or external, but apparently I have 5 not counting PulseAudio

You have 4 actual physical distinct sound cards (internal,  2  nvidia hdmi (do you have two graphic cards?), and the USB card ) the other things you see here are subdevices, so they belong to a specific card, but can be played back to independently of each other (if you read my other post, you can play to each of these subdevices even on plain ALSA concurrently)

Subdevices goes to 0/1 when audio is played out of device (as it should I think) but when I type

Good observation! If you've followed along so far you should at least have an inkling as to what the problem is by now.

MPD is in general a bit of a special case, but if this system is mostly for your personal use, the best way to go about this is to

  1. not use a system level daemon, as pulse runs on your user - https://wiki.archlinux.org/index.php/Mu … figuration

  2. You should explicitly configure MPD to use pulse instead of ALSA for output - https://wiki.archlinux.org/index.php/Mu … figuration

PS. If your intention is to route everything over pulse, you should remove your ~/.asoundrc as you are now redirecting things away from pulse again and you will again have the problem of simultaneous playback

Online

#3 2020-01-08 02:57:19

mrOmegamilkyman
Member
Registered: 2020-01-07
Posts: 2

Re: [SOLVED] mpd not playing through correct device

After reading your reply and post ALSA feels restrictive for no good reason, so I probably will migrate away from it and route everything to pulse, and switch to pulse+pavucontrol instead. It works!

I appreciate your post, it helped me understand exactly what's going on under the hood. Thanks!

Also I do have two graphics cards, I used to mine ETH.

Offline

#4 2020-01-08 09:06:58

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 9,040

Re: [SOLVED] mpd not playing through correct device

There are good reasons for why plain ALSA is like that, and you can recreate a lot of the functionalities of pulseaudio if you dive into ALSA configuration (other than the dynamic runtime switching, that needs some centralized control unit).

And the limitations I'm talking about in the other post are actually hardware limitations. Because software mixing can be done so fast and efficiently nowadays it's much simpler to simply have a single output that expects one final input stream of information. How that input stream is generated from all different potential sources is up to the software/operating systems. This works the same way on Windows and Mac just that there their own "pulseaudios" are a much more integral part of their sound infrastructure.

But yes it's generally a bit of a subversion of expectations if you are used to how other OSes do it, where you have to explicitly from the application have to request exclusive access when you need it, whereas you have to bolt on mixing in some seperate manner here.

Last edited by V1del (2020-01-08 14:06:46)

Online

Board footer

Powered by FluxBB