mirror of
https://github.com/librespot-org/librespot.git
synced 2026-04-27 08:15:50 +03:00
[PR #694] [MERGED] Implement dithering #1024
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#1024
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?
📋 Pull Request Information
Original PR: https://github.com/librespot-org/librespot/pull/694
Author: @roderickvd
Created: 4/13/2021
Status: ✅ Merged
Merged: 5/26/2021
Merged by: @roderickvd
Base:
dev← Head:dithering-and-noise-shaping📝 Commits (10+)
c8ec268Implement dithering and noise shapingf3553e1cargo fmtfde697bFix example977dbedCorrect dithering noise powers6ea089cDisable noise shaping by default00b36beDocument default ditherer and noise shaperf7ac001Fix panic when no noise shaper is specified636d181Implement fmt::Display for Ditherer and NoiseShaper2f11bbcRefactor name() into &'static str34abd0dMerge remote-tracking branch 'upstream/dev' into dithering-and-noise-shaping📊 Changes
20 files changed (+339 additions, -100 deletions)
View changed files
📝
CHANGELOG.md(+1 -0)📝
Cargo.lock(+19 -2)📝
playback/Cargo.toml(+4 -0)📝
playback/src/audio_backend/alsa.rs(+1 -0)📝
playback/src/audio_backend/gstreamer.rs(+3 -2)📝
playback/src/audio_backend/jackaudio.rs(+2 -3)📝
playback/src/audio_backend/mod.rs(+16 -22)📝
playback/src/audio_backend/pipe.rs(+1 -1)📝
playback/src/audio_backend/portaudio.rs(+8 -11)📝
playback/src/audio_backend/pulseaudio.rs(+1 -0)📝
playback/src/audio_backend/rodio.rs(+3 -5)📝
playback/src/audio_backend/sdl.rs(+4 -4)📝
playback/src/audio_backend/subprocess.rs(+1 -0)📝
playback/src/config.rs(+11 -4)📝
playback/src/convert.rs(+86 -39)📝
playback/src/decoder/libvorbis_decoder.rs(+1 -4)➕
playback/src/dither.rs(+138 -0)📝
playback/src/lib.rs(+1 -0)📝
playback/src/player.rs(+6 -1)📝
src/main.rs(+32 -2)📄 Description
Dithering lowers digital-to-analog conversion ("requantization") error, linearizing output, lowering distortion and replacing it with a constant, fixed noise level, which is more pleasant to the ear than the distortion.
Guidance:
On S24, S24_3 and S24, the default is to use triangular dithering. Depending on personal preference you may use Gaussian dithering instead; it's not as good objectively, but it may be preferred subjectively if you are looking for a more "analog" sound akin to tape hiss.
Advanced users who know that they have a DAC without noise shaping have a third option: high-passed dithering, which is like triangular dithering except that it moves dithering noise up in frequency where it is less audible. Note: 99% of DACs are of delta-sigma design with noise shaping, so unless you have a multibit / R2R DAC, or otherwise know what you are doing, this is not for you.
Don't dither or shape noise on S32 or F32. On F32 it's not supported anyway (there are no integer conversions and so no rounding errors) and on S32 the noise level is so far down that it is simply inaudible even after volume normalisation and control.
New command line option:
Notes:
This PR also features some opportunistic improvements. Worthy of mention are:
convertAPI🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.