Mignand
Posts: 2
Joined: Sat Apr 04, 2020 4:57 pm

[Solved] Can not set volume with MPD and USB Audio.

Sat Apr 04, 2020 5:51 pm

Hi, I tried everything, but I can not get the right settings in mpd.conf to control the volume.

Hardware: Raspberry Pi Zero W with "Terratec Aureon Dual USB" for audio.
OS: Raspbian
The desktop with VLC works. The alsamixer works and mpg123 to play mp3 files works.

In the desktop, I have set the USB Audio as default. That probably has set the .aroundrc to default to device 1.

The Terratec USB audio has a optical output with more channels. I use the normal stereo jack connector.

I followed this tutorial: http://wiki.lug-saar.de/projekte/internetradio.
That tutorial is outdated and I had to change a number of things. It is now working, but I can not change the volume with 'MPC volume'. Even "software" for the mixer does not work.

The audio_output part of my /etc/mpd.conf:

Code: Select all

audio_output {
        type     "alsa"
        name     "USB Audio"
        device   "hw:1,0"
}

These things work:

Code: Select all

speaker-test -c2 -twav
aplay -D plughw:1,0 test.wav
espeak-ng -d plughw:1,0 "Hello world"
mpg123 test.mp3
amixer -c 1 set Speaker 50%

aplay -l

Code: Select all

**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
  Subdevices: 7/7
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 IEC958/HDMI [bcm2835 IEC958/HDMI]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: ALSA [bcm2835 ALSA], device 2: bcm2835 IEC958/HDMI1 [bcm2835 IEC958/HDMI1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: DEVICE [USB PNP SOUND DEVICE], device 0: USB Audio [USB Audio]
  Subdevices: 0/1
  Subdevice #0: subdevice #0

aplay -L

Code: Select all

null
    Discard all samples (playback) or generate zero samples (capture)
default
sysdefault:CARD=ALSA
    bcm2835 ALSA, bcm2835 ALSA
    Default Audio Device
dmix:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Direct sample mixing device
dmix:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Direct sample mixing device
dmix:CARD=ALSA,DEV=2
    bcm2835 ALSA, bcm2835 IEC958/HDMI1
    Direct sample mixing device
dsnoop:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Direct sample snooping device
dsnoop:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Direct sample snooping device
dsnoop:CARD=ALSA,DEV=2
    bcm2835 ALSA, bcm2835 IEC958/HDMI1
    Direct sample snooping device
hw:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Direct hardware device without any conversions
hw:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Direct hardware device without any conversions
hw:CARD=ALSA,DEV=2
    bcm2835 ALSA, bcm2835 IEC958/HDMI1
    Direct hardware device without any conversions
plughw:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Hardware device with all software conversions
plughw:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Hardware device with all software conversions
plughw:CARD=ALSA,DEV=2
    bcm2835 ALSA, bcm2835 IEC958/HDMI1
    Hardware device with all software conversions
sysdefault:CARD=DEVICE
    USB PNP SOUND DEVICE, USB Audio
    Default Audio Device
front:CARD=DEVICE,DEV=0
    USB PNP SOUND DEVICE, USB Audio
    Front speakers
surround21:CARD=DEVICE,DEV=0
    USB PNP SOUND DEVICE, USB Audio
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=DEVICE,DEV=0
    USB PNP SOUND DEVICE, USB Audio
    4.0 Surround output to Front and Rear speakers
surround41:CARD=DEVICE,DEV=0
    USB PNP SOUND DEVICE, USB Audio
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=DEVICE,DEV=0
    USB PNP SOUND DEVICE, USB Audio
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=DEVICE,DEV=0
    USB PNP SOUND DEVICE, USB Audio
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=DEVICE,DEV=0
    USB PNP SOUND DEVICE, USB Audio
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=DEVICE,DEV=0
    USB PNP SOUND DEVICE, USB Audio
    IEC958 (S/PDIF) Digital Audio Output
dmix:CARD=DEVICE,DEV=0
    USB PNP SOUND DEVICE, USB Audio
    Direct sample mixing device
dsnoop:CARD=DEVICE,DEV=0
    USB PNP SOUND DEVICE, USB Audio
    Direct sample snooping device
hw:CARD=DEVICE,DEV=0
    USB PNP SOUND DEVICE, USB Audio
    Direct hardware device without any conversions
plughw:CARD=DEVICE,DEV=0
    USB PNP SOUND DEVICE, USB Audio
    Hardware device with all software conversions

amixer (the 'Auto Gain Control' is for the mic)

Code: Select all

Simple mixer control 'Speaker',0
  Capabilities: pvolume pswitch pswitch-joined
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 37
  Mono:
  Front Left: Playback 33 [89%] [-4.00dB] [on]
  Front Right: Playback 33 [89%] [-4.00dB] [on]
Simple mixer control 'Mic',0
  Capabilities: pvolume pvolume-joined cvolume cvolume-joined pswitch pswitch-joined cswitch cswitch-joined
  Playback channels: Mono
  Capture channels: Mono
  Limits: Playback 0 - 31 Capture 0 - 35
  Mono: Playback 0 [0%] [-23.00dB] [off] Capture 30 [86%] [18.00dB] [off]
Simple mixer control 'Auto Gain Control',0
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [on]

amixer -c 0

Code: Select all

Simple mixer control 'PCM',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined
  Playback channels: Mono
  Limits: Playback -10239 - 400
  Mono: Playback -1727 [80%] [-17.27dB] [off]

grep -v '^$\|^\s*#' /etc/mpd.conf

Code: Select all

music_directory		"/var/lib/mpd/music"
playlist_directory		"/var/lib/mpd/playlists"
db_file			"/var/lib/mpd/tag_cache"
pid_file			"/run/mpd/pid"
state_file			"/var/lib/mpd/state"
sticker_file                   "/var/lib/mpd/sticker.sql"
user				"mpd"
bind_to_address		"/run/mpd/socket"
input {
        plugin "curl"
}
audio_output {
	type		"alsa"
	name		"USB Audio"
        device          "hw:1,0"
}
filesystem_charset		"UTF-8"
id3v1_encoding			"UTF-8"
Last edited by Mignand on Mon Apr 06, 2020 6:55 am, edited 1 time in total.

Mignand
Posts: 2
Joined: Sat Apr 04, 2020 4:57 pm

Re: Can not set volume with MPD and USB Audio.

Mon Apr 06, 2020 6:54 am

The problem is solved. I can use MPC and the webpage with PHP to control the volume of the USB audio.
After a reboot, the webpage even starts with the same volume that I set before. The solution was the "Speaker" for the mixer_control.

Code: Select all

audio_output {
        type            "alsa"
        name            "USB Audio"
        device          "hw:1,0"
        mixer_device    "hw:1"
        mixer_type      "hardware"
        mixer_control   "Speaker"
        mixer_index     "0"
}

RoiSoleil
Posts: 1
Joined: Fri Apr 19, 2019 2:55 pm

Re: [Solved] Can not set volume with MPD and USB Audio.

Sat Mar 06, 2021 10:27 pm

Bonjour,
Thank you. Your configuration also works for me as well as for my Bose.
I specify tparam = audio = off parameter of my config.txt file is set

Return to “Media centres”