Mechoption
Posts: 11
Joined: Thu Nov 12, 2015 1:46 am

mpc can't control volume?

Sun Jun 05, 2016 7:08 pm

Got a Model A+ with fresh Jessie install then added mpc and mpd.
"mpc play" works and I get audio that I want, but, when I use "mpc volume 50" I get "error: problems setting volume"?

So I'm stuck at some default volume - how do I enable mpc to adjust volume? I did it ages ago and never ran into this problem, so not sure what is going on. Google revealed some complicated solutions that I couldn't figure out, must be some simple setting somewhere?

bullwinkle
Posts: 118
Joined: Wed Jan 09, 2013 12:14 pm

Re: mpc can't control volume?

Mon Jun 06, 2016 4:37 am

Hi
I had a similar problem with mpd. I found if I change mixer-type to software I could control the volume. Maybe there is something similar for you ? Not sure if these help .... :?: Also if you have not looked, maybe look in .asoundrc for some clues.

good luck

/etc/mpd.conf

Code: Select all

   # An example of an ALSA output:
    #       
    audio_output {
            type            "alsa"
            name            "My ALSA Device"
    #       device          "hw:0,0"        # optional
            mixer_type      "software"      # optional
    #       mixer_device    "default"       # optional
    #       mixer_control   "PCM"           # optional
    #       mixer_index     "0"             # optional
    }

Mechoption
Posts: 11
Joined: Thu Nov 12, 2015 1:46 am

Re: mpc can't control volume?

Wed Jun 08, 2016 2:57 am

Did that...and it works ! But I have no idea why !

Thanks !!

User avatar
startrek.steve
Posts: 390
Joined: Thu Aug 30, 2012 7:19 pm

Re: mpc can't control volume?

Wed Jun 08, 2016 7:54 am

Will this work on mpg321?

I have the same problem...

Steve
Pi 2 running LibreElec Krypton, Pi 2 running Wheezy Desktop, Pi 1 headless Wheezy, downloading Radio, Pi 1 running Picore headless Media Server, Pi Zero to be an Old Time Radio Project. Pi 3 testing. Pi Zero W downloading Radio shows headless.

rocketsquawk
Posts: 1
Joined: Mon Dec 31, 2018 4:00 pm

Re: mpc can't control volume?

Mon Dec 31, 2018 5:54 pm

Sorry for the necro-post, but this is a common question with mpc/mpd on various single board computers, so I thought I'd share...

You may already know this, but using mixer_type "software" defeats "bit-perfect" playback. If you're not an audiophile and don't care, then no need to read on ;)

If bit-perfect playback is required and you want the ALSA hardware mixer to work with mpd clients (like Sonata or mpc), you need to find the right mixer_control and mixer_index values. Here is the audio output portion of my mpd.conf on an RPi3 Model B with the Nov 2018 Raspbian Stretch image:

Code: Select all

audio_output {
        type            "alsa"
        name            "My ALSA Device"
        device          "hw:CARD=ALSA,DEV=0" 
        mixer_control   "PCM"
        mixer_index     "0"
}
To get the device alias:

Code: Select all

~$ aplay -L

... snipped for brevity ...

hw:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Direct hardware device without any conversions
    
...
Note the uppercase -L option on aplay. This will return all PCM subdevice names. You want the alias for the appropriate subdevice with NO conversions or mixers. So, in this case it is hw:CARD=ALSA,DEV=0 which states "Direct hardware device without any conversions". Other aliases with names starting dmix or plughw should be avoided if you're after bit-perfect playback.

To get the mixer_control and mixer_index values:

Code: Select all

~$ aplay -l
**** 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 ALSA [bcm2835 IEC958/HDMI]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

~$ amixer -c 0 scontrols
Simple mixer control 'PCM',0
Above, I used aplay -l to get the desired card index, which in this case, is card 0. Then, I pass that to amixer with -c 0 and the scontrols option for "Simple mixer controls". The return gives PCM as the mixer_control and 0 as the mixer_index.

I have no idea why the OP's RPi Model A+ didn't just work out of the box, because the above values in mpd.conf are the defaults to my understanding. So, it should have worked as-is unless this was fixed in a later kernel or something.

