mirror of
https://github.com/librespot-org/librespot.git
synced 2026-04-27 00:05:55 +03:00
[GH-ISSUE #1008] Playback starts muted when --volume-ctrl=fixed #482
Labels
No labels
A-Alsa
SpotifyAPI
Tokio 1.0
audio
bug
can't reproduce
compilation
dependencies
duplicate
enhancement
good first issue
help wanted
high priority
imported
imported
invalid
new api
pull-request
question
reverse engineering
wiki
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/librespot#482
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @petrkutalek on GitHub (May 26, 2022).
Original GitHub issue: https://github.com/librespot-org/librespot/issues/1008
Originally assigned to: @roderickvd on GitHub.
After updating to librespot v0.4.1 playback starts muted + volume set to 0 % when the switch
--volume-ctrlis set tofixed. After changing tolineareverything seems to be fine (except that I prefer a fixed volume control, I change that one on the amp).Version:
Command line:
@JasonLG1979 commented on GitHub (May 26, 2022):
I have the exact same DAC (Topping D10s). I will see if I can duplicate.
A side note:
The D10s supports S32 audio. Unless you have some other reason for using S24 I'd use S32 with no dithering.
@JasonLG1979 commented on GitHub (May 26, 2022):
It's also pointless and unnecessary to set the mixer device with a fixed volume of 100.
@JasonLG1979 commented on GitHub (May 26, 2022):
Yep, can confirm. It appears to be a quirk of that DAC.
When set to fixed I get:
Notice the volume range is 0.0.
But with the default volume scale of log I get:
Now the volume range is 127.
@JasonLG1979 commented on GitHub (May 26, 2022):
But like I said before if you want to use a fixed volume level of 100 remove:
from your args.
@roderickvd commented on GitHub (May 26, 2022):
Would still be nice though to fix this little quirk with this combination of parameters, superfluous or not. The issue is probably multiplication by zero here:
github.com/librespot-org/librespot@fc1e74574a/playback/src/mixer/alsamixer.rs (L240)Try changing line 239 to:
Please think along if this will work OK for the many other Alsa variants we also have to cover.
@petrkutalek commented on GitHub (May 26, 2022):
Thank you @JasonLG1979 for your valuable comments and analysis of the problem. Librespot is an excellent project that has been a pleasure for me for a very long time, and I appreciate the work of all the developers. I understand the need to support different architectures, but the configuration of the librespot application is by far its weakest point. Even perhaps of all the projects I use. It's like woo-doo.
The idea was that I want to leave the output of the DAC (
--mixer=alsa --alsa-mixer-device=hw:0 --alsa-mixer-control='D10s ') at 100% with no option to change it (--volume-ctrl=fixed), but the--initial-volume=100option will ensure that the mixer output is always set correctly to full at initialization, regardless of the OS settings at startup.Realistically, the D10s' resolution is 21-22 bits according to the measurements. That's why I thought S24 with dithering would be best, but I agree that S32 without dithering is a cleaner choice.
So I finally ended up with the following setup and everything seems to be working fine:
Does this make more sense to you as a Librespot expert?
@JasonLG1979 commented on GitHub (May 26, 2022):
--normalisation-method=dynamicis redundant because dynamic is already the default.A devices name is always better than it's number as the index can change at boot (but it's unlikely unless you have a lot of devices) I generally use
--device=hw:CARD=D10s,DEV=0.Unless you really want track mode normalization I would leave out
--normalisation-gain-type=trackas the default isautowhich will go back and forth between track and album depending on the context. So if you're listening to a mixed playlist it will go to track mode but when you're listening to an album it will switch to album mode.@roderickvd commented on GitHub (May 26, 2022):
We're open to suggestions.
Of course for ultimate ease of use there are other options like
Raspotify. Which is not to say that there is no room for improvement here.With OS settings you mean the OS volume level? If you use
librespot's own softvol or Alsa hardware mixing then the volume is unaffected by the OS.librespot's volume control is in 64-bit float which will be better even than the hardware control of 99.99% of devices.That is the ENOB you are talking about: Effective Number Of Bits, determined by the measured dynamic range, and a result of the engineering of the DAC. It is not the same as the sampling bit depth.
When keeping volume at 100% you will not be able to hear a difference between 24 and 32 bit, dithered or not. At those levels of residual noise it's even hard to measure with the best equipment. Objectively 32 bit will be better and be "naturally" dithered by thermal noise.
Would be great if either of you could take that quick fix for a test drive.
@JasonLG1979 commented on GitHub (May 26, 2022):
I think the intention is to use librespot to set the hardware volume to 100 whenever it starts?
@JasonLG1979 commented on GitHub (May 26, 2022):
Nope, that's didn't fix it. IMHO in the case of
--volume-ctrl=fixedhardware volume control should just not be used. We should just ignore all the hardware volume args.@petrkutalek commented on GitHub (May 26, 2022):
Librespot suits me fine, I don't need another client. As a developer I can also appreciate its beauty inside. You know, I've been using it for a long time, I had to deal with renaming parameters, deprecated parameters, new features, failing Librespot with Rodio backend some time ago, the documentation is not completely exhaustive. So I'm always super nervous when I have to update it and I don't like doing it. However, the contextual explanation @JasonLG1979 wrote is absolutely awesome!!
My layman's view was that it makes no sense to algorithmically lower the volume in Librespot, then in the DAC, to finally raise the volume again in the final amp including noise. I thought it's best to let Librespot do its job with "a 1.0 coefficient", then let the DAC do the output at normal levels (i.e. 100% ??) and control the volume in the amp. But I guess I was wrong.
In the end I used the recommended settings (softvol, no HW mixer settings) and left the work to
amixerandsystemd. I am very satisfied 👍️:@roderickvd commented on GitHub (May 26, 2022):
Thanks for the support. I can imagine about your anxiety as we've been a long way from stability. But we try to make life easier with the changelog we added since v0.2.
No, you were right. Running full line level to an attenuator in the (pre-)amp gives the best dynamic range. It's just a matter of how you get to the full line level. So yeah, hardware control to your DAC to get it to 100% is the best option. And you're also right it's broken now with
fixed, hence the patch I suggested.As comfortable as you are with upgrading, I'd really appreciate if you could test it so we can come full circle on your issue report.
@JasonLG1979 commented on GitHub (May 26, 2022):
It's really about use case. I have my DAC connected to a stereo receiver so I generally use software volume in librespot so that if I want to I can change the volume in a client if I don't have the stereo remote handy or are not close to the receiver. But most of the time I leave it at 100% and use the volume control on the receiver. But all things being equal the software volume control in librespot is going to be better than hardware volume control on a DAC.
Your fix doesn't work no change. If it's helpful librespot also mutes the DAC it doesn't just set the volume to 0.
@roderickvd commented on GitHub (May 26, 2022):
Huh, that's weird. That means that the
set_volumeis called with a volume of0instead ofu16::MAX. I'll have to investigate further sometime later.@JasonLG1979 commented on GitHub (May 26, 2022):
@petrkutalek
Why would you do this? You're throwing away 4dB of theoretical dynamic range. Unless 0dB saturates your preamp's input don't do that. With normalization enabled you'd be better off just lowering the pregain.
@JasonLG1979 commented on GitHub (May 26, 2022):
The D10s is by all indications a very well designed DAC but if you're doing this to prevent inter-sample clipping
--normalisation-pregain=-3should already be sufficient.@petrkutalek commented on GitHub (May 26, 2022):
Yes, @JasonLG1979 exactly. Thanks for advice, will change my settings. 👍️
@roderickvd Sure, I will retest your (next) patch together with Jason to confirm/debug.
@roderickvd commented on GitHub (May 27, 2022):
To be clear, does the verbose log state "Disabling playback (setting mute) on Alsa"? Can you post a full log?
@JasonLG1979 commented on GitHub (May 27, 2022):
With the change:
@JasonLG1979 commented on GitHub (May 27, 2022):
Although the topping D10s is a great DAC the drivers are a bit suspect as evidenced by the fact that it doesn't support S16 on Linux, the trailing white space in the control name and that the control name "D10s " doesn't follow convention at all. There's a post on audio science review about it if I remember. I think a best effort was made but that the author is not a Linux user or experienced at all at writing Linux drivers.
@JasonLG1979 commented on GitHub (May 27, 2022):
It's a USB2 DAC but may not actually be spec compliant?
@roderickvd commented on GitHub (May 27, 2022):
Thanks. And what does it say without the change? Als about
NaNor not?@JasonLG1979 commented on GitHub (May 27, 2022):
The log is exactly the same, no change, still
NaN.@JasonLG1979 commented on GitHub (May 27, 2022):
I think the problem is that a fixed volume has a range of 0.0 but it passes range_ok because it's fixed so the db range is always overridden to 0.0 no matter what the card reports. I'm not sure exactly but then maybe after that there's a division by zero that causes the NaN.
@JasonLG1979 commented on GitHub (May 27, 2022):
Yep, that was the problem.
This seems to fix it:
@JasonLG1979 commented on GitHub (May 27, 2022):
With:
The log output is:
@JasonLG1979 commented on GitHub (May 27, 2022):
What branch do you want me to put in the PR for?
@roderickvd commented on GitHub (May 28, 2022):
Good stuff. Let’s do
devwe have to catch upnew-apianyway.@JasonLG1979 commented on GitHub (May 28, 2022):
Will do.
As a sanity check:
The behavior is such that
--initial-volume=%sets the value of the hardware mixer in a log(?) scale in fixed mode with hardware volume enabled at startup but you can't change the volume level at any time later ofc because it's fixed. Which to me seems like pretty logical behavior.It could come in handy if for some stupid reason your system doesn't remember the volume. I've also seen more than one DAC that if you power cycle them they default back to volume 0, muted.
With
--initial-volume=50With
--initial-volume=0With
--initial-volume=1