-
-
Notifications
You must be signed in to change notification settings - Fork 580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hifiberry Amp hardware volume control not working #232
Comments
I have run -vvv, that did shed some light on the problem:
So it's because the control doesn't have a db volume scale.... |
The built-in software volume control works well, and it is automatically used when you don't specify a mixer name. The only thing you need to do is to separately ensure that the Master volume control is set to maximum before a play session begins. You could write a little script that does that just before Shairport Sync starts playing. (Separately, I'd suggest you ask the HiFiberry guys to consider adding a logarithmic volume control.) |
I'll write a script to set the Master louder / and one to put it back when the shairport stream stops. Pity that I can't use hardware volume control. Is there a way to fiddle around with alsa (asound.conf) to fool shairport-sync into seeing a logarithmic control? I will contact HifiBerry to ask them if they can add a logarithmic volume control. |
Thanks. I'll keep this under review too... |
I changed the "session" section of the shairport-sync.conf:
This worked for a while. Then I got "too many open files" in syslog and:
What's going on... |
In syslog before this happened:
Earlier on it went fine:
I have this at alsa backend:
I changed "default" to "hw:0" in an attempt to fix the failing hardware volume control, before I saw that it was caused by it not having de dB range/scale. But "default" should also use hw:0, as it is the only device on my raspberry pi (not loading drivers for built-in audio). |
The commands operate in the background, so you need to route the output of those commands somewhere like There is no sense in telling Shairport Sync to use the Master mixer, better just comment it out. |
Okay to close this? |
Yes. Fine. Mike Brady [email protected] schreef op 5 april 2016 14:13:00 CEST:
Verzonden van mijn Android telefoon met K-9 Mail. |
Thanks. |
Just got an Amp+ and have the same problem. For me though the software mixer is not working well. When I change the volume on the phone while paired to the shairport-sync, I see log items like:
And other oddly low values. When my phone's volume slider approaches full, it blasts the speakers. I think (though I dare not replicate it), when this happened, shairport-sync reported:
Edit: Forgot to comment out the |
Still intrigued by this. So, the "Amp+" is a HiFiBerry Amp+, right? Can you tell me which version of Shairport Sync you're using please? To get it, enter |
Thanks for your comments (and all your work with this tool, really enjoying it!). Indeed, it's a brand new HifiBerry Amp+ 1.0 (which I'm loving). My shp-s version, freshly compiled yesterday:
To attempt volume control, I was using the normal iPhone volume control after having selected the relevant device in the iPhone's Control Panel for output location; same crazy negative volume settings with iTunes or Pandora. Commenting out I can use Not sure if there's a way to map the smooth volume sliding scale onto this particular mixer arrangement, but very happy to help debug and try things if you have any ideas. Thanks again! |
Thanks. That's all very useful. It supports an idea that there is some silly miscalculation of the transfer function between the volume sliding scale and the range of the Amp+'s mixer. To troubleshoot it, it would be very useful if you could post the upper and lower limits of the "dB gain" for the mixer. You can find that out using
Here are two screenshots showing the max (0.00 dB) and the min-before-mute (-103.00 dB) for an IQaudIO amplifier – the values are near the top left. With those two numbers for the Amp+, some testing could be done. |
Thanks. Just took a look at alsamixer and there is no reported dB gain, only a percentage range from 0-100. Unlike your case, there is a single mixer channel on Here's what
The other mixer looks like:
I'd be happy enough if the volume signal sent over airport mapped linearly (or pleasingly non-linearly via some "typical" dB->percentage mapping) to the 0-248 range of Screenshot: Thanks again. Fun to debug this since it gives you an excuse to sit and listen to music. |
Many thanks for this. I'm now remembering that the hifiberry amp does not have a logarithmic mixer – see #232. So, that means you must use the built-in software volume control. This is all done in 16 bits, so the noise floor isn't as low as it could be due to the [deliberate] use of dithering. The |
OK, wondered if that was the case based on the conversation above. I may contact the HifiBerry people and see why the Amp+ is the only one without a logarithmic mixer exposed. But is it impossible to include a standard "fallback" algorithm for mapping Shairport Sync's desired logarithmic dB scale to a linear "percentage" scale on the HW mixer? I.e. a pseudo-log scale that can map between the two if the mixer itself doesn't present a dB scale to the controller (perhaps with a user-adjustable max_percentage=XXXdB to peg it)? I presume that's all a mixer-provided dB scale does anyway (though perhaps with better vendor domain knowledge of the DAC performance). Thanks. |
Could I jump in here? I am having exactly this problem streaming from a macbook air. The Alsa volume controls on the Pi (raspberry Pi 3, running Moode player 3.1) work fine, either through SSH or through the main interface. But there is no sound at all unless I nudge the alsa controls -- or turn the volume control on the mac to full, which blasts the speakers whatever the Alsa volume is set to. Only did that once, mind you ... Shairport-sync -V gives the result 2.8.6-OpenSSL-Avahi-ALSA-stdout-soxr-metadata-sysconfdir:/usr/local/etc |
It sounds like you have |
Yes indeed. It seems that there is a bug in Shairport Sync in that it should not even be trying to send settings to the mixer once it has discovered that it isn't logarithmic. I'm pretty sure that bug is there because after trying out some ideas to circumvent the problem, the idea was abandoned and some of the code was inadvertently left in place. One possible solution is to add yet another setting allowing the iTunes/iPhone volume (call it AirPlay Volume), which goes from 0 to -30, to be mapped straight onto the non-logarithmic mixer control. For example, if the mixer values are 0 (min) to 100 (max), they should be mapped onto -30 (min AirPlay Volume) to 0 (max AirPlay volume). Zero sounds like mute though, so not sure about that. Whaddya think? What should the name of the setting be? Maybe |
I have asked the Hifiberry people about exposing a dB scale for the Amp. I do know the Amp uses a different driver than the other Hifiberry boards (actually all 4 are different):
In the raspberry pi linux codec
Not sure why that Looking at the |
In case anyone else comes across this, I just used the "run_this_when_volume_is_set" configuration item to run an external script that sets the volume using amixer. I disabled the software volume control (by telling it to use the Amp+'s hardware volume control, which doesn't work but prevents it doing it in software). In the "general" section of /etc/shairport-sync.conf I added this:
As the comments in the config file say, the requested volume is passed to this script as a parameter, from -30 (minimum non-muted) to 0 (max), or -144 for mute (which I didn't need to handle because shairport-sync appears to stop outputting when it's muted). Then it's just a matter of mapping from the requested volume to a value in the 0..100 range that amixer takes. I found that the mapping in the script below worked well and gave a reasonable set of available volume levels, but obviously if you use this technique adjust the formula to your liking. This is the contents of /usr/local/bin/set-volume.sh:
|
Great, thanks. Just a little thing – to disable the software volume control, you should be able to set the |
@jdtsmith, apologies, I somehow overlooked your comment. Would your idea not be at the mercy of how the 0..100 was mapped to level. If it was linear, then one could do something, but if non-linear, then would we not be in trouble, having a composition of two transfer functions? |
Hi Mike, I am apparently using the same driver that you are and am wondering if I am actually using hardware volume or not.. I have the same entries for the mixer that you do and yet, when I control the volume on my Ubuntu machine, the volume adjusts, yet, there is no movement of the sliders when observing alsamixer. I can change the volume, but no change in the alsamixer panel of either the Analogue or Digital sliders. My source machine uses Pulseaudio and also, the volume seems delayed when adjusting. // output_device = "IQaudIODAC"; |
Thanks for the post. Just looking at the settings as given above, they have the two I don’t understand what you mean about the source machine using pulseaudio. Could you elaborate, please? |
Hilarious, I don't know what I was thinking. This is why I don't code. // output_device = "IQaudIODAC"; On the Pulseaudio side of things, in Ubuntu at least, the master volume control that you would normally use if you were using Ubuntu on a laptop with only the built in speakers, actually controls the volume of shairport sync. In a control panel, I can choose the device that I want to output sound to and the master volume in the panel will control that device. There is no need to have a separate application or panel to control the volume of the desired device. I have a suspicion however that whatever was designed to do this in pulseaudio may also be performing it's own dithering in attempt to control the volume of the shairport device. If you were to try this on a linux machine, you may need to install 'paprefs' which is the program that will give you the options.. Thanks Mike |
Good stuff. Actually I didn’t notice that the output device is probably wrong. It probably should be Yeah, PulseAudio can interfere with Shairport Sync alright. It almost certainly does resampling and all kinds of things. |
I have 2 raspi's. One with HifiBerry DAC+, which is working fine. When I open alsamixer, when I change volume on the device (phone, iPad), I see the volume slider in alsamixer move indicating it is using the right control. (with the HifiBerry DAC+, this is " Digital").
Now the other one, is using a HifiBerry Amp.
Alsamixer shows 2 controls: "Master" and "Channels". As per the HifiBerry site, "Master" is the one to use (Mopidy is using Master and works OK).
So I entered "Master" as the mixer control in shairport-sync.conf. But when changing the volume on the device, the volume slider in alsamixer doesn't move, on the device I can't set the volume louder than the setting in alsamixer. I can crank up the volume by setting the alsamixer volume control by hand. But it isn't controlled by shairport.
I tried entering some bogus name for the mixer control in shairport-sync.conf, but it wouldn't start complaining it couldn't find the mixer control. So that indicates that it does use the mixer control name in the config file.
https://www.hifiberry.com/guides/mixer-settings/
The text was updated successfully, but these errors were encountered: