11use std:: { mem, str:: FromStr , time:: Duration } ;
22
33pub use crate :: dither:: { mk_ditherer, DithererBuilder , TriangularDitherer } ;
4- use crate :: { convert:: i24, player :: duration_to_coefficient , RESAMPLER_INPUT_SIZE , SAMPLE_RATE } ;
4+ use crate :: { convert:: i24, RESAMPLER_INPUT_SIZE , SAMPLE_RATE } ;
55
66// Reciprocals allow us to multiply instead of divide during interpolation.
77const HZ48000_RESAMPLE_FACTOR_RECIPROCAL : f64 = SAMPLE_RATE as f64 / 48_000.0 ;
@@ -152,10 +152,12 @@ impl FromStr for SampleRate {
152152 fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
153153 use SampleRate :: * ;
154154
155+ let lowercase_input = s. to_lowercase ( ) ;
156+
155157 // Match against both the actual
156158 // stringified value and how most
157159 // humans would write a sample rate.
158- match s . to_uppercase ( ) . as_ref ( ) {
160+ match lowercase_input . as_str ( ) {
159161 "hz44100" | "44100hz" | "44100" | "44.1khz" => Ok ( Hz44100 ) ,
160162 "hz48000" | "48000hz" | "48000" | "48khz" => Ok ( Hz48000 ) ,
161163 "hz88200" | "88200hz" | "88200" | "88.2khz" => Ok ( Hz88200 ) ,
@@ -348,6 +350,9 @@ pub struct PlayerConfig {
348350 pub gapless : bool ,
349351 pub passthrough : bool ,
350352
353+ pub interpolation_quality : InterpolationQuality ,
354+ pub sample_rate : SampleRate ,
355+
351356 pub normalisation : bool ,
352357 pub normalisation_type : NormalisationType ,
353358 pub normalisation_method : NormalisationMethod ,
@@ -368,12 +373,17 @@ impl Default for PlayerConfig {
368373 bitrate : Bitrate :: default ( ) ,
369374 gapless : true ,
370375 normalisation : false ,
376+ interpolation_quality : InterpolationQuality :: default ( ) ,
377+ sample_rate : SampleRate :: default ( ) ,
371378 normalisation_type : NormalisationType :: default ( ) ,
372379 normalisation_method : NormalisationMethod :: default ( ) ,
373380 normalisation_pregain_db : 0.0 ,
374381 normalisation_threshold_dbfs : -2.0 ,
375- normalisation_attack_cf : duration_to_coefficient ( Duration :: from_millis ( 5 ) ) ,
376- normalisation_release_cf : duration_to_coefficient ( Duration :: from_millis ( 100 ) ) ,
382+ // Dummy value. We can't use the default because
383+ // no matter what it's dependent on the sample rate.
384+ normalisation_attack_cf : 0.0 ,
385+ // Same with release.
386+ normalisation_release_cf : 0.0 ,
377387 normalisation_knee_db : 5.0 ,
378388 passthrough : false ,
379389 ditherer : Some ( mk_ditherer :: < TriangularDitherer > ) ,
0 commit comments