BONUS: Here's what works on my Tinker Board S (which has 192kHz/24-bit capabilities) with TinkerOS 2.08. My mpd.conf audio output section:

Code: Select all

audio_output {
        type            "alsa"
        name            "ALSA Onboard Audio"
        device          "hw:CARD=OnBoard,DEV=2"
        mixer_control   "Headphone"
        mixer_index     "1"
}
Where did those values come from? Same process as on the RPi3 ...

To get the device alias, I did this:

Code: Select all

~$ aplay -L
default
    Playback/recording through the PulseAudio sound server
null
    Discard all samples (playback) or generate zero samples (capture)
sysdefault:CARD=OnBoard
    USB Audio OnBoard, USB Audio
    Default Audio Device
front:CARD=OnBoard,DEV=0
    USB Audio OnBoard, USB Audio
    Front speakers
surround21:CARD=OnBoard,DEV=0
    USB Audio OnBoard, USB Audio
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=OnBoard,DEV=0
    USB Audio OnBoard, USB Audio
    4.0 Surround output to Front and Rear speakers
surround41:CARD=OnBoard,DEV=0
    USB Audio OnBoard, USB Audio
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=OnBoard,DEV=0
    USB Audio OnBoard, USB Audio
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=OnBoard,DEV=0
    USB Audio OnBoard, USB Audio
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=OnBoard,DEV=0
    USB Audio OnBoard, USB Audio
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=OnBoard,DEV=0
    USB Audio OnBoard, USB Audio
    IEC958 (S/PDIF) Digital Audio Output
dmix:CARD=OnBoard,DEV=0
    USB Audio OnBoard, USB Audio
    Direct sample mixing device
dmix:CARD=OnBoard,DEV=1
    USB Audio OnBoard, USB Audio #1
    Direct sample mixing device
dmix:CARD=OnBoard,DEV=2
    USB Audio OnBoard, USB Audio #2
    Direct sample mixing device
dsnoop:CARD=OnBoard,DEV=0
    USB Audio OnBoard, USB Audio
    Direct sample snooping device
dsnoop:CARD=OnBoard,DEV=1
    USB Audio OnBoard, USB Audio #1
    Direct sample snooping device
dsnoop:CARD=OnBoard,DEV=2
    USB Audio OnBoard, USB Audio #2
    Direct sample snooping device
hw:CARD=OnBoard,DEV=0
    USB Audio OnBoard, USB Audio
    Direct hardware device without any conversions
hw:CARD=OnBoard,DEV=1
    USB Audio OnBoard, USB Audio #1
    Direct hardware device without any conversions
hw:CARD=OnBoard,DEV=2
    USB Audio OnBoard, USB Audio #2
    Direct hardware device without any conversions
plughw:CARD=OnBoard,DEV=0
    USB Audio OnBoard, USB Audio
    Hardware device with all software conversions
plughw:CARD=OnBoard,DEV=1
    USB Audio OnBoard, USB Audio #1
    Hardware device with all software conversions
plughw:CARD=OnBoard,DEV=2
    USB Audio OnBoard, USB Audio #2
    Hardware device with all software conversions
sysdefault:CARD=rockchipminiarm
    rockchip,miniarm-codec, 
    Default Audio Device
dmix:CARD=rockchipminiarm,DEV=0
    rockchip,miniarm-codec, 
    Direct sample mixing device
dsnoop:CARD=rockchipminiarm,DEV=0
    rockchip,miniarm-codec, 
    Direct sample snooping device
hw:CARD=rockchipminiarm,DEV=0
    rockchip,miniarm-codec, 
    Direct hardware device without any conversions
plughw:CARD=rockchipminiarm,DEV=0
    rockchip,miniarm-codec, 
    Hardware device with all software conversions
So, hw:CARD=OnBoard,DEV=2 is the direct device alias for the headphone jack (just take this at face value ...) with no conversions of any kind. Again, note the "Direct hardware device without any conversions" bit.

To get the mixer_control and mixer_index, I did this:

Code: Select all

~$ amixer -c 0 scontrols
Simple mixer control 'Headphone',0
Simple mixer control 'Headphone',1
Simple mixer control 'Mic',0
Simple mixer control 'Mic',1
Simple mixer control 'Extension Unit',0
Simple mixer control 'SPDIF',0
'Headphone' and 1 are the correct mixer_control and mixer_index values for the headphone audio jack on a Tinker Board S.

