PeteManchester / MediaPlayer

61 stars 20 forks source link

Volume control doesn't work on new builds #101

Closed mightyoakbob closed 4 months ago

mightyoakbob commented 2 years ago

Using instructions that have successfully built working systems for many months no longer delivers a working volume control.

I'm using a Hi-Fi Berry bolt on dac. Previously to get the volume control to work all you had to do was make a few changes to /etc/mpd.conf so it became like this....

audio_output { type "alsa" name "My ALSA Device" hash device "hw:0,0" # optional mixer_type "software"# <<<<<< makes volume control work. hash mixer_device "default" # optional hash mixer_control "PCM" # optional hash mixer_index "0" # optional }

This has stopped working for new builds in the last couple of months.

Changes have been made somewhere by someone and it is no longer possible to build a new system with working volume control.

I suppose the most likely is mpd and normally I might ask on an associated forum but I'm not aware of any mpd forum that's friendly to none experts.

Any ideas?

Bob.

PeteManchester commented 2 years ago

Hi Bob,

What version of MPD are you using?

mpd --version Music Player Daemon 0.21.5 (0.21.5)

Copyright 2003-2007 Warren Dukes warren.dukes@gmail.com Copyright 2008-2018 Max Kellermann max.kellermann@gmail.com This is free software; see the source for copying conditions. There is NO warranty; not even MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ..... ...

Do you see anything in the MPD log to suggest why the software mixer isn't working.

As a test, have you tried stripping back to the standard Raspi audio output instead of your Hifi Berry to see if the volume control works.

Cheers,

Pete.

mightyoakbob commented 2 years ago

Hi Pete, Thanks for getting back to me and for your help.

I have two raspi HIFI Berry players. One has the cheap analogue output hat and the other the cheap spdif out hat. During testing, both systems behaved the same and indeed the only difference between them should be one line in /boot/config.txt that sets the hat driver.

I have a complete build from last February saved as a file and if I use that as the basis, I can make either system fully functional. However, attempt to build from scratch exactly how the feb version was built and volume doesn't function. At the moment my analogue out pi volume doesn't function but the spdif one does. Both are based on bullseye and both respond to mpd --version with 0.22.6 (0.22.6) .

I've just looked at the mpd log file and there were some errors yesterday afternoon and so I thought I would try to play something now. It played with no errors and I did try the volume control but it still doesn't work.

Yesterday's errors: Jun 19 16:11 : exception: Failed to open '/var/lib/mpd/state': No such file or directory Jun 19 16:11 : avahi: Service 'Music Player @ Linn-Pi-190622-1' successfully established. Jun 19 16:15 : avahi: Service 'Music Player @ Linn-Pi-190622-1' successfully established. Jun 19 16:27 : avahi: Client Disconnected, will reconnect shortly Jun 19 16:28 : zeroconf: No global port, disabling zeroconf Jun 19 16:36 : zeroconf: No global port, disabling zeroconf Jun 19 19:27 : zeroconf: No global port, disabling zeroconf

But nothing today unless they get written at a later time.

I've not tried the ordinary audio out, to do that I assume I allow the original driver and rem out the hifiberry one in config.txt?

I'll give it a go..

Thanks for the help again.

Bob.

mightyoakbob commented 2 years ago

Hi Pete, Sorry I took so long to get back with this I've been busy. I have now edited /boot/config.txt and rem'd out the drivers for hiFi-Berry and allowed the driver dtparam=audio=on. I also deleted /etc/asound.conf, a file needed for the HIFi-Berry hats.

To my surprise the audio actually did work through the on-board jack socket. However, the volume control did NOT function with this output either.

So it seems that with current builds, the alsa setting 'mixer_type [tab] software' no longer functions.

Do you have any other ideas because I don't have the knowledge to get much futher if at all.

Thanks.

Bob.

PeteManchester commented 2 years ago

Hi Bob,

Ok, thanks..

I've tried looking through all the documentation and searching, but not got very far..

If you use the command:

amixer scontrols

[image: image.png]

What do you get?

Here are some examples of what I found for using the Software volume control

https://forums.raspberrypi.com/viewtopic.php?t=269961 https://community.volumio.org/t/mpd-client-volume-control-does-not-work-with-hifiberry-digi-pro/39887/2

I also found this that describes how to try to use the Hardware volume control of a DAC

https://forums.raspberrypi.com/viewtopic.php?t=150505

But not sure if it will work with the HifiBerry, see the post on Monday Dec 31, 2018 at 5.54 'Sorry for the necro-post'

They seem to suggest: using aplay -L to get the DAC device Id using aplay -l and amixer -c to get the mixer_control and mixer_index values

Then they end up with a mpd.conf that looks like this:

audio_output { type "alsa" name "ALSA Onboard Audio" device "hw:CARD=OnBoard,DEV=2" mixer_control "Headphone" mixer_index "1" }

I've not tried it though..

My mpd.conf looks like this:

audio_output { type "alsa" name "My ALSA Device" device "hw:0,0" # optional mixer_type "hardware" # optional mixer_control "PCM" mixer_index "0" # optional }

Where aplay -L gave me: .. hw:CARD=CUBE,DEV=0 Audiotrak ProDigy CUBE, USB Audio Direct hardware device without any conversions ...

aplay -l gave me:

@.*:~# aplay -l ** List of PLAYBACK Hardware Devices **** card 0: CUBE [Audiotrak ProDigy CUBE], device 0: USB Audio [USB Audio] Subdevices: 0/1 Subdevice #0: subdevice #0 card 0: CUBE [Audiotrak ProDigy CUBE], device 1: USB Audio [USB Audio #1] Subdevices: 1/1 Subdevice #0: subdevice #0 card 1: Headphones [bcm2835 Headphones], device 0: bcm2835 Headphones [bcm2835 Headphones] Subdevices: 8/8 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 Subdevice #7: subdevice #7

And amixer -c 0 scontrols gave me:

@.***:~# amixer -c 0 scontrols Simple mixer control 'PCM',0 Simple mixer control 'PCM Capture Source',0 Simple mixer control 'Line',0

I'm not pretending I understand the above, but maybe we could use it as a comparison to what you get..

On Wed, 22 Jun 2022 at 10:35, mightyoakbob @.***> wrote:

Hi Pete, Sorry I took so long to get back with this I've been busy. I have now edited /boot/config.txt and rem'd out the drivers for hiFi-Berry and allowed the driver dtparam=audio=on. I also deleted /etc/asound.conf, a file needed for the HIFi-Berry hats.

To my surprise the audio actually did work through the on-board jack socket. However, the volume control did NOT function with this output either.

So it seems that with current builds, the alsa setting 'mixer_type [tab] software' no longer functions.

Do you have any other ideas because I don't have the knowledge to get much futher if at all.

Thanks.

Bob.

— Reply to this email directly, view it on GitHub https://github.com/PeteManchester/MediaPlayer/issues/101#issuecomment-1162875118, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5RVJ72XKH6Z7IM63CAVPTVQLM7VANCNFSM5ZGTC3QA . You are receiving this because you commented.Message ID: @.***>

mightyoakbob commented 2 years ago

Hi Pete, Thanks for what done in trying to help me with this. For some reason I didn't get an email notification of your latest post and only found it by chance tonight. I'm a bit tied up at the moment but I will attend to this as soon as I'm able.

A couple of things come to mind... Firstly, the issue I have is the same on the spdif out card, dac output card and even the on-board jack fixed to the raspi. Because volume control works (with an earlier build) on the spdif card which has no dac it seems to me this is nothing to do with the dac.

What I'm going to do is issue the commands you suggest on both a working system and a failing one maybe a difference will show up and I'll report back here. But as a starter, this is from a berry dac with faulty volume control..

pi@Linn-Pi-190622-1:~ $ amixer scontrols Simple mixer control 'DSP Program',0 Simple mixer control 'Analogue',0 Simple mixer control 'Analogue Playback Boost',0 Simple mixer control 'Auto Mute',0 Simple mixer control 'Auto Mute Mono',0 Simple mixer control 'Auto Mute Time Left',0 Simple mixer control 'Auto Mute Time Right',0 Simple mixer control 'Clock Missing Period',0 Simple mixer control 'Deemphasis',0 Simple mixer control 'Digital',0 Simple mixer control 'Max Overclock DAC',0 Simple mixer control 'Max Overclock DSP',0 Simple mixer control 'Max Overclock PLL',0 Simple mixer control 'Volume Ramp Down Emergency Rate',0 Simple mixer control 'Volume Ramp Down Emergency Step',0 Simple mixer control 'Volume Ramp Down Rate',0 Simple mixer control 'Volume Ramp Down Step',0 Simple mixer control 'Volume Ramp Up Rate',0 Simple mixer control 'Volume Ramp Up Step',0

pi@Linn-Pi-190622-1:~ $ aplay -L null Discard all samples (playback) or generate zero samples (capture) default hw:CARD=sndrpihifiberry,DEV=0 snd_rpi_hifiberry_dacplus, HiFiBerry DAC+ HiFi pcm512x-hifi-0 Direct hardware device without any conversions plughw:CARD=sndrpihifiberry,DEV=0 snd_rpi_hifiberry_dacplus, HiFiBerry DAC+ HiFi pcm512x-hifi-0 Hardware device with all software conversions sysdefault:CARD=sndrpihifiberry snd_rpi_hifiberry_dacplus, HiFiBerry DAC+ HiFi pcm512x-hifi-0 Default Audio Device dmix:CARD=sndrpihifiberry,DEV=0 snd_rpi_hifiberry_dacplus, HiFiBerry DAC+ HiFi pcm512x-hifi-0 Direct sample mixing device

pi@Linn-Pi-190622-1:~ $ aplay -l List of PLAYBACK Hardware Devices card 0: sndrpihifiberry [snd_rpi_hifiberry_dacplus], device 0: HiFiBerry DAC+ HiFi pcm512x-hifi-0 [HiFiBerry DAC+ HiFi pcm512x-hifi-0] Subdevices: 1/1 Subdevice #0: subdevice #0

pi@Linn-Pi-190622-1:~ $ amixer -c 0 scontrols Simple mixer control 'DSP Program',0 Simple mixer control 'Analogue',0 Simple mixer control 'Analogue Playback Boost',0 Simple mixer control 'Auto Mute',0 Simple mixer control 'Auto Mute Mono',0 Simple mixer control 'Auto Mute Time Left',0 Simple mixer control 'Auto Mute Time Right',0 Simple mixer control 'Clock Missing Period',0 Simple mixer control 'Deemphasis',0 Simple mixer control 'Digital',0 Simple mixer control 'Max Overclock DAC',0 Simple mixer control 'Max Overclock DSP',0 Simple mixer control 'Max Overclock PLL',0 Simple mixer control 'Volume Ramp Down Emergency Rate',0 Simple mixer control 'Volume Ramp Down Emergency Step',0 Simple mixer control 'Volume Ramp Down Rate',0 Simple mixer control 'Volume Ramp Down Step',0 Simple mixer control 'Volume Ramp Up Rate',0 Simple mixer control 'Volume Ramp Up Step',0

More to follow when I can...

Thanks

Bob.

mightyoakbob commented 2 years ago

Hi Pete, I've been trying to read all the references you gave me and to get to understand a bit more but I very much don't understand some basics with this ALSA mixer object.

I understand what hardware and software mean normally but in the context of this Alsa thing I have no idea what the terms mean. Its the same with PCM, yes I know what PCM is but what has that to do with mixer control?

I can't find basic explanations for the terms used (in this context) anywhere.

I'm also confused by how the volume control worked when I had a berry hat with only spdif output and no dac. As far as I can understand, this must mean that the volume control was changing the PCM being fed out (to the external dac) rather than controlling an on board dac in some way.

I'm not keen on pursuing a volume control that only works with an on board dac because to be honest, the sound quality is not in my opinion too good using the Berry dacs but, using and spdif card and an external dac is pretty good. So I need the volume control to work for that too, so surely that must mean adjusting the pcm data going out?

Do you have any better understanding than I of these basic terms?

Thanks

Bob.

mightyoakbob commented 2 years ago

Using the method described in references you gave me I tried this...

audio_output { type "alsa" name "My ALSA Device" device "hw:CARD=sndrpihifiberry,DEV=0" # optional mixer_type "hardware" # optional

mixer_device "default" # optional

mixer_control   "Digital"       # optional
mixer_index "0"     # optional

}

Using the HiFi-Berry dac+ (the cheap £30 hat) this works but only with Kazoo, it does not work with Lumin. I've not tried the spdif output card yet.

As an aside, any idea why this website keeps enlarging some lines of text and not others or better still how to stop it.

Bob.

PeteManchester commented 2 years ago

Hi Bob,

I can't pretend I know everything about how the volume control works..

When you change the volume using Kazoo or Lumin, mediaplayer will send a request to MPD to change the volume.

My understanding is that: If MPD is configured with mixer_type as software, then MPD will adjust the volume, I would guess by just altering the values of each sample being played. If MPD is configured with mixer_type as hardware, then MPD will hand off the control of the volume to the device (DAC), how the DAC or Raspi adjusts the volume is probably dependant on the DAC.

It may be the dashes that are causing your text to be enlarged

Github use a markdown syntax https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax


Test with dashes

Hope that helps,

Pete.

mightyoakbob commented 2 years ago

Hi Pete, Thanks for your help. I have worked on this day after day and all day long, it's a good job I'm retired. I do have some news though. I have been using the beta version you created for me last September that fixed Lumin. I have been using it with Java8 for many months without issue and then suddenly, it would work no longer with new builds.

I then noticed a newer beta on your website and in desperation I tried that. It complained about Java8 and refused to work. I then built again this time using Java 11. I got some worrying warnings about something being illegal.

pi@Linn-Pi-Analogue-test:~/mediaplayer $ WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.rpi.os.OSManager (file:/home/pi/mediaplayer/mediaplayer.jar) to field java.lang.ClassLoader.usr_paths WARNING: Please consider reporting this to the maintainers of org.rpi.os.OSManager WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release

However, Java11 with your latest beta does work, Lumin and the volume control.

I've built this again and again with both Java types and multiple version of mediaplayer and I've proved that the September 21 beta no longer works (volume control wise) with either Java 8 or Java11. I'm pretty confident that what I'm saying is correct. Only your latest beta and java 11 work.

I don't begin to understand how the September 21 beta stored on my hard drive for 6 months can just stop working, Something else must be breaking it but I've no idea what.

Bob.