mirror of
https://github.com/librespot-org/librespot.git
synced 2026-04-27 08:15:50 +03:00
[GH-ISSUE #745] Distorted audio when using dynamic normalisation #403
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#403
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 @rbuch on GitHub (May 13, 2021).
Original GitHub issue: https://github.com/librespot-org/librespot/issues/745
Audio sounds highly distorted and seems to be clipping when using the current default dynamic normalisation added in https://github.com/librespot-org/librespot/pull/660. Changing back to using basic normalisation or disabling normalisation altogether fixes the issue.
(Discovered via
ncspot, the corresponding issue there is: https://github.com/hrkfdn/ncspot/issues/522.)@roderickvd commented on GitHub (May 13, 2021):
Could you please provide the following information:
librespot, all else being equal (same pregain, attack, threshold, knee, and so on);--backend alsaor--backend rodioinstead of PulseAudio or PipeWire.Finally, please explain what its meant by "even when in-app volume is set to 0%" in that downstream issue. As I understand it, the audio is distorted even when volume is set to 0 or mute? Does the distortion differ depending on the volume setting?
@Johannesd3 commented on GitHub (May 13, 2021):
And if you use PipeWire, which backend? IIRC ALSA, Jack, GStreamer, Pulseaudio, or Rodio would be possible. Does it happen with other backends + PipeWire as well?
@rbuch commented on GitHub (May 13, 2021):
I did a bit of digging, I couldn't get this to reproduce in vanilla
librespotwith any of the backends or changing any other options. However, comparing debug output betweenlibrespotandncspotuncovered the issue, thenormalisation_thresholdinncspotis incorrect.ncspotinitializeslibrespot_playback::config::PlayerConfigwith the following code:Thus, it uses the default value for
normalisation_threshold(which is-1.0) directly, whereaslibrespotpasses the default value throughNormalisationData::db_to_ratiowhen it constructs the object (resulting in~0.8912509). Explicitly passing in this adjusted value in thencspotconstructor fixes the issue, otherwise the effective threshold after converting to dB in thencspotcase ends up beingNaN.So I suppose the question now is can the logic to convert the value from dB to ratio be pushed into an object creation function for
PlayerConfigto avoid this problem?@Johannesd3 commented on GitHub (May 13, 2021):
Why can't ncspot use NormalisationData::db_to_ratio themselves?
@rbuch commented on GitHub (May 14, 2021):
It can, of course, but it feels like a leaky abstraction for an external application to have to pull a default value out, transform it, and then explicitly pass it back in when it just wants it to be default initialized.
@roderickvd commented on GitHub (May 14, 2021):
I agree with @rbuch the default should just make sense. This was an oversight on my end. I'll update it later this weekend.
@roderickvd commented on GitHub (May 14, 2021):
Thanks for digging around 😅 I was getting worried.
@roderickvd commented on GitHub (May 16, 2021):
@rbuch could you please verify #749 and report back there?
@rbuch commented on GitHub (May 16, 2021):
Building
ncspotwith #749 does indeed fix the default value issue and it all sounds like it should. Thanks for the quick fix!