With these values in my mpd.conf, I can control volume with mpc as expected:

Code: Select all

~$ mpc volume 95
Norah Jones - Don't Know Why
[playing] #1/1   0:10/3:07 (5%)
volume: 95%   repeat: off   random: off    single: off   consume: off
And the verbose log to prove the bit-perfect 192kHz/24-bit playback and successful volume commands :) :

Code: Select all

Dec 31 12:35 : client: [15] process command "play"
Dec 31 12:35 : playlist: play 0:"HiFi/192000Hz_24bit/Norah Jones - 2012 - Come Away With Me [192kHz FLAC]/1-Dont Know Why.flac"
Dec 31 12:35 : client: [15] command returned 0
Dec 31 12:35 : client: [15] process command list
Dec 31 12:35 : client: process command "status"
Dec 31 12:35 : client: command returned 0
Dec 31 12:35 : client: process command "currentsong"
Dec 31 12:35 : client: command returned 0
Dec 31 12:35 : client: [15] process command list returned 0
Dec 31 12:35 : client: [15] closed
Dec 31 12:35 : decoder_thread: probing plugin flac
Dec 31 12:35 : decoder: audio_format=192000:24:2, seekable=true
Dec 31 12:35 : alsa_output: opened hw:CARD=OnBoard,DEV=2 type=HW
Dec 31 12:35 : alsa_output: format=S24_3LE (Signed 24 bit Little Endian in 3bytes)
Dec 31 12:35 : alsa_output: buffer: size=384..174762 time=2000..910219
Dec 31 12:35 : alsa_output: period: size=192..87381 time=1000..455110
Dec 31 12:35 : alsa_output: default period_time = buffer_time/4 = 500000/4 = 125000
Dec 31 12:35 : alsa_output: buffer_size=96000 period_size=24000
Dec 31 12:35 : output: opened plugin=alsa name="ALSA Onboard Audio" audio_format=192000:24:2
Dec 31 12:35 : client: [16] opened from local
Dec 31 12:35 : client: [16] process command "setvol "95""
Dec 31 12:35 : client: [16] command returned 0
Dec 31 12:35 : client: [16] process command list
Dec 31 12:35 : client: process command "status"
Dec 31 12:35 : client: command returned 0
Dec 31 12:35 : client: process command "currentsong"
Dec 31 12:35 : client: command returned 0
Dec 31 12:35 : client: [16] process command list returned 0
Dec 31 12:35 : client: [16] closed
Dec 31 12:35 : client: [17] opened from local
Dec 31 12:35 : client: [17] process command "stop"
Dec 31 12:35 : playlist: stop
Dec 31 12:35 : player: played "HiFi/192000Hz_24bit/Norah Jones - 2012 - Come Away With Me [192kHz FLAC]/1-Dont Know Why.flac"
Dec 31 12:35 : output: closed plugin=alsa name="ALSA Onboard Audio"
Dec 31 12:35 : client: [17] command returned 0
Dec 31 12:35 : client: [17] process command list
Dec 31 12:35 : client: process command "status"
Dec 31 12:35 : client: command returned 0
Dec 31 12:35 : client: process command "currentsong"
Dec 31 12:35 : client: command returned 0
Dec 31 12:35 : client: [17] process command list returned 0
Dec 31 12:35 : client: [17] closed
And it also works with with Sonata from a different client machine:
Screenshot_2018-12-31_12-51-25.png
Screenshot_2018-12-31_12-51-25.png (16.38 KiB) Viewed 9372 times
Hope this helps someone!

bartelbe
Posts: 9
Joined: Mon May 08, 2017 5:56 pm

Re: mpc can't control volume?

Sun Dec 13, 2020 8:24 pm

That not only helped me, but it saved my asus tinkerboard from being used as a doorstop (again)!
Go figure that I can spend literally years trying to get sound out of the tinkerboard, scouring their forum and google only to find deaD or useless hyperlinks, when the only helpful thread is on a tech help forum for Raspberry pi.

Return to “Troubleshooting”