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
Volume scaling on RPi #22
Comments
I've tried some things. Badly you can't compare mopidy and spotify connect with shairport sync because they are written in python and not in C. In C you can access directly alsa. In python is not much mixer related implemented. So for me I did for now a crude hack to "linearise" the volume. You can see it in my fork of spotify connect. |
So it is the python spotify-connect-web that changes the volume directly? Does it not user amixer? If so it can be the same problem as I don't think it is to do with the alsa library only. i.e. amixer's volume scale is a simple direct raw readout of the card values rather than one that relates to human hearing. I will have a look at your hack, thanks! |
It is the same problem. But in python aren't the same functions implemented to use from alsa like in C. You can read about it in pyalsa docu at the end of mixer part. |
Just to update: it is indeed a similar issue, i.e. simply that hardware volume control from cards operate on a simple scale that is not related to how humans hear. It is the same as what amixer does on command line by default (note that alsamixer does something different). On mine I modified the volume control to translate on an exponent scale:
However I keep managing to break the volume control and am not sure why. |
Are you both using the Pi's builtin "DAC"/PWM ?
The problem is therefore probably not the scale but simply that the minimal value returned by ALSA is incorrect. |
No, I use an USB sound card on my rPi2, which may be not much better than the internal DAC. But I also use the digital output (spdif) from my cubox where I have the same scaling problem. |
This is because pyalsaaudio changes the db value linearly. I've modified pyalsaaudio to scale the volume in the same way as alsamixer does and this improves things for me. I've put the changes in my fork. |
Will test it next days when I'm home. But I need to mix your version with the one where the device is properly released. |
I have added a new argument which sets an upper volume range. Same solution as on https://github.com/mikebrady/shairport-sync, like @plietar said. |
Finally merged in #34, which should fix this |
Firstly just let me say a big thanks for getting so far with this project, it took me a few days to find it but I am pretty happy to get it running on the RPI1.
I have only played with it for a minute, but I did notice that the volume control scale (using the PCM mixer) is off - i.e. it's inaudible/very quiet for most of the range and all the useful variability is in the top 20% or so of the Spotify slider. I can see this reflected in alsamixer when controlling the volume from Spotify. alsamixer itself works correctly.
I believe this is likely related to a similar issue that affected mopidy, to do with the way amixer reports volume:
mopidy/mopidy-alsamixer#3
In shairport-sync a different volume algorithm has been applied that works quite well:
https://github.com/mikebrady/shairport-sync
Not sure what volume is like on other platforms or other versions of amixer, it might be that the latter is what is important in which case the lib could be updated to do something different in each case. Or, maybe apply a configurable filter in the python layer? Has anyone played about with this yet?
The text was updated successfully, but these errors were encountered: