From 33225ccda690345afeac80e8bfe3f9924ade8482 Mon Sep 17 00:00:00 2001 From: JasonLG1979 Date: Tue, 4 Jul 2023 18:34:57 -0500 Subject: [PATCH] New filter coeff's and only have one quality setting. --- playback/src/config.rs | 173 +-- playback/src/filter_coefficients.rs | 1952 +++++++++++---------------- playback/src/resampler.rs | 52 +- playback/src/sample_pipeline.rs | 3 +- src/main.rs | 37 +- 5 files changed, 869 insertions(+), 1348 deletions(-) diff --git a/playback/src/config.rs b/playback/src/config.rs index 85449eb48..e2fafda29 100644 --- a/playback/src/config.rs +++ b/playback/src/config.rs @@ -4,9 +4,7 @@ pub use crate::dither::{mk_ditherer, DithererBuilder, TriangularDitherer}; use crate::{ convert::i24, - filter_coefficients::{ - HZ48000_HIGH, HZ48000_LOW, HZ88200_HIGH, HZ88200_LOW, HZ96000_HIGH, HZ96000_LOW, - }, + filter_coefficients::{HZ48000_COEFFICIENTS, HZ88200_COEFFICIENTS, HZ96000_COEFFICIENTS}, RESAMPLER_INPUT_SIZE, SAMPLE_RATE, }; @@ -33,69 +31,6 @@ const HZ88200_INTERPOLATION_OUTPUT_SIZE: usize = const HZ96000_INTERPOLATION_OUTPUT_SIZE: usize = (RESAMPLER_INPUT_SIZE as f64 * (1.0 / HZ96000_RESAMPLE_FACTOR_RECIPROCAL)) as usize; -#[derive(Clone, Copy, Debug, Default)] -pub enum InterpolationQuality { - Low, - #[default] - High, -} - -impl FromStr for InterpolationQuality { - type Err = (); - - fn from_str(s: &str) -> Result { - use InterpolationQuality::*; - - match s.to_lowercase().as_ref() { - "low" => Ok(Low), - "high" => Ok(High), - _ => Err(()), - } - } -} - -impl std::fmt::Display for InterpolationQuality { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - use InterpolationQuality::*; - - match self { - Low => write!(f, "Low"), - High => write!(f, "High"), - } - } -} - -impl InterpolationQuality { - pub fn get_interpolation_coefficients( - &self, - mut coefficients: Vec, - resample_factor_reciprocal: f64, - ) -> Vec { - let mut coefficient_sum = 0.0; - - for (index, coefficient) in coefficients.iter_mut().enumerate() { - *coefficient *= Self::sinc((index as f64 * resample_factor_reciprocal).fract()); - - coefficient_sum += *coefficient; - } - - coefficients - .iter_mut() - .for_each(|coefficient| *coefficient /= coefficient_sum); - - coefficients - } - - fn sinc(x: f64) -> f64 { - if x.abs() < f64::EPSILON { - 1.0 - } else { - let pi_x = std::f64::consts::PI * x; - pi_x.sin() / pi_x - } - } -} - #[derive(Clone, Copy, Debug, Default)] pub enum SampleRate { #[default] @@ -152,14 +87,6 @@ impl std::fmt::Display for SampleRate { } } -#[derive(Debug, Default)] -pub struct ResampleSpec { - pub resample_factor_reciprocal: f64, - pub interpolation_output_size: usize, - pub high_coefficients: Vec, - pub low_coefficients: Vec, -} - impl SampleRate { pub fn as_u32(&self) -> u32 { use SampleRate::*; @@ -207,41 +134,73 @@ impl SampleRate { } } - pub fn get_resample_spec(&self) -> ResampleSpec { + pub fn get_resample_factor_reciprocal(&self) -> Option { + use SampleRate::*; + + match self { + Hz44100 => None, + Hz48000 => Some(HZ48000_RESAMPLE_FACTOR_RECIPROCAL), + Hz88200 => Some(HZ88200_RESAMPLE_FACTOR_RECIPROCAL), + Hz96000 => Some(HZ96000_RESAMPLE_FACTOR_RECIPROCAL), + } + } + + pub fn get_interpolation_output_size(&self) -> Option { use SampleRate::*; match self { - // Dummy values to satisfy - // the match statement. - // 44.1kHz will be bypassed. - Hz44100 => { - warn!("Resampling 44.1kHz to 44.1kHz is just a really CPU intensive no-op, you should not be doing it"); - - ResampleSpec { - resample_factor_reciprocal: 1.0, - interpolation_output_size: RESAMPLER_INPUT_SIZE, - high_coefficients: vec![], - low_coefficients: vec![], - } - } - Hz48000 => ResampleSpec { - resample_factor_reciprocal: HZ48000_RESAMPLE_FACTOR_RECIPROCAL, - interpolation_output_size: HZ48000_INTERPOLATION_OUTPUT_SIZE, - high_coefficients: HZ48000_HIGH.to_vec(), - low_coefficients: HZ48000_LOW.to_vec(), - }, - Hz88200 => ResampleSpec { - resample_factor_reciprocal: HZ88200_RESAMPLE_FACTOR_RECIPROCAL, - interpolation_output_size: HZ88200_INTERPOLATION_OUTPUT_SIZE, - high_coefficients: HZ88200_HIGH.to_vec(), - low_coefficients: HZ88200_LOW.to_vec(), - }, - Hz96000 => ResampleSpec { - resample_factor_reciprocal: HZ96000_RESAMPLE_FACTOR_RECIPROCAL, - interpolation_output_size: HZ96000_INTERPOLATION_OUTPUT_SIZE, - high_coefficients: HZ96000_HIGH.to_vec(), - low_coefficients: HZ96000_LOW.to_vec(), - }, + Hz44100 => None, + Hz48000 => Some(HZ48000_INTERPOLATION_OUTPUT_SIZE), + Hz88200 => Some(HZ88200_INTERPOLATION_OUTPUT_SIZE), + Hz96000 => Some(HZ96000_INTERPOLATION_OUTPUT_SIZE), + } + } + + pub fn get_interpolation_coefficients(&self) -> Option> { + use SampleRate::*; + + match self { + Hz44100 => None, + Hz48000 => Some(Self::calculate_interpolation_coefficients( + HZ48000_COEFFICIENTS.to_vec(), + HZ48000_RESAMPLE_FACTOR_RECIPROCAL, + )), + Hz88200 => Some(Self::calculate_interpolation_coefficients( + HZ88200_COEFFICIENTS.to_vec(), + HZ88200_RESAMPLE_FACTOR_RECIPROCAL, + )), + Hz96000 => Some(Self::calculate_interpolation_coefficients( + HZ96000_COEFFICIENTS.to_vec(), + HZ96000_RESAMPLE_FACTOR_RECIPROCAL, + )), + } + } + + fn calculate_interpolation_coefficients( + mut coefficients: Vec, + resample_factor_reciprocal: f64, + ) -> Vec { + let mut coefficient_sum = 0.0; + + for (index, coefficient) in coefficients.iter_mut().enumerate() { + *coefficient *= Self::sinc((index as f64 * resample_factor_reciprocal).fract()); + + coefficient_sum += *coefficient; + } + + coefficients + .iter_mut() + .for_each(|coefficient| *coefficient /= coefficient_sum); + + coefficients + } + + fn sinc(x: f64) -> f64 { + if x.abs() < f64::EPSILON { + 1.0 + } else { + let pi_x = std::f64::consts::PI * x; + pi_x.sin() / pi_x } } } @@ -361,7 +320,6 @@ pub struct PlayerConfig { pub gapless: bool, pub passthrough: bool, - pub interpolation_quality: InterpolationQuality, pub sample_rate: SampleRate, pub normalisation: bool, @@ -384,7 +342,6 @@ impl Default for PlayerConfig { bitrate: Bitrate::default(), gapless: true, normalisation: false, - interpolation_quality: InterpolationQuality::default(), sample_rate: SampleRate::default(), normalisation_type: NormalisationType::default(), normalisation_method: NormalisationMethod::default(), diff --git a/playback/src/filter_coefficients.rs b/playback/src/filter_coefficients.rs index 96a2c42b7..38bc46eba 100644 --- a/playback/src/filter_coefficients.rs +++ b/playback/src/filter_coefficients.rs @@ -2,1186 +2,782 @@ // https://github.com/chipmuenk/pyfda // Window = Kaiser // beta = 8.6 (Similar to a Blackman Window) -// fc = 22.5kHz -// -86dB by 23kHz -#[allow(clippy::excessive_precision)] -pub const HZ48000_HIGH: [f64; 257] = [ - -1.4287799853519804e-19, - -8.529928242661527e-07, - 2.1395999264221267e-06, - -3.880458963785995e-06, - 6.05893601403254e-06, - -8.613527303281799e-06, - 1.1432294466108613e-05, - -1.4350136921309217e-05, - 1.7149627991629572e-05, - -1.956600058898423e-05, - 2.1296664705444228e-05, - -2.201537812656286e-05, - 2.1390883855947267e-05, - -1.9109487313809015e-05, - 1.490069206906713e-05, - -8.564666558168402e-06, - -2.4187562985455694e-19, - 1.0770051522629687e-05, - -2.357480377576126e-05, - 3.80789154370508e-05, - -5.37726902353467e-05, - 6.997172608513909e-05, - -8.582740473543781e-05, - 0.0001003492559243388, - -0.00011243964464523357, - 0.00012094053924787859, - -0.0001246913509069703, - 0.00012259602869291528, - -0.00011369679289372431, - 9.725114087319391e-05, - -7.280811540502643e-05, - 4.027933539700687e-05, - -8.761722338284784e-19, - -4.7224970562679786e-05, - 0.0001000942700094669, - -0.00015680711547266284, - 0.00021508702286534775, - -0.00027223465216542913, - 0.00032521058924288055, - -0.00037074739096535606, - 0.00040548854166410335, - -0.00042615022958145474, - 0.0004297001408507999, - -0.00041354588242148774, - 0.00037572428338265103, - -0.0003150817831073127, - 0.00023143548325566652, - -0.00012570429408715404, - 8.736848542712518e-18, - 0.00014233096258373752, - -0.00029672267470682895, - 0.00045746741021428363, - -0.0006178587763843014, - 0.0007704002699025563, - -0.0009070758950716863, - 0.0010196760363510072, - -0.001100168333253743, - 0.0011411000481453986, - -0.0011360155279515375, - 0.0010798700171927062, - -0.0009694194473815131, - 0.0008035650497546995, - -0.0005836318265664195, - 0.0003135611435773604, - -3.649849800074037e-17, - -0.0003477271314898191, - 0.0007177736996011124, - -0.0010960583702874734, - 0.0014666830951029159, - -0.0018124745987316703, - 0.0021156355406508768, - -0.0023584853377038536, - 0.002524264795160409, - -0.0025979735902941564, - 0.0025672055778467244, - -0.002422944105830126, - 0.0021602782649567656, - -0.0017790014114850766, - 0.001284055499878637, - -0.0006857887606066072, - 7.209995999923543e-18, - 0.000752249860282943, - -0.0015450696726810457, - 0.0023484142653889145, - -0.003128995352023552, - 0.00385140677724417, - -0.004479433137231434, - 0.004977500880593015, - -0.005312222191564676, - 0.005453974732678532, - -0.005378455081534177, - 0.005068140772503758, - -0.004513595500789128, - 0.003714554414731469, - -0.0026807315526779464, - 0.0014322992948101853, - -8.297338214945322e-17, - -0.001575137531433456, - 0.003242489907858635, - -0.004942936992960944, - 0.006610347331237228, - -0.008173416627546943, - 0.009557809308226558, - -0.010688539065884867, - 0.011492512118343826, - -0.011901147266026046, - 0.01185298019699458, - -0.011296156240663045, - 0.01019071615665419, - -0.00851058366772981, - 0.006245171256720193, - -0.0034005320447053696, - 1.0063905996254467e-16, - 0.003915722194550309, - -0.008289049174613953, - 0.013046573943979376, - -0.01810068406300195, - 0.023351692368405477, - -0.02869042197225499, - 0.03400116752010972, - -0.03916493952679325, - 0.044062886688337265, - -0.04857978290438118, - 0.052607461706064784, - -0.056048081078209105, - 0.058817106327538726, - -0.06084590754218613, - 0.06208388100251895, - 0.9375003025680546, - 0.06208388100251895, - -0.06084590754218613, - 0.058817106327538726, - -0.056048081078209105, - 0.052607461706064784, - -0.04857978290438118, - 0.044062886688337265, - -0.03916493952679325, - 0.03400116752010972, - -0.02869042197225499, - 0.023351692368405477, - -0.01810068406300195, - 0.013046573943979376, - -0.008289049174613953, - 0.003915722194550309, - 1.0063905996254467e-16, - -0.0034005320447053696, - 0.006245171256720193, - -0.00851058366772981, - 0.01019071615665419, - -0.011296156240663045, - 0.01185298019699458, - -0.011901147266026046, - 0.011492512118343826, - -0.010688539065884867, - 0.009557809308226558, - -0.008173416627546943, - 0.006610347331237228, - -0.004942936992960944, - 0.003242489907858635, - -0.001575137531433456, - -8.297338214945322e-17, - 0.0014322992948101853, - -0.0026807315526779464, - 0.003714554414731469, - -0.004513595500789128, - 0.005068140772503758, - -0.005378455081534177, - 0.005453974732678532, - -0.005312222191564676, - 0.004977500880593015, - -0.004479433137231434, - 0.00385140677724417, - -0.003128995352023552, - 0.0023484142653889145, - -0.0015450696726810457, - 0.000752249860282943, - 7.209995999923543e-18, - -0.0006857887606066072, - 0.001284055499878637, - -0.0017790014114850766, - 0.0021602782649567656, - -0.002422944105830126, - 0.0025672055778467244, - -0.0025979735902941564, - 0.002524264795160409, - -0.0023584853377038536, - 0.0021156355406508768, - -0.0018124745987316703, - 0.0014666830951029159, - -0.0010960583702874734, - 0.0007177736996011124, - -0.0003477271314898191, - -3.649849800074037e-17, - 0.0003135611435773604, - -0.0005836318265664195, - 0.0008035650497546995, - -0.0009694194473815131, - 0.0010798700171927062, - -0.0011360155279515375, - 0.0011411000481453986, - -0.001100168333253743, - 0.0010196760363510072, - -0.0009070758950716863, - 0.0007704002699025563, - -0.0006178587763843014, - 0.00045746741021428363, - -0.00029672267470682895, - 0.00014233096258373752, - 8.736848542712518e-18, - -0.00012570429408715404, - 0.00023143548325566652, - -0.0003150817831073127, - 0.00037572428338265103, - -0.00041354588242148774, - 0.0004297001408507999, - -0.00042615022958145474, - 0.00040548854166410335, - -0.00037074739096535606, - 0.00032521058924288055, - -0.00027223465216542913, - 0.00021508702286534775, - -0.00015680711547266284, - 0.0001000942700094669, - -4.7224970562679786e-05, - -8.761722338284784e-19, - 4.027933539700687e-05, - -7.280811540502643e-05, - 9.725114087319391e-05, - -0.00011369679289372431, - 0.00012259602869291528, - -0.0001246913509069703, - 0.00012094053924787859, - -0.00011243964464523357, - 0.0001003492559243388, - -8.582740473543781e-05, - 6.997172608513909e-05, - -5.37726902353467e-05, - 3.80789154370508e-05, - -2.357480377576126e-05, - 1.0770051522629687e-05, - -2.4187562985455694e-19, - -8.564666558168402e-06, - 1.490069206906713e-05, - -1.9109487313809015e-05, - 2.1390883855947267e-05, - -2.201537812656286e-05, - 2.1296664705444228e-05, - -1.956600058898423e-05, - 1.7149627991629572e-05, - -1.4350136921309217e-05, - 1.1432294466108613e-05, - -8.613527303281799e-06, - 6.05893601403254e-06, - -3.880458963785995e-06, - 2.1395999264221267e-06, - -8.529928242661527e-07, - -1.4287799853519804e-19, +// fc = 22.8kHz +// -86dB well before 23kHz +// The assumption is that the input +// is anti-aliased properly, +// We just want to make sure interpolation +// doesn't add any artifacts. +pub const HZ48000_COEFFICIENTS: [f64; 255] = [ + 0.0000029757601319148547, + -0.0000035724038783700253, + 0.000003999229563120952, + -0.0000041586119519154335, + 0.000003945019406365531, + -0.0000032497776047015684, + 0.00000196692150277904, + 0.00000000000000000032088934154742766, + -0.000002730372012221083, + 0.000006278488369190174, + -0.000010665391641951627, + 0.000015870973207315936, + -0.000021826772577812116, + 0.00002840994425409373, + -0.000035438870844899246, + 0.000042670890395564696, + -0.0000498025717562113, + 0.00005647291323352919, + -0.0000622697565195043, + 0.00006673960088257324, + -0.00006940087390721415, + 0.00006976056792505907, + -0.0000673339900974517, + 0.0000616672043642141, + -0.00005236157158501689, + 0.00003909962734139897, + -0.000021671382730759723, + 0.00000000000000000014775794500939835, + 0.00002583431010568344, + -0.00005557339141539353, + 0.00008876449432687902, + -0.00012474910335619904, + 0.00016265839263500569, + -0.00020141633272562916, + 0.000239751287905558, + -0.0002762167054284902, + 0.0003092212112721526, + -0.0003370680969546191, + 0.00035800381784808707, + -0.0003702747358945199, + 0.00037219094147791126, + -0.00036219559473883636, + 0.0003389378512621098, + -0.0003013470968891303, + 0.0002487059275217649, + -0.00018071908775933306, + 0.00009757544142130711, + -0.000000000000000015631999385489426, + -0.00011070690803839188, + 0.0002326460763402858, + -0.00036331393497998876, + 0.0004996172102242244, + -0.0006379092936400055, + 0.000774049277248856, + -0.0009034839165549037, + 0.001021352018045881, + -0.001122609933353972, + 0.0012021760031783496, + -0.0012550909575157827, + 0.0012766904738419514, + -0.00126278535176025, + 0.0012098441114307354, + -0.0011151722929066716, + 0.0009770823513048355, + -0.000795047832277434, + 0.0005698354930579571, + -0.00030360922076259406, + -0.00000000000000002201626525119935, + 0.00033586320211808853, + -0.0006973659391491813, + 0.0010764674583817267, + -0.0014638086241148443, + 0.001848869319762443, + -0.002220174589015615, + 0.002565547230823385, + -0.0028724029846969794, + 0.003128082879766998, + -0.0033202158232846207, + 0.0034371031226941066, + -0.003468115419918644, + 0.003404091514354354, + -0.003237727805246149, + 0.002963946631713016, + -0.0025802316594287834, + 0.00208691867791818, + -0.0014874307429276622, + 0.0007884475251988019, + -0.00000000000000006205894710359984, + -0.0008645167903853754, + 0.001788418278669237, + -0.002751895456339609, + 0.0037322713985924625, + -0.004704347654507773, + 0.0056408363807764405, + -0.006512871552708505, + 0.007290590117269429, + -0.007943771634413503, + 0.008442522858140263, + -0.00875799190650071, + 0.008863095222899556, + -0.008733239493676851, + 0.008347020102916623, + -0.0076868776065113125, + 0.006739694112159513, + -0.0054973123643820895, + 0.003956961743222636, + -0.0021215772666537125, + 0.0000000000000000846011988918187, + 0.002392950032502607, + -0.005036534334234289, + 0.00790429247981098, + -0.010964373981796057, + 0.014180001292666397, + -0.01751005633403422, + 0.020909779653996083, + -0.024331568244693277, + 0.02772585529430791, + -0.03104205278181687, + 0.03422953591997324, + -0.03723864707102664, + 0.040021695945377404, + -0.04253393267486045, + 0.044734470742229165, + -0.046587137742103886, + 0.048061233524464494, + -0.049132177391356405, + 0.04978202862690666, + 0.9499974857664107, + 0.04978202862690666, + -0.049132177391356405, + 0.048061233524464494, + -0.046587137742103886, + 0.044734470742229165, + -0.04253393267486045, + 0.040021695945377404, + -0.03723864707102664, + 0.03422953591997324, + -0.03104205278181687, + 0.02772585529430791, + -0.024331568244693277, + 0.020909779653996083, + -0.01751005633403422, + 0.014180001292666397, + -0.010964373981796057, + 0.00790429247981098, + -0.005036534334234289, + 0.002392950032502607, + 0.0000000000000000846011988918187, + -0.0021215772666537125, + 0.003956961743222636, + -0.0054973123643820895, + 0.006739694112159513, + -0.0076868776065113125, + 0.008347020102916623, + -0.008733239493676851, + 0.008863095222899556, + -0.00875799190650071, + 0.008442522858140263, + -0.007943771634413503, + 0.007290590117269429, + -0.006512871552708505, + 0.0056408363807764405, + -0.004704347654507773, + 0.0037322713985924625, + -0.002751895456339609, + 0.001788418278669237, + -0.0008645167903853754, + -0.00000000000000006205894710359984, + 0.0007884475251988019, + -0.0014874307429276622, + 0.00208691867791818, + -0.0025802316594287834, + 0.002963946631713016, + -0.003237727805246149, + 0.003404091514354354, + -0.003468115419918644, + 0.0034371031226941066, + -0.0033202158232846207, + 0.003128082879766998, + -0.0028724029846969794, + 0.002565547230823385, + -0.002220174589015615, + 0.001848869319762443, + -0.0014638086241148443, + 0.0010764674583817267, + -0.0006973659391491813, + 0.00033586320211808853, + -0.00000000000000002201626525119935, + -0.00030360922076259406, + 0.0005698354930579571, + -0.000795047832277434, + 0.0009770823513048355, + -0.0011151722929066716, + 0.0012098441114307354, + -0.00126278535176025, + 0.0012766904738419514, + -0.0012550909575157827, + 0.0012021760031783496, + -0.001122609933353972, + 0.001021352018045881, + -0.0009034839165549037, + 0.000774049277248856, + -0.0006379092936400055, + 0.0004996172102242244, + -0.00036331393497998876, + 0.0002326460763402858, + -0.00011070690803839188, + -0.000000000000000015631999385489426, + 0.00009757544142130711, + -0.00018071908775933306, + 0.0002487059275217649, + -0.0003013470968891303, + 0.0003389378512621098, + -0.00036219559473883636, + 0.00037219094147791126, + -0.0003702747358945199, + 0.00035800381784808707, + -0.0003370680969546191, + 0.0003092212112721526, + -0.0002762167054284902, + 0.000239751287905558, + -0.00020141633272562916, + 0.00016265839263500569, + -0.00012474910335619904, + 0.00008876449432687902, + -0.00005557339141539353, + 0.00002583431010568344, + 0.00000000000000000014775794500939835, + -0.000021671382730759723, + 0.00003909962734139897, + -0.00005236157158501689, + 0.0000616672043642141, + -0.0000673339900974517, + 0.00006976056792505907, + -0.00006940087390721415, + 0.00006673960088257324, + -0.0000622697565195043, + 0.00005647291323352919, + -0.0000498025717562113, + 0.000042670890395564696, + -0.000035438870844899246, + 0.00002840994425409373, + -0.000021826772577812116, + 0.000015870973207315936, + -0.000010665391641951627, + 0.000006278488369190174, + -0.000002730372012221083, + 0.00000000000000000032088934154742766, + 0.00000196692150277904, + -0.0000032497776047015684, + 0.000003945019406365531, + -0.0000041586119519154335, + 0.000003999229563120952, + -0.0000035724038783700253, + 0.0000029757601319148547, ]; -#[allow(clippy::excessive_precision)] -pub const HZ88200_HIGH: [f64; 257] = [ - -2.7177973650537016e-06, - 2.615116391456718e-06, - 4.371253470079787e-06, - -4.527642205236769e-06, - -6.343166732321034e-06, - 7.206853357278462e-06, - 8.608531809529578e-06, - -1.0831207319855358e-05, - -1.11168738348255e-05, - 1.5597004565971875e-05, - 1.3787248972132889e-05, - -2.1716246512168148e-05, - -1.6503125021559895e-05, - 2.9413629227200937e-05, - 1.9107254724178818e-05, - -3.8922617925675015e-05, - -2.139666772922098e-05, - 5.04805630067818e-05, - 2.3117918532840763e-05, - -6.432283649476294e-05, - -2.396273660981686e-05, - 8.067598787603222e-05, - 2.3564231002785538e-05, - -9.974994011030785e-05, - -2.149380441843341e-05, - 0.00012172926954179013, - 1.7258931076241913e-05, - -0.00014676363699943706, - -1.030194790401862e-05, - 0.0001749574609349626, - 1.8686890713852827e-19, - -0.0002063589463295164, - 1.4333731499066454e-05, - 0.00024094860458611302, - -3.344740787382722e-05, - -0.0002786274189628284, - 5.814642716712084e-05, - 0.00031920482651865724, - -8.928776855240112e-05, - -0.0003623867002575848, - 0.0001277727488249831, - 0.0004077635233859557, - -0.00017453818403045162, - -0.00045479895057210033, - 0.0002305459825657413, - 0.000502818948057389, - -0.00029677123118056025, - -0.000551001694669649, - 0.00037418887145730905, - 0.0005983684084941591, - -0.00046375910077735565, - -0.0006437752384124257, - 0.0005664116676635973, - 0.0006859063251323009, - -0.0006830292658687915, - -0.0007232680918226466, - 0.0008144302637888361, - 0.000754184768991671, - -0.0009613510348663591, - -0.0007767950905092509, - 0.0011244281797910076, - 0.0007890500159662434, - -0.0013041809517326277, - -0.000788711236573936, - 0.0015009942108703117, - 0.00077335010432126, - -0.00171510224350985, - -0.0007403464826028671, - 0.0019465737836333772, - 0.0006868868445776879, - -0.002195298570445892, - -0.0006099607339225542, - 0.002460975764167073, - 0.0005063544381987515, - -0.002743104523907686, - -0.00037264038864942025, - 0.003040977026074337, - 0.00020516036410315268, - -0.0033536741696310896, - -1.7263210195899785e-18, - 0.0036800641761425457, - -0.0002470486740043912, - -0.004018804248416292, - 0.0005405410133353366, - 0.004368345402486541, - -0.000885455697808869, - -0.004726940534504569, - 0.0012873008119620815, - 0.005092655727810584, - -0.001752261157027223, - -0.005463384747140825, - 0.0022874024955170562, - 0.005836866607731414, - -0.002900955402436162, - -0.006210706048228085, - 0.0036027121698355103, - 0.006582396679029297, - -0.0044045872407267005, - -0.006949346523208571, - 0.005321419255211435, - 0.007308905616676035, - -0.00637213881767667, - -0.007658395288879785, - 0.007581505281049055, - 0.00799513870616462, - -0.008982757034954967, - -0.008316492227824646, - 0.010621782037025395, - 0.00861987710070591, - -0.012563926080135948, - -0.008902811002566763, - 0.01490560790319659, - 0.0091629389377553, - -0.017795223882502632, - -0.009398062991380806, - 0.021473342249052296, - 0.009606170460125666, - -0.026356732255292163, - -0.009785459899039199, - 0.033234410282523816, - 0.009934364653757865, - -0.04379972993086113, - -0.010051573486085123, - 0.06245943058441552, - 0.01013604794705137, - -0.1053787714300839, - -0.010187036204577683, - 0.31806791600342954, - 0.5102041545837825, - 0.31806791600342954, - -0.010187036204577683, - -0.1053787714300839, - 0.01013604794705137, - 0.06245943058441552, - -0.010051573486085123, - -0.04379972993086113, - 0.009934364653757865, - 0.033234410282523816, - -0.009785459899039199, - -0.026356732255292163, - 0.009606170460125666, - 0.021473342249052296, - -0.009398062991380806, - -0.017795223882502632, - 0.0091629389377553, - 0.01490560790319659, - -0.008902811002566763, - -0.012563926080135948, - 0.00861987710070591, - 0.010621782037025395, - -0.008316492227824646, - -0.008982757034954967, - 0.00799513870616462, - 0.007581505281049055, - -0.007658395288879785, - -0.00637213881767667, - 0.007308905616676035, - 0.005321419255211435, - -0.006949346523208571, - -0.0044045872407267005, - 0.006582396679029297, - 0.0036027121698355103, - -0.006210706048228085, - -0.002900955402436162, - 0.005836866607731414, - 0.0022874024955170562, - -0.005463384747140825, - -0.001752261157027223, - 0.005092655727810584, - 0.0012873008119620815, - -0.004726940534504569, - -0.000885455697808869, - 0.004368345402486541, - 0.0005405410133353366, - -0.004018804248416292, - -0.0002470486740043912, - 0.0036800641761425457, - -1.7263210195899785e-18, - -0.0033536741696310896, - 0.00020516036410315268, - 0.003040977026074337, - -0.00037264038864942025, - -0.002743104523907686, - 0.0005063544381987515, - 0.002460975764167073, - -0.0006099607339225542, - -0.002195298570445892, - 0.0006868868445776879, - 0.0019465737836333772, - -0.0007403464826028671, - -0.00171510224350985, - 0.00077335010432126, - 0.0015009942108703117, - -0.000788711236573936, - -0.0013041809517326277, - 0.0007890500159662434, - 0.0011244281797910076, - -0.0007767950905092509, - -0.0009613510348663591, - 0.000754184768991671, - 0.0008144302637888361, - -0.0007232680918226466, - -0.0006830292658687915, - 0.0006859063251323009, - 0.0005664116676635973, - -0.0006437752384124257, - -0.00046375910077735565, - 0.0005983684084941591, - 0.00037418887145730905, - -0.000551001694669649, - -0.00029677123118056025, - 0.000502818948057389, - 0.0002305459825657413, - -0.00045479895057210033, - -0.00017453818403045162, - 0.0004077635233859557, - 0.0001277727488249831, - -0.0003623867002575848, - -8.928776855240112e-05, - 0.00031920482651865724, - 5.814642716712084e-05, - -0.0002786274189628284, - -3.344740787382722e-05, - 0.00024094860458611302, - 1.4333731499066454e-05, - -0.0002063589463295164, - 1.8686890713852827e-19, - 0.0001749574609349626, - -1.030194790401862e-05, - -0.00014676363699943706, - 1.7258931076241913e-05, - 0.00012172926954179013, - -2.149380441843341e-05, - -9.974994011030785e-05, - 2.3564231002785538e-05, - 8.067598787603222e-05, - -2.396273660981686e-05, - -6.432283649476294e-05, - 2.3117918532840763e-05, - 5.04805630067818e-05, - -2.139666772922098e-05, - -3.8922617925675015e-05, - 1.9107254724178818e-05, - 2.9413629227200937e-05, - -1.6503125021559895e-05, - -2.1716246512168148e-05, - 1.3787248972132889e-05, - 1.5597004565971875e-05, - -1.11168738348255e-05, - -1.0831207319855358e-05, - 8.608531809529578e-06, - 7.206853357278462e-06, - -6.343166732321034e-06, - -4.527642205236769e-06, - 4.371253470079787e-06, - 2.615116391456718e-06, - -2.7177973650537016e-06, +pub const HZ88200_COEFFICIENTS: [f64; 255] = [ + -0.0000029273716821419844, + -0.000001915927146548871, + 0.000005219477217215506, + 0.000002372402872839042, + -0.000008330541892509816, + -0.0000024495798339045213, + 0.00001236664398017211, + 0.000001902734096077155, + -0.000017405079644076135, + -0.0000004341851013380535, + 0.00002348062005831949, + -0.0000023054251600118116, + -0.00003057055859026452, + 0.000006712887245818519, + 0.000038579009742008284, + -0.000013224812600752861, + -0.00004732103292895961, + 0.000022306335064421903, + 0.00005650725658972416, + -0.000034435911332705424, + -0.00006572976613223852, + 0.00005008613535216099, + 0.00007445008745258743, + -0.00006970063143912736, + -0.00008199014114192555, + 0.00009366725747067471, + 0.00008752705649756082, + -0.0001222880278348624, + -0.00009009271534231825, + 0.00015574635002274596, + 0.00008857884071692973, + -0.00019407235205592095, + -0.00008174835325426384, + 0.0002371072530375652, + 0.0000682535883750172, + -0.00028446788831476506, + -0.00004666180178561409, + 0.0003355126363098495, + 0.000015488192123332334, + -0.00038931009853386344, + 0.000026763557397966238, + 0.00044461195072122655, + -0.00008155346565913389, + -0.0004998314053955262, + 0.00015025067966387045, + 0.0005530286996599175, + -0.00023407292033321008, + -0.0006019049432393165, + 0.0003340209935341834, + 0.0006438055291286784, + -0.0004508096618206355, + -0.0006757341228525097, + 0.0005847963961125644, + 0.000694378008554235, + -0.0007359097126686615, + -0.0006961452852021643, + 0.0009035789380339908, + 0.0006772140804388555, + -0.0010866673224702102, + -0.0006335935912451262, + 0.0012834104307351845, + 0.0005611963795915633, + -0.001491361668908799, + -0.0004559209590217541, + 0.0017073466491446876, + 0.00031374331718053754, + -0.0019274278434597608, + -0.0001308156429183198, + 0.0021468806260796633, + -0.00009642982170440177, + -0.00236018134426937, + 0.00037117419109281355, + 0.0025610074813160184, + -0.0006961052469236998, + -0.002742249270294127, + 0.0010733134769094976, + 0.002896031264957672, + -0.0015041937804336828, + -0.003013741345201857, + 0.0019893558090264, + 0.003086063381796672, + -0.0025285458503872256, + -0.003103008232572374, + 0.0031205830145178072, + 0.003053935768034646, + -0.0037633122398842253, + -0.002927558032744341, + 0.004453576309795291, + 0.0027119101239030333, + -0.005187208660823071, + -0.002394270396346319, + 0.0059590482854798505, + 0.001961004335237426, + -0.006762977492591828, + -0.0013972954490790723, + 0.007591982705340442, + 0.0006867093788640146, + -0.008438237865199543, + 0.0001894902197481072, + 0.009293209387869551, + -0.001253401423086752, + -0.010147781003567058, + 0.002532125836652939, + 0.01099239622772098, + -0.004060339790609024, + -0.011817215667942006, + 0.005884404177554897, + 0.012612285896753431, + -0.008069132491871982, + -0.013367716223061628, + 0.01070938773733569, + 0.014073859392569126, + -0.013950991939441316, + -0.014721492049452377, + 0.018030948618631207, + 0.015301990706678373, + -0.023361523479218153, + -0.015807499004899122, + 0.030726364654651464, + 0.016231082190882592, + -0.04181268882211351, + -0.016566865013109198, + 0.061020448842538565, + 0.0168101496080043, + -0.10450762784760304, + -0.01695751042529408, + 0.3177771711426954, + 0.5170086595798146, + 0.3177771711426954, + -0.01695751042529408, + -0.10450762784760304, + 0.0168101496080043, + 0.061020448842538565, + -0.016566865013109198, + -0.04181268882211351, + 0.016231082190882592, + 0.030726364654651464, + -0.015807499004899122, + -0.023361523479218153, + 0.015301990706678373, + 0.018030948618631207, + -0.014721492049452377, + -0.013950991939441316, + 0.014073859392569126, + 0.01070938773733569, + -0.013367716223061628, + -0.008069132491871982, + 0.012612285896753431, + 0.005884404177554897, + -0.011817215667942006, + -0.004060339790609024, + 0.01099239622772098, + 0.002532125836652939, + -0.010147781003567058, + -0.001253401423086752, + 0.009293209387869551, + 0.0001894902197481072, + -0.008438237865199543, + 0.0006867093788640146, + 0.007591982705340442, + -0.0013972954490790723, + -0.006762977492591828, + 0.001961004335237426, + 0.0059590482854798505, + -0.002394270396346319, + -0.005187208660823071, + 0.0027119101239030333, + 0.004453576309795291, + -0.002927558032744341, + -0.0037633122398842253, + 0.003053935768034646, + 0.0031205830145178072, + -0.003103008232572374, + -0.0025285458503872256, + 0.003086063381796672, + 0.0019893558090264, + -0.003013741345201857, + -0.0015041937804336828, + 0.002896031264957672, + 0.0010733134769094976, + -0.002742249270294127, + -0.0006961052469236998, + 0.0025610074813160184, + 0.00037117419109281355, + -0.00236018134426937, + -0.00009642982170440177, + 0.0021468806260796633, + -0.0001308156429183198, + -0.0019274278434597608, + 0.00031374331718053754, + 0.0017073466491446876, + -0.0004559209590217541, + -0.001491361668908799, + 0.0005611963795915633, + 0.0012834104307351845, + -0.0006335935912451262, + -0.0010866673224702102, + 0.0006772140804388555, + 0.0009035789380339908, + -0.0006961452852021643, + -0.0007359097126686615, + 0.000694378008554235, + 0.0005847963961125644, + -0.0006757341228525097, + -0.0004508096618206355, + 0.0006438055291286784, + 0.0003340209935341834, + -0.0006019049432393165, + -0.00023407292033321008, + 0.0005530286996599175, + 0.00015025067966387045, + -0.0004998314053955262, + -0.00008155346565913389, + 0.00044461195072122655, + 0.000026763557397966238, + -0.00038931009853386344, + 0.000015488192123332334, + 0.0003355126363098495, + -0.00004666180178561409, + -0.00028446788831476506, + 0.0000682535883750172, + 0.0002371072530375652, + -0.00008174835325426384, + -0.00019407235205592095, + 0.00008857884071692973, + 0.00015574635002274596, + -0.00009009271534231825, + -0.0001222880278348624, + 0.00008752705649756082, + 0.00009366725747067471, + -0.00008199014114192555, + -0.00006970063143912736, + 0.00007445008745258743, + 0.00005008613535216099, + -0.00006572976613223852, + -0.000034435911332705424, + 0.00005650725658972416, + 0.000022306335064421903, + -0.00004732103292895961, + -0.000013224812600752861, + 0.000038579009742008284, + 0.000006712887245818519, + -0.00003057055859026452, + -0.0000023054251600118116, + 0.00002348062005831949, + -0.0000004341851013380535, + -0.000017405079644076135, + 0.000001902734096077155, + 0.00001236664398017211, + -0.0000024495798339045213, + -0.000008330541892509816, + 0.000002372402872839042, + 0.000005219477217215506, + -0.000001915927146548871, + -0.0000029273716821419844, ]; -#[allow(clippy::excessive_precision)] -pub const HZ96000_HIGH: [f64; 257] = [ - -7.143923102926616e-20, - -4.351257283515671e-06, - -1.0907621221693655e-06, - 6.683906965798109e-06, - 3.2790831797631692e-06, - -9.13620584774856e-06, - -6.874774126129371e-06, - 1.1310163453885296e-05, - 1.2126657588758059e-05, - -1.265575645173113e-05, - -1.9166554046744026e-05, - 1.248152779539428e-05, - 2.794862730250771e-05, - -9.984713045871162e-06, - -3.8189337778906546e-05, - 4.303067618516991e-06, - 4.931445698739215e-05, - 5.411099152784563e-06, - -6.042042478905683e-05, - -1.989624512124905e-05, - 7.025763351163002e-05, - 3.967018140695091e-05, - -7.72428741451272e-05, - -6.490829524996992e-05, - 7.9507093138109e-05, - 9.532015440656505e-05, - -7.498274957040692e-05, - -0.00013003529388340405, - 6.153246053554203e-05, - 0.0001675104888314477, - -3.711737577180626e-05, - -0.00020547154270862667, - 4.380875381487169e-19, - 0.0002409023748839593, - 5.102778188775271e-05, - -0.0002700928372585857, - -0.00011640463560427953, - 0.00028875415767545045, - 0.00019556435946416691, - -0.0002922072182944144, - -0.0002867246276901985, - 0.0002756441457161496, - 0.0003867211644368446, - -0.0002344581317859229, - -0.0004909090262693411, - 0.00016463032935658855, - 0.0005931514994811955, - -6.315646659694906e-05, - -0.0006859142317553148, - -7.151005261521953e-05, - 0.0007604775938269121, - 0.0002390268636629881, - -0.0008072740136891249, - -0.00043677525441936056, - 0.0008163493865283938, - 0.0006595508119830226, - -0.0007779390126639911, - -0.0008993661964713373, - 0.0006831393454389286, - 0.00114539774688185, - -0.0005246477263799965, - -0.00138410277847316, - 0.00029753389026130304, - 0.0015995271835870914, - -1.8249308204396214e-17, - -0.001773813531049159, - -0.0003659190459608399, - 0.0018879086841156133, - 0.0007937657463383715, - -0.0019224576000959562, - -0.0012722307423329708, - 0.0018588571537189837, - 0.0017849305448029394, - -0.0016804313624166863, - -0.002310431475418928, - 0.0013736781639519724, - 0.0028225487316737353, - -0.0009295287890346657, - -0.0032909363527835883, - 0.0003445546173767534, - 0.003681968512252244, - 0.0003779460639632543, - -0.00395989577856263, - -0.0012270471817312566, - 0.004088242707216325, - 0.0021835391818022633, - -0.004031396395209965, - -0.003219566441111553, - 0.0037563205210019465, - 0.004298589347141008, - -0.003234316955594173, - -0.005375681266525964, - 0.0024427482073774184, - 0.00639814422962896, - -0.0013666295279113297, - -0.007306395272526002, - 4.1486825665423373e-17, - 0.008035036709816487, - 0.0016530123829845687, - -0.008513975101161425, - -0.0035775058023473096, - 0.008669388760192265, - 0.005747558403911614, - -0.008424248812489233, - -0.008126459615440715, - 0.007697946272157984, - 0.01066743495767241, - -0.006404309173724075, - -0.013314855511628901, - 0.004446782604876781, - 0.016005897813639956, - -0.00170849842523587, - -0.018672595414079837, - -0.001967340732302961, - 0.021244201096702293, - 0.006816838930484501, - -0.02364976015970634, - -0.013239145641295004, - 0.02582078137402188, - 0.021992767160156825, - -0.027693884168079493, - -0.03472848053143565, - 0.02921329883114049, - 0.05579974177257601, - -0.03033310130622086, - -0.10130968278740993, - 0.03101907530302571, - 0.3167001312508388, - 0.46875167199845, - 0.3167001312508388, - 0.03101907530302571, - -0.10130968278740993, - -0.03033310130622086, - 0.05579974177257601, - 0.02921329883114049, - -0.03472848053143565, - -0.027693884168079493, - 0.021992767160156825, - 0.02582078137402188, - -0.013239145641295004, - -0.02364976015970634, - 0.006816838930484501, - 0.021244201096702293, - -0.001967340732302961, - -0.018672595414079837, - -0.00170849842523587, - 0.016005897813639956, - 0.004446782604876781, - -0.013314855511628901, - -0.006404309173724075, - 0.01066743495767241, - 0.007697946272157984, - -0.008126459615440715, - -0.008424248812489233, - 0.005747558403911614, - 0.008669388760192265, - -0.0035775058023473096, - -0.008513975101161425, - 0.0016530123829845687, - 0.008035036709816487, - 4.1486825665423373e-17, - -0.007306395272526002, - -0.0013666295279113297, - 0.00639814422962896, - 0.0024427482073774184, - -0.005375681266525964, - -0.003234316955594173, - 0.004298589347141008, - 0.0037563205210019465, - -0.003219566441111553, - -0.004031396395209965, - 0.0021835391818022633, - 0.004088242707216325, - -0.0012270471817312566, - -0.00395989577856263, - 0.0003779460639632543, - 0.003681968512252244, - 0.0003445546173767534, - -0.0032909363527835883, - -0.0009295287890346657, - 0.0028225487316737353, - 0.0013736781639519724, - -0.002310431475418928, - -0.0016804313624166863, - 0.0017849305448029394, - 0.0018588571537189837, - -0.0012722307423329708, - -0.0019224576000959562, - 0.0007937657463383715, - 0.0018879086841156133, - -0.0003659190459608399, - -0.001773813531049159, - -1.8249308204396214e-17, - 0.0015995271835870914, - 0.00029753389026130304, - -0.00138410277847316, - -0.0005246477263799965, - 0.00114539774688185, - 0.0006831393454389286, - -0.0008993661964713373, - -0.0007779390126639911, - 0.0006595508119830226, - 0.0008163493865283938, - -0.00043677525441936056, - -0.0008072740136891249, - 0.0002390268636629881, - 0.0007604775938269121, - -7.151005261521953e-05, - -0.0006859142317553148, - -6.315646659694906e-05, - 0.0005931514994811955, - 0.00016463032935658855, - -0.0004909090262693411, - -0.0002344581317859229, - 0.0003867211644368446, - 0.0002756441457161496, - -0.0002867246276901985, - -0.0002922072182944144, - 0.00019556435946416691, - 0.00028875415767545045, - -0.00011640463560427953, - -0.0002700928372585857, - 5.102778188775271e-05, - 0.0002409023748839593, - 4.380875381487169e-19, - -0.00020547154270862667, - -3.711737577180626e-05, - 0.0001675104888314477, - 6.153246053554203e-05, - -0.00013003529388340405, - -7.498274957040692e-05, - 9.532015440656505e-05, - 7.9507093138109e-05, - -6.490829524996992e-05, - -7.72428741451272e-05, - 3.967018140695091e-05, - 7.025763351163002e-05, - -1.989624512124905e-05, - -6.042042478905683e-05, - 5.411099152784563e-06, - 4.931445698739215e-05, - 4.303067618516991e-06, - -3.8189337778906546e-05, - -9.984713045871162e-06, - 2.794862730250771e-05, - 1.248152779539428e-05, - -1.9166554046744026e-05, - -1.265575645173113e-05, - 1.2126657588758059e-05, - 1.1310163453885296e-05, - -6.874774126129371e-06, - -9.13620584774856e-06, - 3.2790831797631692e-06, - 6.683906965798109e-06, - -1.0907621221693655e-06, - -4.351257283515671e-06, - -7.143923102926616e-20, -]; - -#[allow(clippy::excessive_precision)] -pub const HZ48000_LOW: [f64; 129] = [ - -1.4287804154623814e-19, - -2.181517823792544e-06, - 6.5581470578797384e-06, - -1.3749507785319245e-05, - 2.4253243796448185e-05, - -3.8332995273522084e-05, - 5.589709009118714e-05, - -7.637845076415545e-05, - 9.862862369540776e-05, - -0.00012084049392574903, - 0.00014051485346619586, - -0.0001544852936160124, - 0.00015901371827411808, - -0.0001499650577703289, - 0.00012306455887295043, - -7.423453305983806e-05, - 8.761724975855263e-19, - 0.00010205526341099535, - -0.0002328085860166881, - 0.00039112756777908054, - -0.0005734475676350329, - 0.0007734400525193427, - -0.000981815162903983, - 0.001186299507498468, - -0.0013718244260180216, - 0.0015209507112593692, - -0.0016145432755263242, - 0.0016326939677845523, - -0.0015558734461504878, - 0.001366274669719045, - -0.0010492923645293963, - 0.000595066029150748, - -3.649850898800486e-17, - -0.0007318359380147118, - 0.0015875268203384464, - -0.0025444539959421624, - 0.0035698505829804923, - -0.004620849350959662, - 0.005645080848996707, - -0.006581853334149319, - 0.007363915351356501, - -0.007919768248015761, - 0.008176461349835438, - -0.008062769060436804, - 0.007512618931198147, - -0.006468614873048888, - 0.004885482036021499, - -0.002733251011439905, - 8.297340712720699e-17, - 0.0033060150358527928, - -0.007154990546444822, - 0.011495082976006515, - -0.016252871396153546, - 0.021334807123689837, - -0.026629632648107943, - 0.032011701411864754, - -0.03734508091577928, - 0.042488277143797916, - -0.047299381109978895, - 0.051641410759341526, - -0.05538760532182361, - 0.05842642570422467, - -0.06066602406289918, - 0.06203796801866447, - 0.9375005847868952, - 0.06203796801866447, - -0.06066602406289918, - 0.05842642570422467, - -0.05538760532182361, - 0.051641410759341526, - -0.047299381109978895, - 0.042488277143797916, - -0.03734508091577928, - 0.032011701411864754, - -0.026629632648107943, - 0.021334807123689837, - -0.016252871396153546, - 0.011495082976006515, - -0.007154990546444822, - 0.0033060150358527928, - 8.297340712720699e-17, - -0.002733251011439905, - 0.004885482036021499, - -0.006468614873048888, - 0.007512618931198147, - -0.008062769060436804, - 0.008176461349835438, - -0.007919768248015761, - 0.007363915351356501, - -0.006581853334149319, - 0.005645080848996707, - -0.004620849350959662, - 0.0035698505829804923, - -0.0025444539959421624, - 0.0015875268203384464, - -0.0007318359380147118, - -3.649850898800486e-17, - 0.000595066029150748, - -0.0010492923645293963, - 0.001366274669719045, - -0.0015558734461504878, - 0.0016326939677845523, - -0.0016145432755263242, - 0.0015209507112593692, - -0.0013718244260180216, - 0.001186299507498468, - -0.000981815162903983, - 0.0007734400525193427, - -0.0005734475676350329, - 0.00039112756777908054, - -0.0002328085860166881, - 0.00010205526341099535, - 8.761724975855263e-19, - -7.423453305983806e-05, - 0.00012306455887295043, - -0.0001499650577703289, - 0.00015901371827411808, - -0.0001544852936160124, - 0.00014051485346619586, - -0.00012084049392574903, - 9.862862369540776e-05, - -7.637845076415545e-05, - 5.589709009118714e-05, - -3.8332995273522084e-05, - 2.4253243796448185e-05, - -1.3749507785319245e-05, - 6.5581470578797384e-06, - -2.181517823792544e-06, - -1.4287804154623814e-19, -]; - -#[allow(clippy::excessive_precision)] -pub const HZ88200_LOW: [f64; 129] = [ - 5.875800344814529e-06, - 4.851699044013074e-06, - -1.5670438235895964e-05, - -9.287225758882044e-06, - 3.2188588517572685e-05, - 1.452725442412174e-05, - -5.80015310113526e-05, - -1.975318175268538e-05, - 9.615523116437566e-05, - 2.3552114164532385e-05, - -0.00015014174552603567, - -2.375916580017386e-05, - 0.00022383889492568076, - 1.729437074025395e-05, - -0.00032141607023776947, - -1.8686789504441635e-19, - 0.00044720587729591056, - -3.351608912018519e-05, - -0.0006055434276587542, - 9.002640046744051e-05, - 0.0008005773235174634, - -0.00017781632159122524, - -0.0010360586296973909, - 0.00030680368023040425, - 0.0013151162221446207, - -0.0004886505249968164, - -0.0016400286962743556, - 0.0007368790790811487, - 0.0020120043638640903, - -0.0010670133701345262, - -0.0024309816366330315, - 0.0014967816965620656, - 0.002895462190517508, - -0.002046435147324143, - -0.0034023886674580135, - 0.002739267989293373, - 0.003947077286631264, - -0.003602474524851333, - -0.0045232136384107564, - 0.0046685585578356776, - 0.005122917204805467, - -0.005977654559924746, - -0.005736876918489128, - 0.007581382917565772, - 0.006354556507022021, - -0.009549372598113655, - -0.006964464667634032, - 0.011980635507338782, - 0.007554481497059819, - -0.015024288868017965, - -0.008112229280669358, - 0.018919636740583255, - 0.008625472935527727, - -0.024080164100849143, - -0.009082533288527662, - 0.031289629556764974, - 0.009472695101363785, - -0.042234282967316725, - -0.009786591428611496, - 0.06131211363458383, - 0.01001654655736988, - -0.10467821599139523, - -0.010156861410646928, - 0.31783087768940993, - 0.5102013912850153, - 0.31783087768940993, - -0.010156861410646928, - -0.10467821599139523, - 0.01001654655736988, - 0.06131211363458383, - -0.009786591428611496, - -0.042234282967316725, - 0.009472695101363785, - 0.031289629556764974, - -0.009082533288527662, - -0.024080164100849143, - 0.008625472935527727, - 0.018919636740583255, - -0.008112229280669358, - -0.015024288868017965, - 0.007554481497059819, - 0.011980635507338782, - -0.006964464667634032, - -0.009549372598113655, - 0.006354556507022021, - 0.007581382917565772, - -0.005736876918489128, - -0.005977654559924746, - 0.005122917204805467, - 0.0046685585578356776, - -0.0045232136384107564, - -0.003602474524851333, - 0.003947077286631264, - 0.002739267989293373, - -0.0034023886674580135, - -0.002046435147324143, - 0.002895462190517508, - 0.0014967816965620656, - -0.0024309816366330315, - -0.0010670133701345262, - 0.0020120043638640903, - 0.0007368790790811487, - -0.0016400286962743556, - -0.0004886505249968164, - 0.0013151162221446207, - 0.00030680368023040425, - -0.0010360586296973909, - -0.00017781632159122524, - 0.0008005773235174634, - 9.002640046744051e-05, - -0.0006055434276587542, - -3.351608912018519e-05, - 0.00044720587729591056, - -1.8686789504441635e-19, - -0.00032141607023776947, - 1.729437074025395e-05, - 0.00022383889492568076, - -2.375916580017386e-05, - -0.00015014174552603567, - 2.3552114164532385e-05, - 9.615523116437566e-05, - -1.975318175268538e-05, - -5.80015310113526e-05, - 1.452725442412174e-05, - 3.2188588517572685e-05, - -9.287225758882044e-06, - -1.5670438235895964e-05, - 4.851699044013074e-06, - 5.875800344814529e-06, -]; - -#[allow(clippy::excessive_precision)] -pub const HZ96000_LOW: [f64; 129] = [ - -7.143944801213435e-20, - -1.1128313185646072e-05, - -3.3433343718178e-06, - 2.368294142133405e-05, - 1.3125839456769717e-05, - -4.065919588349948e-05, - -3.361363034503314e-05, - 6.0198389114399714e-05, - 6.974138571798226e-05, - -7.816273123033217e-05, - -0.000126460783407638, - 8.758503947913682e-05, - 0.0002077626777155509, - -7.835700358335798e-05, - -0.0003154059452699033, - 3.729708416324331e-05, - 0.0004474410769117699, - 5.1274839240568415e-05, - -0.0005966722898292008, - -0.00020436483462002328, - 0.0007492498350107482, - 0.0004384998464839666, - -0.0008836155865344651, - -0.0007673289520005847, - 0.000970032155449486, - 0.0011987515041766601, - -0.0009709031498968383, - -0.0017317724164334631, - 0.0008420376771297366, - 0.0023533499143115976, - -0.0005349278077261196, - -0.00303553840647302, - 1.824936363314565e-17, - 0.003733226210629766, - 0.0008093189947979181, - -0.004382713612447862, - -0.0019320007678197645, - 0.004901261108562161, - 0.0033946608064293073, - -0.00518754915999129, - -0.005207105621787521, - 0.0051227092580119855, - 0.007358664812266444, - -0.004571166160481191, - -0.009815768367302802, - 0.003379862524796346, - 0.012521152261727227, - -0.0013732462347513066, - -0.015394948058705999, - -0.0016610156480375167, - 0.018337745467632928, - 0.006006200853277362, - -0.021235526836812676, - -0.012095713970371423, - 0.02396617954234677, - 0.020705989626446524, - -0.02640711788557473, - -0.03348753234339166, - 0.028443411089665006, - 0.05477521964516673, - -0.029975735264560804, - -0.10063702926794785, - 0.030927455828749166, - 0.3164667874739216, - 0.4687530957411302, - 0.3164667874739216, - 0.030927455828749166, - -0.10063702926794785, - -0.029975735264560804, - 0.05477521964516673, - 0.028443411089665006, - -0.03348753234339166, - -0.02640711788557473, - 0.020705989626446524, - 0.02396617954234677, - -0.012095713970371423, - -0.021235526836812676, - 0.006006200853277362, - 0.018337745467632928, - -0.0016610156480375167, - -0.015394948058705999, - -0.0013732462347513066, - 0.012521152261727227, - 0.003379862524796346, - -0.009815768367302802, - -0.004571166160481191, - 0.007358664812266444, - 0.0051227092580119855, - -0.005207105621787521, - -0.00518754915999129, - 0.0033946608064293073, - 0.004901261108562161, - -0.0019320007678197645, - -0.004382713612447862, - 0.0008093189947979181, - 0.003733226210629766, - 1.824936363314565e-17, - -0.00303553840647302, - -0.0005349278077261196, - 0.0023533499143115976, - 0.0008420376771297366, - -0.0017317724164334631, - -0.0009709031498968383, - 0.0011987515041766601, - 0.000970032155449486, - -0.0007673289520005847, - -0.0008836155865344651, - 0.0004384998464839666, - 0.0007492498350107482, - -0.00020436483462002328, - -0.0005966722898292008, - 5.1274839240568415e-05, - 0.0004474410769117699, - 3.729708416324331e-05, - -0.0003154059452699033, - -7.835700358335798e-05, - 0.0002077626777155509, - 8.758503947913682e-05, - -0.000126460783407638, - -7.816273123033217e-05, - 6.974138571798226e-05, - 6.0198389114399714e-05, - -3.361363034503314e-05, - -4.065919588349948e-05, - 1.3125839456769717e-05, - 2.368294142133405e-05, - -3.3433343718178e-06, - -1.1128313185646072e-05, - -7.143944801213435e-20, +pub const HZ96000_COEFFICIENTS: [f64; 255] = [ + 0.000002847632463847152, + -0.0000020047064344575387, + -0.000005225258612782935, + 0.0000021863172837045737, + 0.000008449577753794505, + -0.000001645147457526964, + -0.00001253472602638548, + -0.00000000000000000016044508154100242, + 0.0000174000157479276, + 0.000003178383395449116, + -0.000022843501303930687, + -0.000008343885756492573, + 0.000028518125704304344, + 0.000015942653739013533, + -0.00003391297504718035, + -0.00002637212811191098, + 0.00003834232729455769, + 0.00003993248213488137, + -0.00004094517846935377, + -0.0000567722407866557, + 0.0000406977377370788, + 0.0000768306237296946, + -0.0000364409861432804, + -0.00009977988810634192, + 0.00002692478682324265, + 0.00012497158932796155, + -0.000010869225300885724, + -0.0001513911731816747, + -0.000012957130632604465, + 0.0001776256072439122, + 0.00004564349416716221, + -0.0002018488060644161, + -0.00008803031312301156, + 0.00022182936482515332, + 0.00014059383532190895, + -0.00023496456530319273, + -0.00020332691806948484, + 0.0002383437472796663, + 0.0002756223036799507, + -0.00022884295783594133, + -0.00035616547057519077, + 0.00020325132992421135, + 0.0004428447776134229, + -0.0001584279499844757, + -0.0005326868783038047, + 0.00009148612118064054, + 0.0006218252347089108, + -0.00000000000000000781601970311331, + -0.0007055089689793785, + -0.00011777332099314322, + 0.0007781582361031978, + 0.00026266498403304154, + -0.000833470791850537, + -0.000434369018599322, + 0.000864582499023525, + 0.0006312318776939468, + -0.000864282224208867, + -0.0008500689803514512, + 0.000825279013812413, + 0.001086020563990385, + -0.0007405167135629041, + -0.0013324587293609888, + 0.0006035284410498627, + 0.0015809565017422316, + -0.0004088206818543355, + -0.0018213280295778427, + 0.00015227441021615416, + 0.0020417467245597773, + 0.0001684513101656827, + -0.0022289452786264483, + -0.0005535291619738098, + 0.0023684981706099148, + 0.0010006034272540317, + -0.0024451836264598003, + -0.0015044762763612067, + 0.00244341817642038, + 0.0020568558307895875, + -0.002347753134303414, + -0.002646179268022404, + 0.002143418693941639, + 0.003257521129549034, + -0.0018168980846478362, + -0.003872592813376805, + 0.0013565115327417309, + 0.004469833939590421, + -0.0007529878048992226, + -0.005024589797093532, + 0.000000000000000031029552992847454, + 0.005509361251772587, + 0.0009053578866107159, + -0.005894103991259223, + -0.001962176216624525, + 0.006146542155498904, + 0.003165437440243828, + -0.006232446045449634, + -0.004505844026260251, + 0.006115802482065992, + 0.005969780446988715, + -0.005758775394159593, + -0.0075394184180818564, + 0.005121305691106225, + 0.009192969321584898, + -0.004160118833572156, + -0.010905082066156728, + 0.002826767016941831, + 0.012647378800894607, + -0.001064071526537435, + -0.014389115154419273, + -0.0012001778271450816, + 0.016097946278574398, + 0.0040644576464234725, + -0.01774077518737831, + -0.007674181046896078, + 0.019284655926700384, + 0.012261815746530359, + -0.020697721185583922, + -0.018231002603733296, + 0.021950102220049332, + 0.026352857354615483, + -0.023014808506865155, + -0.0382984768866238, + 0.023868535422982867, + 0.05844855236359276, + -0.024492370440327798, + -0.10293919694107687, + 0.02487237175898274, + 0.3172491067865382, + 0.474999958965639, + 0.3172491067865382, + 0.02487237175898274, + -0.10293919694107687, + -0.024492370440327798, + 0.05844855236359276, + 0.023868535422982867, + -0.0382984768866238, + -0.023014808506865155, + 0.026352857354615483, + 0.021950102220049332, + -0.018231002603733296, + -0.020697721185583922, + 0.012261815746530359, + 0.019284655926700384, + -0.007674181046896078, + -0.01774077518737831, + 0.0040644576464234725, + 0.016097946278574398, + -0.0012001778271450816, + -0.014389115154419273, + -0.001064071526537435, + 0.012647378800894607, + 0.002826767016941831, + -0.010905082066156728, + -0.004160118833572156, + 0.009192969321584898, + 0.005121305691106225, + -0.0075394184180818564, + -0.005758775394159593, + 0.005969780446988715, + 0.006115802482065992, + -0.004505844026260251, + -0.006232446045449634, + 0.003165437440243828, + 0.006146542155498904, + -0.001962176216624525, + -0.005894103991259223, + 0.0009053578866107159, + 0.005509361251772587, + 0.000000000000000031029552992847454, + -0.005024589797093532, + -0.0007529878048992226, + 0.004469833939590421, + 0.0013565115327417309, + -0.003872592813376805, + -0.0018168980846478362, + 0.003257521129549034, + 0.002143418693941639, + -0.002646179268022404, + -0.002347753134303414, + 0.0020568558307895875, + 0.00244341817642038, + -0.0015044762763612067, + -0.0024451836264598003, + 0.0010006034272540317, + 0.0023684981706099148, + -0.0005535291619738098, + -0.0022289452786264483, + 0.0001684513101656827, + 0.0020417467245597773, + 0.00015227441021615416, + -0.0018213280295778427, + -0.0004088206818543355, + 0.0015809565017422316, + 0.0006035284410498627, + -0.0013324587293609888, + -0.0007405167135629041, + 0.001086020563990385, + 0.000825279013812413, + -0.0008500689803514512, + -0.000864282224208867, + 0.0006312318776939468, + 0.000864582499023525, + -0.000434369018599322, + -0.000833470791850537, + 0.00026266498403304154, + 0.0007781582361031978, + -0.00011777332099314322, + -0.0007055089689793785, + -0.00000000000000000781601970311331, + 0.0006218252347089108, + 0.00009148612118064054, + -0.0005326868783038047, + -0.0001584279499844757, + 0.0004428447776134229, + 0.00020325132992421135, + -0.00035616547057519077, + -0.00022884295783594133, + 0.0002756223036799507, + 0.0002383437472796663, + -0.00020332691806948484, + -0.00023496456530319273, + 0.00014059383532190895, + 0.00022182936482515332, + -0.00008803031312301156, + -0.0002018488060644161, + 0.00004564349416716221, + 0.0001776256072439122, + -0.000012957130632604465, + -0.0001513911731816747, + -0.000010869225300885724, + 0.00012497158932796155, + 0.00002692478682324265, + -0.00009977988810634192, + -0.0000364409861432804, + 0.0000768306237296946, + 0.0000406977377370788, + -0.0000567722407866557, + -0.00004094517846935377, + 0.00003993248213488137, + 0.00003834232729455769, + -0.00002637212811191098, + -0.00003391297504718035, + 0.000015942653739013533, + 0.000028518125704304344, + -0.000008343885756492573, + -0.000022843501303930687, + 0.000003178383395449116, + 0.0000174000157479276, + -0.00000000000000000016044508154100242, + -0.00001253472602638548, + -0.000001645147457526964, + 0.000008449577753794505, + 0.0000021863172837045737, + -0.000005225258612782935, + -0.0000020047064344575387, + 0.000002847632463847152, ]; diff --git a/playback/src/resampler.rs b/playback/src/resampler.rs index 25c3a749a..fe82d4845 100644 --- a/playback/src/resampler.rs +++ b/playback/src/resampler.rs @@ -7,9 +7,8 @@ use std::{ }; use crate::{ - config::{InterpolationQuality, SampleRate}, - player::PLAYER_COUNTER, - RESAMPLER_INPUT_SIZE, SAMPLE_RATE as SOURCE_SAMPLE_RATE, + config::SampleRate, player::PLAYER_COUNTER, RESAMPLER_INPUT_SIZE, + SAMPLE_RATE as SOURCE_SAMPLE_RATE, }; struct DelayLine { @@ -88,27 +87,27 @@ struct MonoSincResampler { } impl MonoSincResampler { - fn new(sample_rate: SampleRate, interpolation_quality: InterpolationQuality) -> Self { - let spec = sample_rate.get_resample_spec(); + fn new(sample_rate: SampleRate) -> Self { + let coefficients = sample_rate + .get_interpolation_coefficients() + .unwrap_or_default(); - let coefficients = match interpolation_quality { - InterpolationQuality::Low => spec.low_coefficients, - InterpolationQuality::High => spec.high_coefficients, - }; + let resample_factor_reciprocal = sample_rate + .get_resample_factor_reciprocal() + .unwrap_or_default(); - let delay_line_latency = - (coefficients.len() as f64 * spec.resample_factor_reciprocal) as u64; + let interpolation_output_size = sample_rate + .get_interpolation_output_size() + .unwrap_or_default(); - Self { - interpolator: ConvolutionFilter::new( - interpolation_quality - .get_interpolation_coefficients(coefficients, spec.resample_factor_reciprocal), - ), + let delay_line_latency = (coefficients.len() as f64 * resample_factor_reciprocal) as u64; + Self { + interpolator: ConvolutionFilter::new(coefficients), input_buffer: Vec::with_capacity(SOURCE_SAMPLE_RATE as usize), - resample_factor_reciprocal: spec.resample_factor_reciprocal, + resample_factor_reciprocal, delay_line_latency, - interpolation_output_size: spec.interpolation_output_size, + interpolation_output_size, } } @@ -281,7 +280,7 @@ pub struct StereoInterleavedResampler { } impl StereoInterleavedResampler { - pub fn new(sample_rate: SampleRate, interpolation_quality: InterpolationQuality) -> Self { + pub fn new(sample_rate: SampleRate) -> Self { debug!("Sample Rate: {sample_rate}"); let resampler = match sample_rate { @@ -292,7 +291,7 @@ impl StereoInterleavedResampler { Resampler::Bypass } _ => { - debug!("Interpolation Quality: {interpolation_quality}"); + debug!("Interpolation Type: Windowed Sinc"); // The player increments the player id when it gets it... let player_id = PLAYER_COUNTER.load(Ordering::SeqCst).saturating_sub(1); @@ -300,12 +299,15 @@ impl StereoInterleavedResampler { let left_thread_name = format!("resampler:{player_id}:left"); let right_thread_name = format!("resampler:{player_id}:right"); - let left = MonoSincResampler::new(sample_rate, interpolation_quality); - let right = MonoSincResampler::new(sample_rate, interpolation_quality); - Resampler::Worker { - left_resampler: ResampleWorker::new(left, left_thread_name), - right_resampler: ResampleWorker::new(right, right_thread_name), + left_resampler: ResampleWorker::new( + MonoSincResampler::new(sample_rate), + left_thread_name, + ), + right_resampler: ResampleWorker::new( + MonoSincResampler::new(sample_rate), + right_thread_name, + ), } } }; diff --git a/playback/src/sample_pipeline.rs b/playback/src/sample_pipeline.rs index bae88279d..53bbc29f3 100644 --- a/playback/src/sample_pipeline.rs +++ b/playback/src/sample_pipeline.rs @@ -23,8 +23,7 @@ impl SamplePipeline { sink: Box, volume_getter: Box, ) -> Self { - let resampler = - StereoInterleavedResampler::new(config.sample_rate, config.interpolation_quality); + let resampler = StereoInterleavedResampler::new(config.sample_rate); let normaliser = Normaliser::new(config, volume_getter); let converter = Converter::new(config.ditherer); diff --git a/src/main.rs b/src/main.rs index 231b24518..f959267a7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,8 +24,8 @@ use librespot::{ playback::{ audio_backend::{self, SinkBuilder, BACKENDS}, config::{ - AudioFormat, Bitrate, InterpolationQuality, NormalisationMethod, NormalisationType, - PlayerConfig, SampleRate, VolumeCtrl, + AudioFormat, Bitrate, NormalisationMethod, NormalisationType, PlayerConfig, SampleRate, + VolumeCtrl, }, dither, mixer::{self, MixerConfig, MixerFn}, @@ -240,7 +240,6 @@ fn get_setup() -> Setup { const VOLUME_RANGE: &str = "volume-range"; const ZEROCONF_PORT: &str = "zeroconf-port"; const ZEROCONF_INTERFACE: &str = "zeroconf-interface"; - const INTERPOLATION_QUALITY: &str = "interpolation-quality"; const SAMPLE_RATE: &str = "sample-rate"; // Mostly arbitrary. @@ -579,11 +578,6 @@ fn get_setup() -> Setup { ZEROCONF_INTERFACE, "Comma-separated interface IP addresses on which zeroconf will bind. Defaults to all interfaces. Ignored by DNS-SD.", "IP" - ).optopt( - "", - INTERPOLATION_QUALITY, - "Interpolation Quality to use if Resampling {Low|High}. Defaults to High.", - "QUALITY" ).optopt( "", SAMPLE_RATE, @@ -800,32 +794,6 @@ fn get_setup() -> Setup { }) .unwrap_or_default(); - let interpolation_quality = opt_str(INTERPOLATION_QUALITY) - .as_deref() - .map(|interpolation_quality| match sample_rate { - SampleRate::Hz44100 => { - warn!( - "--{} has no effect with a sample rate of {sample_rate}.", - INTERPOLATION_QUALITY - ); - - InterpolationQuality::default() - } - _ => InterpolationQuality::from_str(interpolation_quality).unwrap_or_else(|_| { - let default_value = &format!("{}", InterpolationQuality::default()); - invalid_error_msg( - INTERPOLATION_QUALITY, - "", - interpolation_quality, - "Low, High", - default_value, - ); - - exit(1); - }), - }) - .unwrap_or_default(); - let format = opt_str(FORMAT) .as_deref() .map(|format| { @@ -1671,7 +1639,6 @@ fn get_setup() -> Setup { bitrate, gapless, passthrough, - interpolation_quality, sample_rate, normalisation, normalisation_type,