Skip to content

Commit

Permalink
fix default dithering behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
eladyn committed May 7, 2024
1 parent 91d1503 commit d0bd81e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ use gethostname::gethostname;
use librespot_core::{
cache::Cache, config::DeviceType as LSDeviceType, config::SessionConfig, version,
};
use librespot_playback::config::{
AudioFormat as LSAudioFormat, Bitrate as LSBitrate, PlayerConfig,
use librespot_playback::{
config::{AudioFormat as LSAudioFormat, Bitrate as LSBitrate, PlayerConfig},
dither::{mk_ditherer, DithererBuilder, TriangularDitherer},
};
use log::{error, info, warn};
use serde::{de::Error, de::Unexpected, Deserialize, Deserializer};
Expand Down Expand Up @@ -829,6 +830,14 @@ pub(crate) fn get_internal_config(config: CliConfig) -> SpotifydConfig {
None => info!("No proxy specified"),
}

// choose default ditherer the same way librespot does
let ditherer: Option<DithererBuilder> = match audio_format {
LSAudioFormat::S16 | LSAudioFormat::S24 | LSAudioFormat::S24_3 => {
Some(mk_ditherer::<TriangularDitherer>)
}
_ => None,
};

// TODO: when we were on librespot 0.1.5, all PlayerConfig values were available in the
// Spotifyd config. The upgrade to librespot 0.2.0 introduces new config variables, and we
// should consider adding them to Spotifyd's config system.
Expand All @@ -837,6 +846,7 @@ pub(crate) fn get_internal_config(config: CliConfig) -> SpotifydConfig {
normalisation: config.shared_config.volume_normalisation,
normalisation_pregain_db: normalisation_pregain,
gapless: true,
ditherer,
..Default::default()
};

Expand Down

0 comments on commit d0bd81e

Please sign in to comment.