From 8aaab0a210e616a0a2ff7b6f40cf7f3510886dd1 Mon Sep 17 00:00:00 2001 From: JasonLG1979 Date: Sun, 3 Sep 2023 17:32:55 -0500 Subject: [PATCH] More touch ups --- playback/src/config.rs | 29 +- playback/src/filter_coefficients.rs | 2510 +++++++++++++-------------- playback/src/normaliser.rs | 61 +- playback/src/resampler.rs | 232 ++- playback/src/sample_pipeline.rs | 130 +- 5 files changed, 1498 insertions(+), 1464 deletions(-) diff --git a/playback/src/config.rs b/playback/src/config.rs index 6f9eb256..20f5a1f5 100644 --- a/playback/src/config.rs +++ b/playback/src/config.rs @@ -8,10 +8,14 @@ use crate::{ RESAMPLER_INPUT_SIZE, SAMPLE_RATE, }; -// Reciprocals allow us to multiply instead of divide during interpolation. -const HZ48000_RESAMPLE_FACTOR_RECIPROCAL: f64 = SAMPLE_RATE as f64 / 48_000.0; -const HZ88200_RESAMPLE_FACTOR_RECIPROCAL: f64 = SAMPLE_RATE as f64 / 88_200.0; -const HZ96000_RESAMPLE_FACTOR_RECIPROCAL: f64 = SAMPLE_RATE as f64 / 96_000.0; +const HZ48000_RESAMPLE_FACTOR: f64 = 48_000.0 / (SAMPLE_RATE as f64); +const HZ88200_RESAMPLE_FACTOR: f64 = 88_200.0 / (SAMPLE_RATE as f64); +const HZ96000_RESAMPLE_FACTOR: f64 = 96_000.0 / (SAMPLE_RATE as f64); + +// Reciprocals allow us to multiply instead of divide during normal interpolation. +const HZ48000_RESAMPLE_FACTOR_RECIPROCAL: f64 = 1.0 / HZ48000_RESAMPLE_FACTOR; +const HZ88200_RESAMPLE_FACTOR_RECIPROCAL: f64 = 1.0 / HZ88200_RESAMPLE_FACTOR; +const HZ96000_RESAMPLE_FACTOR_RECIPROCAL: f64 = 1.0 / HZ96000_RESAMPLE_FACTOR; // sample rate * channels const HZ44100_SAMPLES_PER_SECOND: f64 = 44_100.0 * 2.0; @@ -23,13 +27,13 @@ const HZ96000_SAMPLES_PER_SECOND: f64 = 96_000.0 * 2.0; // to be integers, which is a very good thing. That means no fractional samples // which translates to much better interpolation. const HZ48000_INTERPOLATION_OUTPUT_SIZE: usize = - (RESAMPLER_INPUT_SIZE as f64 * (1.0 / HZ48000_RESAMPLE_FACTOR_RECIPROCAL)) as usize; + (RESAMPLER_INPUT_SIZE as f64 * HZ48000_RESAMPLE_FACTOR) as usize; const HZ88200_INTERPOLATION_OUTPUT_SIZE: usize = - (RESAMPLER_INPUT_SIZE as f64 * (1.0 / HZ88200_RESAMPLE_FACTOR_RECIPROCAL)) as usize; + (RESAMPLER_INPUT_SIZE as f64 * HZ88200_RESAMPLE_FACTOR) as usize; const HZ96000_INTERPOLATION_OUTPUT_SIZE: usize = - (RESAMPLER_INPUT_SIZE as f64 * (1.0 / HZ96000_RESAMPLE_FACTOR_RECIPROCAL)) as usize; + (RESAMPLER_INPUT_SIZE as f64 * HZ96000_RESAMPLE_FACTOR) as usize; #[derive(Clone, Copy, Debug, Default)] pub enum SampleRate { @@ -134,6 +138,17 @@ impl SampleRate { } } + pub fn get_resample_factor(&self) -> Option { + use SampleRate::*; + + match self { + Hz44100 => None, + Hz48000 => Some(HZ48000_RESAMPLE_FACTOR), + Hz88200 => Some(HZ88200_RESAMPLE_FACTOR), + Hz96000 => Some(HZ96000_RESAMPLE_FACTOR), + } + } + pub fn get_resample_factor_reciprocal(&self) -> Option { use SampleRate::*; diff --git a/playback/src/filter_coefficients.rs b/playback/src/filter_coefficients.rs index dee8a64b..1f89764b 100644 --- a/playback/src/filter_coefficients.rs +++ b/playback/src/filter_coefficients.rs @@ -1,1344 +1,1188 @@ -// All Windows calculated with pyfda (Python Filter Design Analysis Tool) +// All coefficients calculated with pyfda (Python Filter Design Analysis Tool) // https://github.com/chipmuenk/pyfda // Window = Kaiser -// beta = 15 -// fc = 22.8kHz -// -140dB well before 24kHz -// The assumption is that the input -// is anti-aliased properly, -// We just want to make sure interpolation -// doesn't add any artifacts. +// Ripple = 0.00017371779276643043 + +// β = 20.8 +// fc = 20.66 +// -195dB before 22kHz #[allow(clippy::excessive_precision)] -pub const HZ48000_COEFFICIENTS: [f64; 441] = [ - -8.771146084517915e-23, - 1.0570942208391173e-09, - -3.0666660745656922e-09, - 6.298083919549404e-09, - -1.1009494492149948e-08, - 1.7421987235394415e-08, - -2.5689109092988082e-08, - 3.5862674329115807e-08, - -4.7856266645529607e-08, - 6.140828902806317e-08, - -7.604685422793451e-08, - 9.105919616127095e-08, - -1.0546858823253603e-07, - 1.1802194634247329e-07, - -1.271913407105633e-07, - 1.3119251294318607e-07, - -1.280231690229821e-07, - 1.1552327779416195e-07, - -9.145883941617693e-08, - 5.362960091161619e-08, - -7.7217226107300735e-22, - -7.114875946245203e-08, - 1.6104911667095417e-07, - -2.7026527132156615e-07, - 3.985058614410556e-07, - -5.444396250307578e-07, - 7.055238955116609e-07, - -8.778569687571143e-07, - 1.0560662317828128e-06, - -1.2332443646663861e-06, - 1.4009458289943576e-06, - -1.5492551604686838e-06, - 1.6669372292816672e-06, - -1.7416775803496403e-06, - 1.760418204028636e-06, - -1.7097906350117925e-06, - 1.5766441855366919e-06, - -1.3486624782617763e-06, - 1.015056381074019e-06, - -5.673161244592637e-07, - 9.792562157691215e-20, - 6.884681756425475e-07, - -1.4950254408593126e-06, - 2.4112566283065856e-06, - -3.4227817199744546e-06, - 4.5087853828418386e-06, - -5.641730870612593e-06, - 6.787299186897442e-06, - -7.904591223857538e-06, - 8.946625393428547e-06, - -9.861155999917786e-06, - 1.059182828621353e-05, - -1.1079674832069601e-05, - 1.126494499675449e-05, - -1.1089244681251284e-05, - 1.0497948234446287e-05, - -9.442828331471874e-06, - 7.884833680573385e-06, - -5.796929105544363e-06, - 3.1668985925331214e-06, - -1.0267057094301908e-18, - -3.678648971030143e-06, - 7.82207956681534e-06, - -1.2360003045077198e-05, - 1.719798834414252e-05, - -2.221740239139365e-05, - 2.727621538905652e-05, - -3.221075420642931e-05, - 3.6838462372847274e-05, - -4.096169540744633e-05, - 4.4372545871397646e-05, - -4.6858654348383316e-05, - 4.8209921539750954e-05, - -4.8225994005681544e-05, - 4.6724353186234967e-05, - -4.354879574733261e-05, - 3.857805468230202e-05, - -3.1734276690489895e-05, - 2.2991043887561944e-05, - -1.2380608558550801e-05, - 1.0714892504045419e-18, - 1.3984336126251783e-05, - -2.933369198803881e-05, - 4.5736344959148374e-05, - -6.280915808675244e-05, - 8.010174059784683e-05, - -9.710330972590319e-05, - 0.00011325231780323752, - -0.00012794882111289484, - 0.00014056947148065392, - -0.00015048491054933942, - 0.00015707924308034133, - -0.0001597711628045901, - 0.00015803620591136328, - -0.0001514295170121378, - 0.00013960843420358319, - -0.0001223541374673828, - 9.95915616676161e-05, - -7.140675507600406e-05, - 3.806086941676025e-05, - 5.522292755457904e-18, - -4.213984402529341e-05, - 8.753326840947647e-05, - -0.00013517203082831053, - 0.0001838779481747696, - -0.00023232236376993098, - 0.00027905217036022, - -0.00032252217407439016, - 0.0003611333624045614, - -0.0003932764120704118, - 0.00041737954732315945, - -0.0004319596433444126, - 0.00043567527068183264, - -0.00042738020297625895, - 0.00040617576920780796, - -0.00037146033048375895, - 0.00032297410642885815, - -0.0002608375729289383, - 0.00018558170547350593, - -9.816845330568487e-05, - 6.397895727529846e-19, - 0.00010708440490237048, - -0.00022082497375172826, - 0.00033857186283733177, - -0.00045732982316766367, - 0.0005738168187053221, - -0.000684535969656674, - 0.0007858597238898489, - -0.0008741247047765545, - 0.000945735242783811, - -0.0009972731855902538, - 0.0010256112120681994, - -0.0010280265635201971, - 0.0010023118646185563, - -0.000946879548805299, - 0.0008608563389349595, - -0.0007441642719534753, - 0.0005975849020744005, - -0.00042280357297843214, - 0.00022243101557540356, - -3.474391490098325e-17, - -0.00024006465851531805, - 0.0004925037811490474, - -0.0007513095024493709, - 0.0010098384606174067, - -0.0012609511916318978, - 0.001497175575304658, - -0.0017108913477184788, - 0.00189453189460518, - -0.002040798799462615, - 0.0021428839636620438, - -0.002194693567447552, - 0.002191067722720476, - -0.0021279894003546954, - 0.0020027761127039494, - -0.001814247908162659, - 0.0015628654968098813, - -0.0012508327770007735, - 0.0008821586696520896, - -0.00046267398178344456, - -3.3039584853563575e-17, - 0.0004965333609844947, - -0.0010160207840665381, - 0.0015461657408802655, - -0.0020735138415665724, - 0.002583732114598345, - -0.0030619295805850155, - 0.0034930131304211584, - -0.0038620714583133555, - 0.004154778673084419, - -0.004357808253637993, - 0.004459247260332142, - -0.004449000192806269, - 0.004319171620808093, - -0.004064416725949453, - 0.003682249190367868, - -0.00317329645683304, - 0.0025414932599423837, - -0.0017942054777252078, - 0.0009422777573359167, - -7.350185540376589e-17, - -0.0010150103856962798, - 0.002082011577823492, - -0.0031774248180713193, - 0.00427520317347509, - -0.005347276351155804, - 0.006364064256720479, - -0.0072950500213230345, - 0.008109401423325797, - -0.008776628049842111, - 0.00926726022866957, - -0.009553534753966662, - 0.009610071764202605, - -0.009414526835002754, - 0.008948202440030514, - -0.008196603417779811, - 0.007149921958698993, - -0.005803438882712496, - 0.00415782958901113, - -0.0022193649952320592, - 8.812638424710787e-17, - 0.00248265554875482, - -0.005205485774200194, - 0.008140137239069204, - -0.011253403840824383, - 0.014507722254727249, - -0.017861769381184747, - 0.02127115074947851, - -0.024689166551051196, - 0.02806763998183295, - -0.031357790917889976, - 0.03451113667723182, - -0.0374804007687864, - 0.04022041012286698, - -0.04268896135026697, - 0.04484763709216705, - -0.04666255449128448, - 0.048105029215477144, - -0.04915214026651778, - 0.049787182966797176, - 0.9499999996921324, - 0.049787182966797176, - -0.04915214026651778, - 0.048105029215477144, - -0.04666255449128448, - 0.04484763709216705, - -0.04268896135026697, - 0.04022041012286698, - -0.0374804007687864, - 0.03451113667723182, - -0.031357790917889976, - 0.02806763998183295, - -0.024689166551051196, - 0.02127115074947851, - -0.017861769381184747, - 0.014507722254727249, - -0.011253403840824383, - 0.008140137239069204, - -0.005205485774200194, - 0.00248265554875482, - 8.812638424710787e-17, - -0.0022193649952320592, - 0.00415782958901113, - -0.005803438882712496, - 0.007149921958698993, - -0.008196603417779811, - 0.008948202440030514, - -0.009414526835002754, - 0.009610071764202605, - -0.009553534753966662, - 0.00926726022866957, - -0.008776628049842111, - 0.008109401423325797, - -0.0072950500213230345, - 0.006364064256720479, - -0.005347276351155804, - 0.00427520317347509, - -0.0031774248180713193, - 0.002082011577823492, - -0.0010150103856962798, - -7.350185540376589e-17, - 0.0009422777573359167, - -0.0017942054777252078, - 0.0025414932599423837, - -0.00317329645683304, - 0.003682249190367868, - -0.004064416725949453, - 0.004319171620808093, - -0.004449000192806269, - 0.004459247260332142, - -0.004357808253637993, - 0.004154778673084419, - -0.0038620714583133555, - 0.0034930131304211584, - -0.0030619295805850155, - 0.002583732114598345, - -0.0020735138415665724, - 0.0015461657408802655, - -0.0010160207840665381, - 0.0004965333609844947, - -3.3039584853563575e-17, - -0.00046267398178344456, - 0.0008821586696520896, - -0.0012508327770007735, - 0.0015628654968098813, - -0.001814247908162659, - 0.0020027761127039494, - -0.0021279894003546954, - 0.002191067722720476, - -0.002194693567447552, - 0.0021428839636620438, - -0.002040798799462615, - 0.00189453189460518, - -0.0017108913477184788, - 0.001497175575304658, - -0.0012609511916318978, - 0.0010098384606174067, - -0.0007513095024493709, - 0.0004925037811490474, - -0.00024006465851531805, - -3.474391490098325e-17, - 0.00022243101557540356, - -0.00042280357297843214, - 0.0005975849020744005, - -0.0007441642719534753, - 0.0008608563389349595, - -0.000946879548805299, - 0.0010023118646185563, - -0.0010280265635201971, - 0.0010256112120681994, - -0.0009972731855902538, - 0.000945735242783811, - -0.0008741247047765545, - 0.0007858597238898489, - -0.000684535969656674, - 0.0005738168187053221, - -0.00045732982316766367, - 0.00033857186283733177, - -0.00022082497375172826, - 0.00010708440490237048, - 6.397895727529846e-19, - -9.816845330568487e-05, - 0.00018558170547350593, - -0.0002608375729289383, - 0.00032297410642885815, - -0.00037146033048375895, - 0.00040617576920780796, - -0.00042738020297625895, - 0.00043567527068183264, - -0.0004319596433444126, - 0.00041737954732315945, - -0.0003932764120704118, - 0.0003611333624045614, - -0.00032252217407439016, - 0.00027905217036022, - -0.00023232236376993098, - 0.0001838779481747696, - -0.00013517203082831053, - 8.753326840947647e-05, - -4.213984402529341e-05, - 5.522292755457904e-18, - 3.806086941676025e-05, - -7.140675507600406e-05, - 9.95915616676161e-05, - -0.0001223541374673828, - 0.00013960843420358319, - -0.0001514295170121378, - 0.00015803620591136328, - -0.0001597711628045901, - 0.00015707924308034133, - -0.00015048491054933942, - 0.00014056947148065392, - -0.00012794882111289484, - 0.00011325231780323752, - -9.710330972590319e-05, - 8.010174059784683e-05, - -6.280915808675244e-05, - 4.5736344959148374e-05, - -2.933369198803881e-05, - 1.3984336126251783e-05, - 1.0714892504045419e-18, - -1.2380608558550801e-05, - 2.2991043887561944e-05, - -3.1734276690489895e-05, - 3.857805468230202e-05, - -4.354879574733261e-05, - 4.6724353186234967e-05, - -4.8225994005681544e-05, - 4.8209921539750954e-05, - -4.6858654348383316e-05, - 4.4372545871397646e-05, - -4.096169540744633e-05, - 3.6838462372847274e-05, - -3.221075420642931e-05, - 2.727621538905652e-05, - -2.221740239139365e-05, - 1.719798834414252e-05, - -1.2360003045077198e-05, - 7.82207956681534e-06, - -3.678648971030143e-06, - -1.0267057094301908e-18, - 3.1668985925331214e-06, - -5.796929105544363e-06, - 7.884833680573385e-06, - -9.442828331471874e-06, - 1.0497948234446287e-05, - -1.1089244681251284e-05, - 1.126494499675449e-05, - -1.1079674832069601e-05, - 1.059182828621353e-05, - -9.861155999917786e-06, - 8.946625393428547e-06, - -7.904591223857538e-06, - 6.787299186897442e-06, - -5.641730870612593e-06, - 4.5087853828418386e-06, - -3.4227817199744546e-06, - 2.4112566283065856e-06, - -1.4950254408593126e-06, - 6.884681756425475e-07, - 9.792562157691215e-20, - -5.673161244592637e-07, - 1.015056381074019e-06, - -1.3486624782617763e-06, - 1.5766441855366919e-06, - -1.7097906350117925e-06, - 1.760418204028636e-06, - -1.7416775803496403e-06, - 1.6669372292816672e-06, - -1.5492551604686838e-06, - 1.4009458289943576e-06, - -1.2332443646663861e-06, - 1.0560662317828128e-06, - -8.778569687571143e-07, - 7.055238955116609e-07, - -5.444396250307578e-07, - 3.985058614410556e-07, - -2.7026527132156615e-07, - 1.6104911667095417e-07, - -7.114875946245203e-08, - -7.7217226107300735e-22, - 5.362960091161619e-08, - -9.145883941617693e-08, - 1.1552327779416195e-07, - -1.280231690229821e-07, - 1.3119251294318607e-07, - -1.271913407105633e-07, - 1.1802194634247329e-07, - -1.0546858823253603e-07, - 9.105919616127095e-08, - -7.604685422793451e-08, - 6.140828902806317e-08, - -4.7856266645529607e-08, - 3.5862674329115807e-08, - -2.5689109092988082e-08, - 1.7421987235394415e-08, - -1.1009494492149948e-08, - 6.298083919549404e-09, - -3.0666660745656922e-09, - 1.0570942208391173e-09, - -8.771146084517915e-23, +pub const HZ48000_COEFFICIENTS: [f64; 241] = [ + -2.258118962333164e-11, + 1.0448101000984154e-10, + -2.579276986417335e-10, + 4.3213325781961056e-10, + -4.5843163381727067e-10, + 2.430239393368342e-11, + 1.2790201415889041e-09, + -3.792077258698514e-09, + 7.493499387692452e-09, + -1.1626845054841438e-08, + 1.4380896605407448e-08, + -1.2833471192711628e-08, + 3.3983200532147757e-09, + 1.7048569784995365e-08, + -4.9373422503539266e-08, + 9.003364640559896e-08, + -1.2924579989482033e-07, + 1.5044668040182147e-07, + -1.3210217109716104e-07, + 5.2624736306518187e-08, + 1.0159667858088225e-07, + -3.2622696353370664e-07, + 5.896182325418432e-07, + -8.277448145932576e-07, + 9.475531903328232e-07, + -8.420069483888789e-07, + 4.1772688158879863e-07, + 3.676938974884631e-07, + -1.4662320604642053e-06, + 2.70957271705655e-06, + -3.802817981364587e-06, + 4.354432548140361e-06, + -3.949196046553083e-06, + 2.260451641101642e-06, + 8.156542880169858e-07, + -5.034945638176245e-06, + 9.729638811991692e-06, + -1.3824155754916521e-05, + 1.5973180290174572e-05, + -1.4828839170824971e-05, + 9.409279173382038e-06, + 4.97915044540138e-07, + -1.3997250778589253e-05, + 2.8927821383294266e-05, + -4.199180492418264e-05, + 4.92301628886413e-05, + -4.683190451509506e-05, + 3.216863473381749e-05, + -4.851687701631952e-06, + -3.245913549120116e-05, + 7.378212902653717e-05, + -0.00011030659888783692, + 0.0001317501695922293, + -0.00012848221714262343, + 9.409014122219963e-05, + -2.7862808366416616e-05, + -6.345544705962209e-05, + 0.00016527387065770158, + -0.00025658320129024414, + 0.00031331992887743433, + -0.0003133321268094909, + 0.0002421329206487914, + -9.823590003163207e-05, + -0.0001033189088939493, + 0.0003305257920305843, + -0.000537884656631541, + 0.0006738503239522973, + -0.0006913872260666551, + 0.0005598234351094426, + -0.00027549921950280733, + -0.0001315408318317103, + 0.0005972048317626658, + -0.0010307540796842497, + 0.0013298141762067902, + -0.0014010675688317755, + 0.001183005538332482, + -0.0006659459018028209, + -9.575731141327346e-05, + 0.0009835467015551942, + -0.001828807023851628, + 0.0024407594224301493, + -0.002644336904102565, + 0.002321370370940948, + -0.0014465226885409, + 0.00010912299971391861, + 0.0014863005385165546, + -0.0030444757114376, + 0.004227621393143003, + -0.004720858410663518, + 0.00430340749485201, + -0.0029111568371450493, + 0.0006758266942872845, + 0.002071261954870286, + -0.004837052438450331, + 0.007044582477270947, + -0.008140448727362718, + 0.0077138932032073445, + -0.005604540990581585, + 0.0019749656455550968, + 0.0026718056262489383, + -0.007541245521216586, + 0.011662297443732754, + -0.014054752766974423, + 0.0139234284401599, + -0.010845235097865776, + 0.0049126327506936645, + 0.0031988445349823255, + -0.01226053329472526, + 0.020623711066876563, + -0.026443075826064425, + 0.027960344694893176, + -0.023804280659778104, + 0.01325702377313349, + 0.0035612135716636354, + -0.025626116624367066, + 0.05108081411605677, + -0.07744152221841791, + 0.10191100680419664, + -0.12175444572282804, + 0.1346803352883561, + 0.8608333333333897, + 0.1346803352883561, + -0.12175444572282804, + 0.10191100680419664, + -0.07744152221841791, + 0.05108081411605677, + -0.025626116624367066, + 0.0035612135716636354, + 0.01325702377313349, + -0.023804280659778104, + 0.027960344694893176, + -0.026443075826064425, + 0.020623711066876563, + -0.01226053329472526, + 0.0031988445349823255, + 0.0049126327506936645, + -0.010845235097865776, + 0.0139234284401599, + -0.014054752766974423, + 0.011662297443732754, + -0.007541245521216586, + 0.0026718056262489383, + 0.0019749656455550968, + -0.005604540990581585, + 0.0077138932032073445, + -0.008140448727362718, + 0.007044582477270947, + -0.004837052438450331, + 0.002071261954870286, + 0.0006758266942872845, + -0.0029111568371450493, + 0.00430340749485201, + -0.004720858410663518, + 0.004227621393143003, + -0.0030444757114376, + 0.0014863005385165546, + 0.00010912299971391861, + -0.0014465226885409, + 0.002321370370940948, + -0.002644336904102565, + 0.0024407594224301493, + -0.001828807023851628, + 0.0009835467015551942, + -9.575731141327346e-05, + -0.0006659459018028209, + 0.001183005538332482, + -0.0014010675688317755, + 0.0013298141762067902, + -0.0010307540796842497, + 0.0005972048317626658, + -0.0001315408318317103, + -0.00027549921950280733, + 0.0005598234351094426, + -0.0006913872260666551, + 0.0006738503239522973, + -0.000537884656631541, + 0.0003305257920305843, + -0.0001033189088939493, + -9.823590003163207e-05, + 0.0002421329206487914, + -0.0003133321268094909, + 0.00031331992887743433, + -0.00025658320129024414, + 0.00016527387065770158, + -6.345544705962209e-05, + -2.7862808366416616e-05, + 9.409014122219963e-05, + -0.00012848221714262343, + 0.0001317501695922293, + -0.00011030659888783692, + 7.378212902653717e-05, + -3.245913549120116e-05, + -4.851687701631952e-06, + 3.216863473381749e-05, + -4.683190451509506e-05, + 4.92301628886413e-05, + -4.199180492418264e-05, + 2.8927821383294266e-05, + -1.3997250778589253e-05, + 4.97915044540138e-07, + 9.409279173382038e-06, + -1.4828839170824971e-05, + 1.5973180290174572e-05, + -1.3824155754916521e-05, + 9.729638811991692e-06, + -5.034945638176245e-06, + 8.156542880169858e-07, + 2.260451641101642e-06, + -3.949196046553083e-06, + 4.354432548140361e-06, + -3.802817981364587e-06, + 2.70957271705655e-06, + -1.4662320604642053e-06, + 3.676938974884631e-07, + 4.1772688158879863e-07, + -8.420069483888789e-07, + 9.475531903328232e-07, + -8.277448145932576e-07, + 5.896182325418432e-07, + -3.2622696353370664e-07, + 1.0159667858088225e-07, + 5.2624736306518187e-08, + -1.3210217109716104e-07, + 1.5044668040182147e-07, + -1.2924579989482033e-07, + 9.003364640559896e-08, + -4.9373422503539266e-08, + 1.7048569784995365e-08, + 3.3983200532147757e-09, + -1.2833471192711628e-08, + 1.4380896605407448e-08, + -1.1626845054841438e-08, + 7.493499387692452e-09, + -3.792077258698514e-09, + 1.2790201415889041e-09, + 2.430239393368342e-11, + -4.5843163381727067e-10, + 4.3213325781961056e-10, + -2.579276986417335e-10, + 1.0448101000984154e-10, + -2.258118962333164e-11, ]; +// β = 20.6 +// fc = 20.6 +// -195dB before 22kHz #[allow(clippy::excessive_precision)] pub const HZ88200_COEFFICIENTS: [f64; 441] = [ - -3.0915687919410175e-09, - -4.380355015683147e-09, - 7.889301672202866e-09, - 7.814782506112341e-09, - -1.601722660647997e-08, - -1.162897576000204e-08, - 2.875448571604994e-08, - 1.510435454511938e-08, - -4.758343509079679e-08, - -1.7052240013897604e-08, - 7.414020115596361e-08, - 1.5685867044913693e-08, - -1.1013103295646797e-07, - -8.486685443549004e-09, - 1.5720816822680103e-07, - -7.927830161980731e-09, - -2.1679956837762108e-07, - 3.792557598966923e-08, - 2.898880068451338e-07, - -8.695906085997518e-08, - -3.767366685630587e-07, - 1.6162916242945288e-07, - 4.765606699845109e-07, - -2.6969832218324916e-07, - -5.871467509278004e-07, - 4.200367275533767e-07, - 7.044268061921138e-07, - -6.224841713408436e-07, - -8.220148697645299e-07, - 8.876100914738924e-07, - 9.307215563684733e-07, - -1.2263549285013004e-06, - -1.0180646862659517e-06, - 1.6495375341784678e-06, - 1.0677997143447814e-06, - -2.1672160434902636e-06, - -1.0594984616938665e-06, - 2.7878934786218487e-06, - 9.682092811742628e-07, - -3.5175644448463682e-06, - -7.642359224979942e-07, - 4.3586056187007376e-06, - 4.130757186506121e-07, - -5.3085202796190045e-06, - 1.2443999883255955e-07, - 6.358555800084345e-06, - -8.917594302752569e-07, - -7.492222625290795e-06, - 1.9359346976965215e-06, - 8.683753613501706e-06, - -3.3066166723901634e-06, - -9.896553377686571e-06, - 5.054684641484621e-06, - 1.1081698107413262e-05, - -7.230482378766363e-06, - -1.2176556837151924e-05, - 9.881641808207685e-06, - 1.310361479118067e-05, - -1.3050487570176674e-05, - -1.3769587763932494e-05, - 1.6771030367931327e-05, - 1.4064922949971825e-05, - -2.1065573831506833e-05, - -1.386378567354253e-05, - 2.5940978523130324e-05, - 1.3024632549176766e-05, - -3.138464724410613e-05, - -1.1391469231232117e-05, - 3.7360317493302477e-05, - 8.795884637183773e-06, - -4.380376916620311e-05, - -5.059942993990692e-06, - 5.061857766137688e-05, - -1.2729279960739985e-18, - -5.767206367871742e-05, - 6.568510314697647e-06, - 6.479161027901487e-05, - -1.482529579321305e-05, - -7.176153430630762e-05, - 2.493843998881951e-05, - 7.832071210975769e-05, - -3.705668910231432e-05, - -8.416116770617441e-05, - 5.1300867944157375e-05, - 8.892783420621756e-05, - -6.77545401257115e-05, - -9.221969567445976e-05, - 8.645406887217791e-05, - 9.359250590922007e-05, - -0.00010737827686101525, - -9.256326236908447e-05, - 0.0001304379450839715, - 8.861658728324014e-05, - -0.0001554654305418504, - -8.121313372668574e-05, - 0.0001822047191488953, - 6.980009223001803e-05, - -0.00021030226203261508, - -5.382382370758039e-05, - 0.00023929896894150197, - 3.274458779064277e-05, - -0.00026862375023307836, - -6.0532729964936305e-06, - 0.00029758900751817864, - -2.671003221043526e-05, - -0.000325388471242336, - 6.593585899246278e-05, - 0.0003510977702523597, - -0.00011192387190357726, - -0.0003736780929427704, - 0.0001648604519001771, - 0.000391983261423784, - -0.00022479579247089605, - -0.00040477048916979987, - 0.00029162101662982327, - 0.000410715029047172, - -0.00036504587911318116, - -0.00040842884314578015, - 0.0004445776651260253, - 0.0003964833395366939, - -0.0005295019321669618, - -0.00037343612546606575, - 0.0006188657627433, - 0.00033786162350484585, - -0.0007114642013347918, - -0.0002883852891386307, - 0.0008058305372427186, - 0.00022372105788811238, - -0.0009002310648224352, - -0.0001427115403024383, - 0.0009926649033332297, - 4.437037731172248e-05, - -0.0010808693900394488, - 7.207393010339128e-05, - 0.0011623314725868622, - -0.00020713349063999724, - -0.0012343054209503327, - 0.0003610166387724715, - 0.0012938370568711898, - -0.0005335845995545083, - -0.0013377945617159535, - 0.0007243101385594058, - 0.0013629057746815654, - -0.0009322391431135004, - -0.0013658017353411673, - 0.0011559560634399873, - 0.001343066061215347, - -0.0013935540949750406, - -0.0012912895862815387, - 0.0016426109036876274, - 0.0012071295242966488, - -0.001900170582736454, - -0.0010873722658800765, - 0.0021627323794196534, - 0.0009289987749149286, - -0.0024262465443003586, - -0.0007292514223482997, - 0.002686117427541705, - 0.00048570098808220843, - -0.0029372136780933438, - -0.0001963124782057012, - 0.0031738850853730077, - -0.0001404916512597725, - -0.003389985234223304, - 0.0005257722987911238, - 0.003578898712425241, - -0.0009600199781197914, - -0.003733571100688918, - 0.001443107923088798, - 0.0038465393642386826, - -0.001974253349587081, - -0.003909959516535164, - 0.0025519880785917614, - 0.003915627483496994, - -0.003174139582456504, - -0.003854987874872023, - 0.0038378233438448386, - 0.0037191237352354268, - -0.0045394472161245205, - -0.003498718093020069, - 0.0052747282494331775, - 0.0031839749242818863, - -0.006038722202602122, - -0.0027644824727652566, - 0.006825865702928783, - 0.0022289948598659135, - -0.007630030749218701, - -0.0015650971422069776, - 0.008444590984764183, - 0.0007587019748704784, - -0.009262498902418221, - 0.00020670150584601254, - 0.010076372890169986, - -0.0013511718972066557, - -0.010878592789031707, - 0.002700017220606699, - 0.0116614024217388, - -0.004286419502573899, - -0.01241701736642861, - 0.0061555897334271996, - 0.013137736099170549, - -0.008371571243092978, - -0.013816052517290636, - 0.01102886093018991, - 0.014444767785294677, - -0.014273331179705539, - -0.015017099419278979, - 0.01834245227603654, - 0.015526785545393338, - -0.023649360357418405, - -0.01596818233340632, - 0.030978952287937712, - 0.016336352716813843, - -0.04202003363176658, - -0.016627144664162638, - 0.061174433061502255, - 0.01683725745918051, - -0.10460220813936734, - -0.01696429467574168, - 0.3178080921167005, - 0.5170068048932956, - 0.3178080921167005, - -0.01696429467574168, - -0.10460220813936734, - 0.01683725745918051, - 0.061174433061502255, - -0.016627144664162638, - -0.04202003363176658, - 0.016336352716813843, - 0.030978952287937712, - -0.01596818233340632, - -0.023649360357418405, - 0.015526785545393338, - 0.01834245227603654, - -0.015017099419278979, - -0.014273331179705539, - 0.014444767785294677, - 0.01102886093018991, - -0.013816052517290636, - -0.008371571243092978, - 0.013137736099170549, - 0.0061555897334271996, - -0.01241701736642861, - -0.004286419502573899, - 0.0116614024217388, - 0.002700017220606699, - -0.010878592789031707, - -0.0013511718972066557, - 0.010076372890169986, - 0.00020670150584601254, - -0.009262498902418221, - 0.0007587019748704784, - 0.008444590984764183, - -0.0015650971422069776, - -0.007630030749218701, - 0.0022289948598659135, - 0.006825865702928783, - -0.0027644824727652566, - -0.006038722202602122, - 0.0031839749242818863, - 0.0052747282494331775, - -0.003498718093020069, - -0.0045394472161245205, - 0.0037191237352354268, - 0.0038378233438448386, - -0.003854987874872023, - -0.003174139582456504, - 0.003915627483496994, - 0.0025519880785917614, - -0.003909959516535164, - -0.001974253349587081, - 0.0038465393642386826, - 0.001443107923088798, - -0.003733571100688918, - -0.0009600199781197914, - 0.003578898712425241, - 0.0005257722987911238, - -0.003389985234223304, - -0.0001404916512597725, - 0.0031738850853730077, - -0.0001963124782057012, - -0.0029372136780933438, - 0.00048570098808220843, - 0.002686117427541705, - -0.0007292514223482997, - -0.0024262465443003586, - 0.0009289987749149286, - 0.0021627323794196534, - -0.0010873722658800765, - -0.001900170582736454, - 0.0012071295242966488, - 0.0016426109036876274, - -0.0012912895862815387, - -0.0013935540949750406, - 0.001343066061215347, - 0.0011559560634399873, - -0.0013658017353411673, - -0.0009322391431135004, - 0.0013629057746815654, - 0.0007243101385594058, - -0.0013377945617159535, - -0.0005335845995545083, - 0.0012938370568711898, - 0.0003610166387724715, - -0.0012343054209503327, - -0.00020713349063999724, - 0.0011623314725868622, - 7.207393010339128e-05, - -0.0010808693900394488, - 4.437037731172248e-05, - 0.0009926649033332297, - -0.0001427115403024383, - -0.0009002310648224352, - 0.00022372105788811238, - 0.0008058305372427186, - -0.0002883852891386307, - -0.0007114642013347918, - 0.00033786162350484585, - 0.0006188657627433, - -0.00037343612546606575, - -0.0005295019321669618, - 0.0003964833395366939, - 0.0004445776651260253, - -0.00040842884314578015, - -0.00036504587911318116, - 0.000410715029047172, - 0.00029162101662982327, - -0.00040477048916979987, - -0.00022479579247089605, - 0.000391983261423784, - 0.0001648604519001771, - -0.0003736780929427704, - -0.00011192387190357726, - 0.0003510977702523597, - 6.593585899246278e-05, - -0.000325388471242336, - -2.671003221043526e-05, - 0.00029758900751817864, - -6.0532729964936305e-06, - -0.00026862375023307836, - 3.274458779064277e-05, - 0.00023929896894150197, - -5.382382370758039e-05, - -0.00021030226203261508, - 6.980009223001803e-05, - 0.0001822047191488953, - -8.121313372668574e-05, - -0.0001554654305418504, - 8.861658728324014e-05, - 0.0001304379450839715, - -9.256326236908447e-05, - -0.00010737827686101525, - 9.359250590922007e-05, - 8.645406887217791e-05, - -9.221969567445976e-05, - -6.77545401257115e-05, - 8.892783420621756e-05, - 5.1300867944157375e-05, - -8.416116770617441e-05, - -3.705668910231432e-05, - 7.832071210975769e-05, - 2.493843998881951e-05, - -7.176153430630762e-05, - -1.482529579321305e-05, - 6.479161027901487e-05, - 6.568510314697647e-06, - -5.767206367871742e-05, - -1.2729279960739985e-18, - 5.061857766137688e-05, - -5.059942993990692e-06, - -4.380376916620311e-05, - 8.795884637183773e-06, - 3.7360317493302477e-05, - -1.1391469231232117e-05, - -3.138464724410613e-05, - 1.3024632549176766e-05, - 2.5940978523130324e-05, - -1.386378567354253e-05, - -2.1065573831506833e-05, - 1.4064922949971825e-05, - 1.6771030367931327e-05, - -1.3769587763932494e-05, - -1.3050487570176674e-05, - 1.310361479118067e-05, - 9.881641808207685e-06, - -1.2176556837151924e-05, - -7.230482378766363e-06, - 1.1081698107413262e-05, - 5.054684641484621e-06, - -9.896553377686571e-06, - -3.3066166723901634e-06, - 8.683753613501706e-06, - 1.9359346976965215e-06, - -7.492222625290795e-06, - -8.917594302752569e-07, - 6.358555800084345e-06, - 1.2443999883255955e-07, - -5.3085202796190045e-06, - 4.130757186506121e-07, - 4.3586056187007376e-06, - -7.642359224979942e-07, - -3.5175644448463682e-06, - 9.682092811742628e-07, - 2.7878934786218487e-06, - -1.0594984616938665e-06, - -2.1672160434902636e-06, - 1.0677997143447814e-06, - 1.6495375341784678e-06, - -1.0180646862659517e-06, - -1.2263549285013004e-06, - 9.307215563684733e-07, - 8.876100914738924e-07, - -8.220148697645299e-07, - -6.224841713408436e-07, - 7.044268061921138e-07, - 4.200367275533767e-07, - -5.871467509278004e-07, - -2.6969832218324916e-07, - 4.765606699845109e-07, - 1.6162916242945288e-07, - -3.767366685630587e-07, - -8.695906085997518e-08, - 2.898880068451338e-07, - 3.792557598966923e-08, - -2.1679956837762108e-07, - -7.927830161980731e-09, - 1.5720816822680103e-07, - -8.486685443549004e-09, - -1.1013103295646797e-07, - 1.5685867044913693e-08, - 7.414020115596361e-08, - -1.7052240013897604e-08, - -4.758343509079679e-08, - 1.510435454511938e-08, - 2.875448571604994e-08, - -1.162897576000204e-08, - -1.601722660647997e-08, - 7.814782506112341e-09, - 7.889301672202866e-09, - -4.380355015683147e-09, - -3.0915687919410175e-09, + 1.2391850466535611e-11, + 3.333531231852631e-11, + -3.818076213800401e-11, + -1.1509190451828784e-10, + 6.213231728454743e-11, + 2.87564799120199e-10, + -4.83714488602796e-11, + -5.98140269952324e-10, + -7.613942071856133e-11, + 1.091658461057221e-09, + 4.366508439461712e-10, + -1.7901478075133797e-09, + -1.2235803551276082e-09, + 2.6606550552703873e-09, + 2.6983221513529074e-09, + -3.5701268624480448e-09, + -5.1850938604085815e-09, + 4.22849061463688e-09, + 9.040594409322398e-09, + -4.124314021234486e-09, + -1.4592660607406648e-08, + 2.4616283588031036e-09, + 2.2039870818100458e-08, + 1.8885900693913606e-09, + -3.1306686778954656e-08, + -1.0403682851560303e-08, + 4.185370804820422e-08, + 2.4868193950736736e-08, + -5.2450215719700035e-08, + -4.725031763559409e-08, + 6.092638395586248e-08, + 7.946970063915712e-08, + -6.393490946981877e-08, + -1.2303428788774302e-07, + 5.676541482012926e-08, + 1.78533026093471e-07, + -3.326832582637974e-08, + -2.449864750294829e-07, + -1.4044042441359084e-08, + 3.1907908092442563e-07, + 9.36452494218834e-08, + -3.9432463332063344e-07, + -2.143188256204172e-07, + 4.6024886815334354e-07, + 3.8409805762714097e-07, + -5.017077715653631e-07, + -6.087855952658568e-07, + 4.984931642791297e-07, + 8.900563561995833e-07, + -4.2540377575602484e-07, + -1.22320149064785e-06, + 2.529745550676697e-07, + 1.5946390442210958e-06, + 5.0946720741292064e-08, + -1.9793949347642123e-06, + -5.18614345326223e-07, + 2.3388400822855868e-06, + 1.178686943365455e-06, + -2.6190477406863324e-06, + -2.051402354112695e-06, + 2.750198862065714e-06, + 3.1427325820583206e-06, + -2.6475006778025306e-06, + -4.437778022762077e-06, + 2.2140819263549915e-06, + 5.893834031499378e-06, + -1.346275173199573e-06, + -7.433746697465689e-06, + -5.84176093744815e-08, + 8.940351623169533e-06, + 2.0905619376415587e-06, + -1.0252938719737726e-05, + -4.815366354286811e-06, + 1.116678371934488e-05, + 8.257045673101373e-06, + -1.1436808304058493e-05, + -1.2381782138946336e-05, + 1.07863516162757e-05, + 1.7080481116289375e-05, + -8.921836494731473e-06, + -2.2152897980823273e-05, + 5.553781010971955e-06, + 2.7295047456388915e-05, + -4.241366082350153e-07, + -3.20920511104106e-05, + -6.660662180398171e-06, + 3.6018686158196044e-05, + 1.579225072211783e-05, + -3.8449823912780616e-05, + -2.6920566641892563e-05, + 3.86826504349648e-05, + 3.9814608385366115e-05, + -3.5972018152061004e-05, + -5.40272758493732e-05, + 2.957947522797144e-05, + 6.886841768724772e-05, + -1.883547055403238e-05, + -8.339055426463937e-05, + 3.2129726777802045e-06, + 9.639178287766639e-05, + 1.7590665981469e-05, + -0.00010644003002621123, + -4.356823270696307e-05, + 0.00011192203972004702, + 7.43196068089881e-05, + -0.00011111924915469956, + -0.00010897840035651321, + 0.0001023110102270036, + 0.0001461564332782211, + -8.39035143510593e-05, + -0.0001839145994539007, + 5.458036000311854e-05, + 0.00021976848452479796, + -1.3468102824193484e-05, + -0.0002507361886566276, + -3.969247678935454e-05, + 0.00027343412277189825, + 0.00010438105445408068, + -0.00028422407111677975, + -0.00017915202264934046, + 0.00027941159473480933, + 0.0002615232577530964, + -0.0002554920062562159, + -0.0003479147183809301, + 0.00020943586336383046, + 0.0004336515130111242, + -0.00013900145970572364, + -0.0005130441646730521, + 4.305744764222408e-05, + 0.0005795556035604514, + 7.810514286236892e-05, + -0.000626059960741494, + -0.00022249525192315596, + 0.0006451926445289425, + 0.0003862040895990157, + -0.0006297846881076496, + -0.000563273268175783, + 0.0005733672979368042, + 0.0007456731567251603, + -0.00047072533356158625, + -0.0009234124120507005, + 0.00031847160782443723, + 0.0010847942203041586, + -0.00011560795133020693, + -0.001216827481451714, + -0.00013596551747171158, + 0.0013057922370346962, + 0.000431034022287387, + -0.0013379484836784292, + -0.0007607859194021795, + 0.0013003666729946694, + 0.0011127033514844527, + -0.0011818473308014906, + -0.0014706590334826724, + 0.0009738870733597434, + 0.0018152441480513153, + -0.0006716396297363814, + -0.00212434140340482, + 0.00027481405517449135, + 0.0023739441826708192, + 0.00021155117442863655, + -0.002539208026359171, + -0.0007764995060906656, + 0.002595705252002013, + 0.0014028105594797902, + -0.002520838280105065, + -0.002066946890004278, + 0.002295353243766825, + 0.0027393311085735996, + -0.0019048837776677375, + -0.0033849759136069676, + 0.0013414465376334745, + 0.003964471427659919, + -0.0006048059155471451, + -0.0044353140878159725, + -0.0002963736582894608, + 0.004753540316566857, + 0.0013436629459418286, + -0.004875607545075603, + -0.002508353422240745, + 0.004760446192255864, + 0.0037513374964797752, + -0.004371590227561371, + -0.005023403561028252, + 0.003679282168147092, + 0.006265935796833347, + -0.0026624417988238744, + -0.0074119723035414265, + 0.001310387304196292, + 0.008387531541080585, + 0.0003757967194566891, + -0.009113063498733195, + -0.002382337716262893, + 0.009504812205198838, + 0.004682375201032287, + -0.0094757769641619, + -0.007236133980982176, + 0.008935803592365966, + 0.00999169454693342, + -0.00779006602885168, + -0.012886354290132159, + 0.005934686330738007, + 0.015848541869091636, + -0.0032471953026167945, + -0.018800216515377825, + -0.00043276438591991135, + 0.021659656151486406, + 0.00534258783499553, + -0.024344514621636986, + -0.011880324982220983, + 0.026775010617614767, + 0.02080098573194893, + -0.028877100210586794, + -0.033749565270108174, + 0.03058548206942095, + 0.05507167446179364, + -0.03184628978971992, + -0.10086083835694314, + 0.03261933911867418, + 0.3165475195411714, + 0.46712018140067035, + 0.3165475195411714, + 0.03261933911867418, + -0.10086083835694314, + -0.03184628978971992, + 0.05507167446179364, + 0.03058548206942095, + -0.033749565270108174, + -0.028877100210586794, + 0.02080098573194893, + 0.026775010617614767, + -0.011880324982220983, + -0.024344514621636986, + 0.00534258783499553, + 0.021659656151486406, + -0.00043276438591991135, + -0.018800216515377825, + -0.0032471953026167945, + 0.015848541869091636, + 0.005934686330738007, + -0.012886354290132159, + -0.00779006602885168, + 0.00999169454693342, + 0.008935803592365966, + -0.007236133980982176, + -0.0094757769641619, + 0.004682375201032287, + 0.009504812205198838, + -0.002382337716262893, + -0.009113063498733195, + 0.0003757967194566891, + 0.008387531541080585, + 0.001310387304196292, + -0.0074119723035414265, + -0.0026624417988238744, + 0.006265935796833347, + 0.003679282168147092, + -0.005023403561028252, + -0.004371590227561371, + 0.0037513374964797752, + 0.004760446192255864, + -0.002508353422240745, + -0.004875607545075603, + 0.0013436629459418286, + 0.004753540316566857, + -0.0002963736582894608, + -0.0044353140878159725, + -0.0006048059155471451, + 0.003964471427659919, + 0.0013414465376334745, + -0.0033849759136069676, + -0.0019048837776677375, + 0.0027393311085735996, + 0.002295353243766825, + -0.002066946890004278, + -0.002520838280105065, + 0.0014028105594797902, + 0.002595705252002013, + -0.0007764995060906656, + -0.002539208026359171, + 0.00021155117442863655, + 0.0023739441826708192, + 0.00027481405517449135, + -0.00212434140340482, + -0.0006716396297363814, + 0.0018152441480513153, + 0.0009738870733597434, + -0.0014706590334826724, + -0.0011818473308014906, + 0.0011127033514844527, + 0.0013003666729946694, + -0.0007607859194021795, + -0.0013379484836784292, + 0.000431034022287387, + 0.0013057922370346962, + -0.00013596551747171158, + -0.001216827481451714, + -0.00011560795133020693, + 0.0010847942203041586, + 0.00031847160782443723, + -0.0009234124120507005, + -0.00047072533356158625, + 0.0007456731567251603, + 0.0005733672979368042, + -0.000563273268175783, + -0.0006297846881076496, + 0.0003862040895990157, + 0.0006451926445289425, + -0.00022249525192315596, + -0.000626059960741494, + 7.810514286236892e-05, + 0.0005795556035604514, + 4.305744764222408e-05, + -0.0005130441646730521, + -0.00013900145970572364, + 0.0004336515130111242, + 0.00020943586336383046, + -0.0003479147183809301, + -0.0002554920062562159, + 0.0002615232577530964, + 0.00027941159473480933, + -0.00017915202264934046, + -0.00028422407111677975, + 0.00010438105445408068, + 0.00027343412277189825, + -3.969247678935454e-05, + -0.0002507361886566276, + -1.3468102824193484e-05, + 0.00021976848452479796, + 5.458036000311854e-05, + -0.0001839145994539007, + -8.39035143510593e-05, + 0.0001461564332782211, + 0.0001023110102270036, + -0.00010897840035651321, + -0.00011111924915469956, + 7.43196068089881e-05, + 0.00011192203972004702, + -4.356823270696307e-05, + -0.00010644003002621123, + 1.7590665981469e-05, + 9.639178287766639e-05, + 3.2129726777802045e-06, + -8.339055426463937e-05, + -1.883547055403238e-05, + 6.886841768724772e-05, + 2.957947522797144e-05, + -5.40272758493732e-05, + -3.5972018152061004e-05, + 3.9814608385366115e-05, + 3.86826504349648e-05, + -2.6920566641892563e-05, + -3.8449823912780616e-05, + 1.579225072211783e-05, + 3.6018686158196044e-05, + -6.660662180398171e-06, + -3.20920511104106e-05, + -4.241366082350153e-07, + 2.7295047456388915e-05, + 5.553781010971955e-06, + -2.2152897980823273e-05, + -8.921836494731473e-06, + 1.7080481116289375e-05, + 1.07863516162757e-05, + -1.2381782138946336e-05, + -1.1436808304058493e-05, + 8.257045673101373e-06, + 1.116678371934488e-05, + -4.815366354286811e-06, + -1.0252938719737726e-05, + 2.0905619376415587e-06, + 8.940351623169533e-06, + -5.84176093744815e-08, + -7.433746697465689e-06, + -1.346275173199573e-06, + 5.893834031499378e-06, + 2.2140819263549915e-06, + -4.437778022762077e-06, + -2.6475006778025306e-06, + 3.1427325820583206e-06, + 2.750198862065714e-06, + -2.051402354112695e-06, + -2.6190477406863324e-06, + 1.178686943365455e-06, + 2.3388400822855868e-06, + -5.18614345326223e-07, + -1.9793949347642123e-06, + 5.0946720741292064e-08, + 1.5946390442210958e-06, + 2.529745550676697e-07, + -1.22320149064785e-06, + -4.2540377575602484e-07, + 8.900563561995833e-07, + 4.984931642791297e-07, + -6.087855952658568e-07, + -5.017077715653631e-07, + 3.8409805762714097e-07, + 4.6024886815334354e-07, + -2.143188256204172e-07, + -3.9432463332063344e-07, + 9.36452494218834e-08, + 3.1907908092442563e-07, + -1.4044042441359084e-08, + -2.449864750294829e-07, + -3.326832582637974e-08, + 1.78533026093471e-07, + 5.676541482012926e-08, + -1.2303428788774302e-07, + -6.393490946981877e-08, + 7.946970063915712e-08, + 6.092638395586248e-08, + -4.725031763559409e-08, + -5.2450215719700035e-08, + 2.4868193950736736e-08, + 4.185370804820422e-08, + -1.0403682851560303e-08, + -3.1306686778954656e-08, + 1.8885900693913606e-09, + 2.2039870818100458e-08, + 2.4616283588031036e-09, + -1.4592660607406648e-08, + -4.124314021234486e-09, + 9.040594409322398e-09, + 4.22849061463688e-09, + -5.1850938604085815e-09, + -3.5701268624480448e-09, + 2.6983221513529074e-09, + 2.6606550552703873e-09, + -1.2235803551276082e-09, + -1.7901478075133797e-09, + 4.366508439461712e-10, + 1.091658461057221e-09, + -7.613942071856133e-11, + -5.98140269952324e-10, + -4.83714488602796e-11, + 2.87564799120199e-10, + 6.213231728454743e-11, + -1.1509190451828784e-10, + -3.818076213800401e-11, + 3.333531231852631e-11, + 1.2391850466535611e-11, ]; +// β = 20.6 +// fc = 20.65 +// -195dB before 22kHz #[allow(clippy::excessive_precision)] -pub const HZ96000_COEFFICIENTS: [f64; 441] = [ - 5.560249704317343e-10, - 6.7457053197573024e-09, - 1.2990035898564e-10, - -1.3822536813261148e-08, - -2.9300911640564656e-09, - 2.399478082083703e-08, - 9.41622844952465e-09, - -3.7481047434174274e-08, - -2.1662912144899056e-08, - 5.404635607782416e-08, - 4.224936834873014e-08, - -7.277372749908042e-08, - -7.420406557781993e-08, - 9.180574659487064e-08, - 1.2087511596227733e-07, - -1.0806955116527926e-07, - -1.8571016370140034e-07, - 1.170047184434655e-07, - 2.7193189671565557e-07, - -1.1231972250589951e-07, - -3.820995948332229e-07, - 8.580858719281314e-08, - 5.175534033235693e-07, - -2.7264542219779906e-08, - -6.777463371709023e-07, - -7.546867930879655e-08, - 8.594792841000288e-07, - 2.362654075465788e-07, - -1.0560662274062185e-06, - -4.702647143542115e-07, - 1.2564701211818615e-06, - 7.931573753480084e-07, - -1.444463705583346e-06, - -1.2201828893460145e-06, - 1.5978832544551455e-06, - 1.7648179657738676e-06, - -1.6880558459176943e-06, - -2.4371537290850187e-06, - 1.6794911507065441e-06, - 3.241978858347619e-06, - -1.5299357680554498e-06, - -4.176609629091859e-06, - 1.1908906002040628e-06, - 5.228534691612452e-06, - -6.086884800383554e-07, - -6.372971415214212e-06, - -2.7378079220115605e-07, - 7.570460432970104e-06, - 1.5146285260962556e-06, - -8.764654009459012e-06, - -3.1697646987478756e-06, - 9.880480130834774e-06, - 5.288925533796424e-06, - -1.0822885686373e-05, - -7.91096385725646e-06, - 1.147637656202352e-05, - 1.1058484433166778e-05, - -1.1705577680692975e-05, - -1.4731961794014652e-05, - 1.1357029900154213e-05, - 1.8903537311698937e-05, - -1.02624213729694e-05, - -2.3510752894245287e-05, - 8.243417040440697e-06, - 2.845053771367662e-05, - -5.118200477547931e-06, - -3.357381830826675e-05, - 7.097771141127904e-07, - 3.868116747816418e-05, - 5.1439924827157876e-06, - -4.3519939664326893e-05, - -1.2578754584543908e-05, - 4.778335604530135e-05, - 2.1690650088703207e-05, - -5.1111997713789026e-05, - -3.25222717208439e-05, - 5.3098136771621236e-05, - 4.504805078593748e-05, - -5.329328046531237e-05, - -5.9159648408755305e-05, - 5.1219220953428783e-05, - 7.465203338939947e-05, - -4.638277246361614e-05, - -9.121102194406923e-05, - 3.829423929087409e-05, - 0.00010840312702721423, - -2.6489494595043767e-05, - -0.00012566860999063735, - 1.0555365102241566e-05, - 0.0001423186387411039, - 9.84218401105256e-06, - -0.00015753742873676115, - -3.492777968059588e-05, - 0.00017039017161439265, - 6.478521332693489e-05, - -0.0001798374378895852, - -9.932598355762823e-05, - 0.00018475657369415775, - 0.00013825912105014366, - -0.00018397039760952743, - -0.00018106376125474611, - 0.0001762832452577541, - 0.00022696604405721683, - -0.00016052411172711115, - -0.0002749219824710103, - 0.0001355963128374769, - 0.0003236079454914325, - -0.0001005327357148728, - -0.0003714203356632149, - 5.4555389294439867e-05, - 0.00041648590394768506, - 2.8623898269992334e-06, - -0.00045668392990309446, - -7.193305595729272e-05, - 0.0004896812037153272, - 0.00015249357603317176, - -0.0005129803811882822, - -0.00024394827954764191, - 0.0005239818498263345, - 0.0003452185393899377, - -0.0005200587535404849, - -0.0004547020805523807, - 0.0004986442886477423, - 0.0005702447116739937, - -0.00045732982127237766, - -0.000689127166061252, - 0.00039397180535415474, - 0.0008080695174294933, - -0.0003068049228110276, - -0.0009232552984091209, - 0.00019455834610855686, - 0.0010303769985912112, - -5.657156236266569e-05, - -0.0011247040600814201, - -0.00010709417927966556, - 0.0012011738336718703, - 0.00029555300653979545, - -0.001254505224223492, - -0.0005070045038801027, - 0.0012793339607298146, - 0.0007386610901853346, - -0.001270367600067128, - -0.0009866968976081866, - 0.0012225575424289717, - 0.0012462220382388606, - -0.0011312845324039525, - -0.0015112856634668026, - 0.000992553375801394, - 0.001774910578349497, - -0.0008031919524797967, - -0.002029161380794138, - 0.0005610490828306219, - 0.0022652471702039635, - -0.00026518544171678135, - -0.0024736588359997344, - -8.394846280610072e-05, - 0.0026443398223918325, - 0.0004843531929226606, - -0.0027668881061983677, - -0.0009323458453637817, - 0.0028307859575470943, - 0.0014224552392333313, - -0.0028256529198113544, - -0.001947351215488067, - 0.002741516387210494, - 0.002497811396668082, - -0.002569093217952415, - -0.003062727446644023, - 0.002300075037489875, - 0.003629151287117882, - -0.0019274092967394656, - -0.0041823798600841, - 0.0014455677851960128, - 0.004706074850303062, - -0.0008507941834454292, - -0.005182411251550035, - 0.00014132239052928864, - 0.0055922456849282496, - 0.0006824422129566309, - -0.00591529179532096, - -0.0016177857065913586, - 0.006130285582602136, - 0.0026595989567600935, - -0.006215117688556044, - -0.0038003463068190125, - 0.006146901643802061, - 0.005030093197407957, - -0.0059019354869432146, - -0.006336594699928613, - 0.00545549657976398, - 0.00770544523750543, - -0.004781381564722846, - -0.00912028798641521, - 0.003851057421363559, - 0.010563080653771224, - -0.0026322107431178856, - -0.012014412573237022, - 0.001086341830368365, - 0.013453866409008227, - 0.0008352110916833665, - -0.014860416266574179, - -0.0031979417347285668, - 0.01621285273010614, - 0.006095714026154995, - -0.017490224327851422, - -0.009671655092655702, - 0.01867228420781883, - 0.014158404619215172, - -0.019739930415957174, - -0.0199622658168629, - 0.020675628126808922, - 0.027859437853963814, - -0.021463802489478597, - -0.03952835273006745, - 0.022091191414822978, - 0.05935902511250348, - -0.02254714862612816, - -0.10349853375753784, - 0.022823888596670217, - 0.31743777574504695, - 0.47708333120157576, - 0.31743777574504695, - 0.022823888596670217, - -0.10349853375753784, - -0.02254714862612816, - 0.05935902511250348, - 0.022091191414822978, - -0.03952835273006745, - -0.021463802489478597, - 0.027859437853963814, - 0.020675628126808922, - -0.0199622658168629, - -0.019739930415957174, - 0.014158404619215172, - 0.01867228420781883, - -0.009671655092655702, - -0.017490224327851422, - 0.006095714026154995, - 0.01621285273010614, - -0.0031979417347285668, - -0.014860416266574179, - 0.0008352110916833665, - 0.013453866409008227, - 0.001086341830368365, - -0.012014412573237022, - -0.0026322107431178856, - 0.010563080653771224, - 0.003851057421363559, - -0.00912028798641521, - -0.004781381564722846, - 0.00770544523750543, - 0.00545549657976398, - -0.006336594699928613, - -0.0059019354869432146, - 0.005030093197407957, - 0.006146901643802061, - -0.0038003463068190125, - -0.006215117688556044, - 0.0026595989567600935, - 0.006130285582602136, - -0.0016177857065913586, - -0.00591529179532096, - 0.0006824422129566309, - 0.0055922456849282496, - 0.00014132239052928864, - -0.005182411251550035, - -0.0008507941834454292, - 0.004706074850303062, - 0.0014455677851960128, - -0.0041823798600841, - -0.0019274092967394656, - 0.003629151287117882, - 0.002300075037489875, - -0.003062727446644023, - -0.002569093217952415, - 0.002497811396668082, - 0.002741516387210494, - -0.001947351215488067, - -0.0028256529198113544, - 0.0014224552392333313, - 0.0028307859575470943, - -0.0009323458453637817, - -0.0027668881061983677, - 0.0004843531929226606, - 0.0026443398223918325, - -8.394846280610072e-05, - -0.0024736588359997344, - -0.00026518544171678135, - 0.0022652471702039635, - 0.0005610490828306219, - -0.002029161380794138, - -0.0008031919524797967, - 0.001774910578349497, - 0.000992553375801394, - -0.0015112856634668026, - -0.0011312845324039525, - 0.0012462220382388606, - 0.0012225575424289717, - -0.0009866968976081866, - -0.001270367600067128, - 0.0007386610901853346, - 0.0012793339607298146, - -0.0005070045038801027, - -0.001254505224223492, - 0.00029555300653979545, - 0.0012011738336718703, - -0.00010709417927966556, - -0.0011247040600814201, - -5.657156236266569e-05, - 0.0010303769985912112, - 0.00019455834610855686, - -0.0009232552984091209, - -0.0003068049228110276, - 0.0008080695174294933, - 0.00039397180535415474, - -0.000689127166061252, - -0.00045732982127237766, - 0.0005702447116739937, - 0.0004986442886477423, - -0.0004547020805523807, - -0.0005200587535404849, - 0.0003452185393899377, - 0.0005239818498263345, - -0.00024394827954764191, - -0.0005129803811882822, - 0.00015249357603317176, - 0.0004896812037153272, - -7.193305595729272e-05, - -0.00045668392990309446, - 2.8623898269992334e-06, - 0.00041648590394768506, - 5.4555389294439867e-05, - -0.0003714203356632149, - -0.0001005327357148728, - 0.0003236079454914325, - 0.0001355963128374769, - -0.0002749219824710103, - -0.00016052411172711115, - 0.00022696604405721683, - 0.0001762832452577541, - -0.00018106376125474611, - -0.00018397039760952743, - 0.00013825912105014366, - 0.00018475657369415775, - -9.932598355762823e-05, - -0.0001798374378895852, - 6.478521332693489e-05, - 0.00017039017161439265, - -3.492777968059588e-05, - -0.00015753742873676115, - 9.84218401105256e-06, - 0.0001423186387411039, - 1.0555365102241566e-05, - -0.00012566860999063735, - -2.6489494595043767e-05, - 0.00010840312702721423, - 3.829423929087409e-05, - -9.121102194406923e-05, - -4.638277246361614e-05, - 7.465203338939947e-05, - 5.1219220953428783e-05, - -5.9159648408755305e-05, - -5.329328046531237e-05, - 4.504805078593748e-05, - 5.3098136771621236e-05, - -3.25222717208439e-05, - -5.1111997713789026e-05, - 2.1690650088703207e-05, - 4.778335604530135e-05, - -1.2578754584543908e-05, - -4.3519939664326893e-05, - 5.1439924827157876e-06, - 3.868116747816418e-05, - 7.097771141127904e-07, - -3.357381830826675e-05, - -5.118200477547931e-06, - 2.845053771367662e-05, - 8.243417040440697e-06, - -2.3510752894245287e-05, - -1.02624213729694e-05, - 1.8903537311698937e-05, - 1.1357029900154213e-05, - -1.4731961794014652e-05, - -1.1705577680692975e-05, - 1.1058484433166778e-05, - 1.147637656202352e-05, - -7.91096385725646e-06, - -1.0822885686373e-05, - 5.288925533796424e-06, - 9.880480130834774e-06, - -3.1697646987478756e-06, - -8.764654009459012e-06, - 1.5146285260962556e-06, - 7.570460432970104e-06, - -2.7378079220115605e-07, - -6.372971415214212e-06, - -6.086884800383554e-07, - 5.228534691612452e-06, - 1.1908906002040628e-06, - -4.176609629091859e-06, - -1.5299357680554498e-06, - 3.241978858347619e-06, - 1.6794911507065441e-06, - -2.4371537290850187e-06, - -1.6880558459176943e-06, - 1.7648179657738676e-06, - 1.5978832544551455e-06, - -1.2201828893460145e-06, - -1.444463705583346e-06, - 7.931573753480084e-07, - 1.2564701211818615e-06, - -4.702647143542115e-07, - -1.0560662274062185e-06, - 2.362654075465788e-07, - 8.594792841000288e-07, - -7.546867930879655e-08, - -6.777463371709023e-07, - -2.7264542219779906e-08, - 5.175534033235693e-07, - 8.580858719281314e-08, - -3.820995948332229e-07, - -1.1231972250589951e-07, - 2.7193189671565557e-07, - 1.170047184434655e-07, - -1.8571016370140034e-07, - -1.0806955116527926e-07, - 1.2087511596227733e-07, - 9.180574659487064e-08, - -7.420406557781993e-08, - -7.277372749908042e-08, - 4.224936834873014e-08, - 5.404635607782416e-08, - -2.1662912144899056e-08, - -3.7481047434174274e-08, - 9.41622844952465e-09, - 2.399478082083703e-08, - -2.9300911640564656e-09, - -1.3822536813261148e-08, - 1.2990035898564e-10, - 6.7457053197573024e-09, - 5.560249704317343e-10, +pub const HZ96000_COEFFICIENTS: [f64; 481] = [ + -1.1994395146732941e-11, + 1.915913091651547e-11, + 5.960745176448492e-11, + -1.3061824926945334e-11, + -1.5601965248971414e-10, + -7.018946259546669e-11, + 2.809141662660533e-10, + 3.0701859865581745e-10, + -3.4623720597839356e-10, + -7.560570063834295e-10, + 1.7447498568802657e-10, + 1.3876779389493582e-09, + 4.841122743309274e-10, + -1.9950759509148982e-09, + -1.8677373375643354e-09, + 2.1241568247563375e-09, + 4.040333248197303e-09, + -1.0805250278628995e-09, + -6.6709623778697e-09, + -1.9223082282338022e-09, + 8.824396176308693e-09, + 7.432242319481839e-09, + -8.879743628810473e-09, + -1.526391589543894e-08, + 4.7187712854981555e-09, + 2.395097795739618e-08, + 5.699370544081556e-09, + -3.035967368747228e-08, + -2.3354970601865938e-08, + 2.9753058833130447e-08, + 4.6919535092840925e-08, + -1.6591644718097893e-08, + -7.159335536018259e-08, + -1.377054465796504e-08, + 8.856657748781657e-08, + 6.260407964576534e-08, + -8.57196191379699e-08, + -1.2502708392121218e-07, + 5.005664742272042e-08, + 1.8782810133829837e-07, + 2.8016936501450825e-08, + -2.2906722734906596e-07, + -1.4909601103428738e-07, + 2.206254163789919e-07, + 2.991551330257851e-07, + -1.3442648724143923e-07, + -4.4590734890745537e-07, + -4.7879991080474856e-08, + 5.394825425816262e-07, + 3.2331554237412893e-07, + -5.194446675053159e-07, + -6.57027401634456e-07, + 3.289904476631279e-07, + 9.768751569312674e-07, + 6.484665244473348e-08, + -1.1774482315206333e-06, + -6.487149967509684e-07, + 1.1367035368094803e-06, + 1.3443762821484977e-06, + -7.457595423462837e-07, + -2.0017613173009023e-06, + -5.1597883890098977e-08, + 2.411048558044751e-06, + 1.2177127242482222e-06, + -2.3383632432586653e-06, + -2.5901102398864627e-06, + 1.584294923048922e-06, + 3.874557757285263e-06, + -5.710332117813373e-08, + -4.67416428974752e-06, + -2.1552409835570375e-06, + 4.560474161361854e-06, + 4.735928837508751e-06, + -3.1823115172240006e-06, + -7.136437289370632e-06, + 3.9537838003464527e-07, + 8.638487741992554e-06, + 3.6168030625091555e-06, + -8.487457353378934e-06, + -8.268279687162828e-06, + 6.08570579554361e-06, + 1.2580315824988063e-05, + -1.2131040701919644e-06, + -1.5302661405843096e-05, + -5.777021855417445e-06, + 1.5151846270420658e-05, + 1.384911600179759e-05, + -1.1141109862235736e-05, + -2.1323121189248238e-05, + 2.942823993601164e-06, + 2.6097190687324947e-05, + 8.803876391769033e-06, + -2.605572654342193e-05, + -2.2340476276265842e-05, + 1.9612964695179654e-05, + 3.488121193630334e-05, + -6.290426820769221e-06, + -4.300164683848037e-05, + -1.2813427009008755e-05, + 4.3312083775684775e-05, + 3.48167368145463e-05, + -3.332549671812382e-05, + -5.5242609990036297e-05, + 1.2352369776983332e-05, + 6.866855793659725e-05, + 1.7799995928150835e-05, + -6.980212930301614e-05, + -5.2557793316981136e-05, + 5.482811512633073e-05, + 8.492850576208972e-05, + -2.2760842363500776e-05, + -0.00010654680234804103, + -2.3537583858735534e-05, + 0.00010934295961065633, + 7.701671223906466e-05, + -8.758109455240882e-05, + -0.00012703637978599055, + 3.985676013463422e-05, + 0.000160996958416934, + 2.9449694220786016e-05, + -0.0001668593951537981, + -0.00010975678946015862, + 0.00013615772393127433, + 0.00018525861849561634, + -6.68894489448072e-05, + -0.0002373927755966462, + -3.4446399696334056e-05, + 0.0002485555889307161, + 0.00015235556237131378, + -0.00020646049212939892, + -0.0002638742511127665, + 0.00010824229568279674, + 0.00034220774450222953, + 3.672879517702098e-05, + -0.00036208738952237034, + -0.00020627705332200324, + 0.0003059539182138257, + 0.00036771798854165044, + -0.000169686983664989, + -0.0004830949655477637, + -3.356087538554157e-05, + 0.000516747424579293, + 0.0002727180713288947, + -0.0004439276317579888, + -0.0005021408279491042, + 0.0002586774737622995, + 0.0006689840372751786, + 2.1005660832265722e-05, + -0.0007236944059030511, + -0.0003524392471042917, + 0.0006318239364446761, + 0.0006729912856795399, + -0.00038471232202596237, + -0.0009102437079813836, + 6.38666808859098e-06, + 0.0009962913814304114, + 0.0004455959415068065, + -0.000883700794702363, + -0.0008866682568559575, + 0.0005598267515351781, + 0.0012189997524931617, + -5.597052247416223e-05, + -0.0013506744814651686, + -0.0005515874903799232, + 0.0012169664404254664, + 0.0011503309637701427, + -0.0007993367464203114, + -0.0016097669927078522, + 0.00013754769531381425, + 0.0018067748745233803, + 0.0006689447112888635, + -0.0016536419135613023, + -0.0014724108324020095, + 0.0011230729782408402, + 0.002100681647505729, + -0.0002642101377135884, + -0.0023902085007997164, + -0.0007952746528221351, + 0.0022226419001671943, + 0.0018636837000276705, + -0.0015575734284970257, + -0.002715873624285176, + 0.00045379149820339325, + 0.003135840880826238, + 0.000927277958513202, + -0.0029640553852661746, + -0.002339401002118082, + 0.0021401998423146917, + 0.0034900692956516236, + -0.0007315871721489155, + -0.004094709676209372, + -0.0010608480645675196, + 0.003937529987755766, + 0.002923538240315551, + -0.0029273062430608095, + -0.004477830306334461, + 0.0011358453900638611, + 0.005348134434122349, + 0.0011912532792074859, + -0.005239696871558134, + -0.0036576629006305752, + 0.00401161436225257, + 0.005773326918770769, + -0.0017297944791563327, + -0.007038739381869608, + -0.0013133934970218752, + 0.007043643801584631, + 0.0046211349636550774, + -0.005562920332614075, + -0.007557142405019193, + 0.0026309665606692157, + 0.009446822141073024, + 0.0014221140453043691, + -0.009700340779953782, + -0.005983789053885521, + 0.007937816806243354, + 0.010225042584697239, + -0.004094712744425417, + -0.01321279387321101, + -0.0015125512082305491, + 0.014053552677719357, + 0.00817458594195583, + -0.012046130339034358, + -0.014834568635464904, + 0.006817826441535441, + 0.020182379994583177, + 0.0015804785111363736, + -0.02277241530222604, + -0.012639398046523115, + 0.021117172951004536, + 0.025426139972915516, + -0.013660357026856107, + -0.038688052580126614, + -0.001622620777002329, + 0.05101135603655969, + 0.02896082858633861, + -0.06101196868999017, + -0.0838338660597568, + 0.06752918327641895, + 0.3106351462916042, + 0.4302083333281181, + 0.3106351462916042, + 0.06752918327641895, + -0.0838338660597568, + -0.06101196868999017, + 0.02896082858633861, + 0.05101135603655969, + -0.001622620777002329, + -0.038688052580126614, + -0.013660357026856107, + 0.025426139972915516, + 0.021117172951004536, + -0.012639398046523115, + -0.02277241530222604, + 0.0015804785111363736, + 0.020182379994583177, + 0.006817826441535441, + -0.014834568635464904, + -0.012046130339034358, + 0.00817458594195583, + 0.014053552677719357, + -0.0015125512082305491, + -0.01321279387321101, + -0.004094712744425417, + 0.010225042584697239, + 0.007937816806243354, + -0.005983789053885521, + -0.009700340779953782, + 0.0014221140453043691, + 0.009446822141073024, + 0.0026309665606692157, + -0.007557142405019193, + -0.005562920332614075, + 0.0046211349636550774, + 0.007043643801584631, + -0.0013133934970218752, + -0.007038739381869608, + -0.0017297944791563327, + 0.005773326918770769, + 0.00401161436225257, + -0.0036576629006305752, + -0.005239696871558134, + 0.0011912532792074859, + 0.005348134434122349, + 0.0011358453900638611, + -0.004477830306334461, + -0.0029273062430608095, + 0.002923538240315551, + 0.003937529987755766, + -0.0010608480645675196, + -0.004094709676209372, + -0.0007315871721489155, + 0.0034900692956516236, + 0.0021401998423146917, + -0.002339401002118082, + -0.0029640553852661746, + 0.000927277958513202, + 0.003135840880826238, + 0.00045379149820339325, + -0.002715873624285176, + -0.0015575734284970257, + 0.0018636837000276705, + 0.0022226419001671943, + -0.0007952746528221351, + -0.0023902085007997164, + -0.0002642101377135884, + 0.002100681647505729, + 0.0011230729782408402, + -0.0014724108324020095, + -0.0016536419135613023, + 0.0006689447112888635, + 0.0018067748745233803, + 0.00013754769531381425, + -0.0016097669927078522, + -0.0007993367464203114, + 0.0011503309637701427, + 0.0012169664404254664, + -0.0005515874903799232, + -0.0013506744814651686, + -5.597052247416223e-05, + 0.0012189997524931617, + 0.0005598267515351781, + -0.0008866682568559575, + -0.000883700794702363, + 0.0004455959415068065, + 0.0009962913814304114, + 6.38666808859098e-06, + -0.0009102437079813836, + -0.00038471232202596237, + 0.0006729912856795399, + 0.0006318239364446761, + -0.0003524392471042917, + -0.0007236944059030511, + 2.1005660832265722e-05, + 0.0006689840372751786, + 0.0002586774737622995, + -0.0005021408279491042, + -0.0004439276317579888, + 0.0002727180713288947, + 0.000516747424579293, + -3.356087538554157e-05, + -0.0004830949655477637, + -0.000169686983664989, + 0.00036771798854165044, + 0.0003059539182138257, + -0.00020627705332200324, + -0.00036208738952237034, + 3.672879517702098e-05, + 0.00034220774450222953, + 0.00010824229568279674, + -0.0002638742511127665, + -0.00020646049212939892, + 0.00015235556237131378, + 0.0002485555889307161, + -3.4446399696334056e-05, + -0.0002373927755966462, + -6.68894489448072e-05, + 0.00018525861849561634, + 0.00013615772393127433, + -0.00010975678946015862, + -0.0001668593951537981, + 2.9449694220786016e-05, + 0.000160996958416934, + 3.985676013463422e-05, + -0.00012703637978599055, + -8.758109455240882e-05, + 7.701671223906466e-05, + 0.00010934295961065633, + -2.3537583858735534e-05, + -0.00010654680234804103, + -2.2760842363500776e-05, + 8.492850576208972e-05, + 5.482811512633073e-05, + -5.2557793316981136e-05, + -6.980212930301614e-05, + 1.7799995928150835e-05, + 6.866855793659725e-05, + 1.2352369776983332e-05, + -5.5242609990036297e-05, + -3.332549671812382e-05, + 3.48167368145463e-05, + 4.3312083775684775e-05, + -1.2813427009008755e-05, + -4.300164683848037e-05, + -6.290426820769221e-06, + 3.488121193630334e-05, + 1.9612964695179654e-05, + -2.2340476276265842e-05, + -2.605572654342193e-05, + 8.803876391769033e-06, + 2.6097190687324947e-05, + 2.942823993601164e-06, + -2.1323121189248238e-05, + -1.1141109862235736e-05, + 1.384911600179759e-05, + 1.5151846270420658e-05, + -5.777021855417445e-06, + -1.5302661405843096e-05, + -1.2131040701919644e-06, + 1.2580315824988063e-05, + 6.08570579554361e-06, + -8.268279687162828e-06, + -8.487457353378934e-06, + 3.6168030625091555e-06, + 8.638487741992554e-06, + 3.9537838003464527e-07, + -7.136437289370632e-06, + -3.1823115172240006e-06, + 4.735928837508751e-06, + 4.560474161361854e-06, + -2.1552409835570375e-06, + -4.67416428974752e-06, + -5.710332117813373e-08, + 3.874557757285263e-06, + 1.584294923048922e-06, + -2.5901102398864627e-06, + -2.3383632432586653e-06, + 1.2177127242482222e-06, + 2.411048558044751e-06, + -5.1597883890098977e-08, + -2.0017613173009023e-06, + -7.457595423462837e-07, + 1.3443762821484977e-06, + 1.1367035368094803e-06, + -6.487149967509684e-07, + -1.1774482315206333e-06, + 6.484665244473348e-08, + 9.768751569312674e-07, + 3.289904476631279e-07, + -6.57027401634456e-07, + -5.194446675053159e-07, + 3.2331554237412893e-07, + 5.394825425816262e-07, + -4.7879991080474856e-08, + -4.4590734890745537e-07, + -1.3442648724143923e-07, + 2.991551330257851e-07, + 2.206254163789919e-07, + -1.4909601103428738e-07, + -2.2906722734906596e-07, + 2.8016936501450825e-08, + 1.8782810133829837e-07, + 5.005664742272042e-08, + -1.2502708392121218e-07, + -8.57196191379699e-08, + 6.260407964576534e-08, + 8.856657748781657e-08, + -1.377054465796504e-08, + -7.159335536018259e-08, + -1.6591644718097893e-08, + 4.6919535092840925e-08, + 2.9753058833130447e-08, + -2.3354970601865938e-08, + -3.035967368747228e-08, + 5.699370544081556e-09, + 2.395097795739618e-08, + 4.7187712854981555e-09, + -1.526391589543894e-08, + -8.879743628810473e-09, + 7.432242319481839e-09, + 8.824396176308693e-09, + -1.9223082282338022e-09, + -6.6709623778697e-09, + -1.0805250278628995e-09, + 4.040333248197303e-09, + 2.1241568247563375e-09, + -1.8677373375643354e-09, + -1.9950759509148982e-09, + 4.841122743309274e-10, + 1.3876779389493582e-09, + 1.7447498568802657e-10, + -7.560570063834295e-10, + -3.4623720597839356e-10, + 3.0701859865581745e-10, + 2.809141662660533e-10, + -7.018946259546669e-11, + -1.5601965248971414e-10, + -1.3061824926945334e-11, + 5.960745176448492e-11, + 1.915913091651547e-11, + -1.1994395146732941e-11, ]; diff --git a/playback/src/normaliser.rs b/playback/src/normaliser.rs index 0807e449..04b7ed32 100644 --- a/playback/src/normaliser.rs +++ b/playback/src/normaliser.rs @@ -7,32 +7,6 @@ use crate::{ ratio_to_db, PCM_AT_0DBFS, }; -struct NoNormalisation; - -impl NoNormalisation { - fn normalise(mut samples: Vec, volume: f64) -> Vec { - if volume < 1.0 { - samples.iter_mut().for_each(|sample| *sample *= volume); - } - - samples - } -} - -struct BasicNormalisation; - -impl BasicNormalisation { - fn normalise(mut samples: Vec, volume: f64, factor: f64) -> Vec { - if volume < 1.0 || factor < 1.0 { - samples - .iter_mut() - .for_each(|sample| *sample *= factor * volume); - } - - samples - } -} - #[derive(PartialEq)] struct DynamicNormalisation { threshold_db: f64, @@ -194,12 +168,35 @@ impl Normalisation { } } - fn normalise(&mut self, samples: Vec, volume: f64, factor: f64) -> Vec { + fn normalise(&mut self, mut samples: Vec, volume: f64, factor: f64) -> Vec { use Normalisation::*; match self { - None => NoNormalisation::normalise(samples, volume), - Basic => BasicNormalisation::normalise(samples, volume, factor), + None => { + // We only care about volume. + // We don't care about factor. + // volume: 0.0 - 1.0 + if volume < 1.0 { + // for each sample: sample = sample * volume + samples.iter_mut().for_each(|sample| *sample *= volume); + } + + samples + } + Basic => { + // We care about both volume and factor. + // volume: 0.0 - 1.0 + // factor: 0.0 - 1.0 + if volume < 1.0 || factor < 1.0 { + // for each sample: sample = sample * volume * factor + samples + .iter_mut() + .for_each(|sample| *sample *= volume * factor); + } + + samples + } + // We don't care about anything, DynamicNormalisation does that for us. Dynamic(ref mut d) => d.normalise(samples, volume, factor), } } @@ -222,7 +219,7 @@ impl Normaliser { normalisation_type: config.normalisation_type, pregain_db: config.normalisation_pregain_db, threshold_dbfs: config.normalisation_threshold_dbfs, - factor: 1.0, + factor: 0.0, } } @@ -233,6 +230,7 @@ impl Normaliser { } pub fn stop(&mut self) { + self.factor = 0.0; self.normalisation.stop(); } @@ -241,6 +239,8 @@ impl Normaliser { auto_normalise_as_album: bool, data: NormalisationData, ) { + // Normalisation::None doesn't use the factor, + // so there is no need to waste the time calculating it. if self.normalisation != Normalisation::None { self.factor = self.get_factor(auto_normalise_as_album, data); } @@ -326,6 +326,7 @@ impl Normaliser { }; debug!("Normalisation Data: {:?}", data); + debug!("Normalisation Type: {:?}", self.normalisation_type); debug!( "Calculated Normalisation Factor for {:?}: {:.2}%", norm_type, diff --git a/playback/src/resampler.rs b/playback/src/resampler.rs index 7642e44f..17f141c3 100644 --- a/playback/src/resampler.rs +++ b/playback/src/resampler.rs @@ -1,76 +1,60 @@ use std::{ - collections::{vec_deque, VecDeque}, - process::exit, - sync::atomic::Ordering, - sync::mpsc, - thread, + collections::VecDeque, process::exit, sync::atomic::Ordering::SeqCst, sync::mpsc, thread, }; -use crate::{ - config::SampleRate, player::PLAYER_COUNTER, RESAMPLER_INPUT_SIZE, - SAMPLE_RATE as SOURCE_SAMPLE_RATE, -}; - -struct DelayLine { - buffer: VecDeque, - coefficients_length: usize, -} - -impl DelayLine { - fn new(coefficients_length: usize) -> DelayLine { - Self { - buffer: VecDeque::with_capacity(coefficients_length), - coefficients_length, - } - } - - fn push(&mut self, sample: f64) { - self.buffer.push_back(sample); - - while self.buffer.len() > self.coefficients_length { - self.buffer.pop_front(); - } - } - - fn clear(&mut self) { - self.buffer.clear(); - } -} - -impl<'a> IntoIterator for &'a DelayLine { - type Item = &'a f64; - type IntoIter = vec_deque::Iter<'a, f64>; - - fn into_iter(self) -> Self::IntoIter { - self.buffer.iter() - } -} +use crate::{config::SampleRate, player::PLAYER_COUNTER, RESAMPLER_INPUT_SIZE}; struct ConvolutionFilter { coefficients: Vec, - delay_line: DelayLine, + coefficients_length: usize, + delay_line: VecDeque, } impl ConvolutionFilter { fn new(coefficients: Vec) -> Self { - let delay_line = DelayLine::new(coefficients.len()); + let coefficients_length = coefficients.len(); + let delay_line = VecDeque::with_capacity(coefficients_length); Self { coefficients, + coefficients_length, delay_line, } } - fn convolute(&mut self, sample: f64) -> f64 { - self.delay_line.push(sample); - - // Temporal convolution - self.coefficients + fn get_convoluted_sample(&mut self) -> f64 { + let output_sample = self + .coefficients .iter() .zip(&self.delay_line) .fold(0.0, |acc, (coefficient, delay_line_sample)| { acc + coefficient * delay_line_sample - }) + }); + + self.delay_line.pop_front(); + + output_sample + } + + fn convolute(&mut self, sample: f64) -> f64 { + self.delay_line.push_back(sample); + + if self.delay_line.len() == self.coefficients_length { + self.get_convoluted_sample() + } else { + 0.0 + } + } + + fn drain(&mut self) -> Vec { + let delay_line_len = self.delay_line.len(); + let mut output = Vec::with_capacity(delay_line_len); + + for _ in 0..delay_line_len { + output.push(self.get_convoluted_sample()); + } + + output } fn clear(&mut self) { @@ -81,6 +65,7 @@ impl ConvolutionFilter { struct MonoSincResampler { interpolator: ConvolutionFilter, input_buffer: Vec, + resample_factor: f64, resample_factor_reciprocal: f64, delay_line_latency: u64, interpolation_output_size: usize, @@ -92,6 +77,8 @@ impl MonoSincResampler { .get_interpolation_coefficients() .unwrap_or_default(); + let resample_factor = sample_rate.get_resample_factor().unwrap_or_default(); + let resample_factor_reciprocal = sample_rate .get_resample_factor_reciprocal() .unwrap_or_default(); @@ -104,7 +91,8 @@ impl MonoSincResampler { Self { interpolator: ConvolutionFilter::new(coefficients), - input_buffer: Vec::with_capacity(SOURCE_SAMPLE_RATE as usize), + input_buffer: Vec::with_capacity(RESAMPLER_INPUT_SIZE), + resample_factor, resample_factor_reciprocal, delay_line_latency, interpolation_output_size, @@ -120,40 +108,76 @@ impl MonoSincResampler { self.input_buffer.clear(); } - fn resample(&mut self, samples: &[f64]) -> Option> { + fn drain(&mut self) -> (Option>, u64) { + // On drain the interpolation isn't perfect for a couple reasons: + // 1. buffer len * resample_factor more than likely isn't an integer. + // 2. As you drain the delay line there are less and less samples to use for interpolation. + let output_len = (self.input_buffer.len() as f64 * self.resample_factor) as usize; + let mut output = Vec::with_capacity(output_len); + + output.extend((0..output_len).map(|ouput_index| { + self.interpolator.convolute( + *self + .input_buffer + .get((ouput_index as f64 * self.resample_factor_reciprocal) as usize) + .unwrap_or(&0.0), + ) + })); + + let interpolator_drainage = self.interpolator.drain(); + + output.reserve_exact(interpolator_drainage.len()); + + output.extend(interpolator_drainage.iter()); + + let output_len = output.len() as f64; + + // Do a simple linear fade out of the drainage (about 5ms) to hide/prevent audible artifacts. + for (index, sample) in output.iter_mut().enumerate() { + let fade_factor = 1.0 - (index as f64) / output_len; + *sample *= fade_factor; + } + + (Some(output), 0) + } + + fn resample(&mut self, samples: &[f64]) -> (Option>, u64) { self.input_buffer.extend_from_slice(samples); let num_buffer_chunks = self.input_buffer.len().saturating_div(RESAMPLER_INPUT_SIZE); if num_buffer_chunks == 0 { - return None; + return (None, self.get_latency_pcm()); } let input_size = num_buffer_chunks * RESAMPLER_INPUT_SIZE; - // The size of the output after interpolation. + let output_size = num_buffer_chunks * self.interpolation_output_size; let mut output = Vec::with_capacity(output_size); output.extend((0..output_size).map(|ouput_index| { - // The factional weights are already calculated and factored - // into our interpolation coefficients so all we have to - // do is pretend we're doing nearest-neighbor interpolation - // and push samples though the Interpolator and what comes - // out the other side is Sinc Windowed Interpolated samples. - let sample_index = (ouput_index as f64 * self.resample_factor_reciprocal) as usize; - let sample = self.input_buffer[sample_index]; - self.interpolator.convolute(sample) + // Since the interpolation coefficients are pre-calculated we can pretend like + // we're doing nearest neighbor interpolation and then push the samples though + // the interpolator as if it were a simple FIR filter (which it actually also is). + // What comes out the other side is anti-aliased windowed sinc interpolated samples. + self.interpolator.convolute( + *self + .input_buffer + .get((ouput_index as f64 * self.resample_factor_reciprocal) as usize) + .unwrap_or(&0.0), + ) })); self.input_buffer.drain(..input_size); - Some(output) + (Some(output), self.get_latency_pcm()) } } enum ResampleTask { Stop, + Drain, Terminate, Resample(Vec), } @@ -165,12 +189,14 @@ struct ResampleWorker { } impl ResampleWorker { - fn new(mut resampler: MonoSincResampler, name: String) -> Self { + fn new(sample_rate: SampleRate, name: String) -> Self { let (task_sender, task_receiver) = mpsc::channel(); let (result_sender, result_receiver) = mpsc::channel(); let builder = thread::Builder::new().name(name.clone()); + let mut resampler = MonoSincResampler::new(sample_rate); + let handle = match builder.spawn(move || loop { match task_receiver.recv() { Err(e) => { @@ -183,11 +209,11 @@ impl ResampleWorker { } Ok(task) => match task { ResampleTask::Stop => resampler.stop(), + ResampleTask::Drain => { + result_sender.send(resampler.drain()).ok(); + } ResampleTask::Resample(samples) => { - let resampled = resampler.resample(&samples); - let latency = resampler.get_latency_pcm(); - - result_sender.send((resampled, latency)).ok(); + result_sender.send(resampler.resample(&samples)).ok(); } ResampleTask::Terminate => { loop { @@ -231,6 +257,12 @@ impl ResampleWorker { .and_then(|sender| sender.send(ResampleTask::Stop).ok()); } + fn drain(&mut self) { + self.task_sender + .as_mut() + .and_then(|sender| sender.send(ResampleTask::Drain).ok()); + } + fn resample(&mut self, samples: Vec) { self.task_sender .as_mut() @@ -294,16 +326,16 @@ impl StereoInterleavedResampler { 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); + let player_id = PLAYER_COUNTER.load(SeqCst).saturating_sub(1); Resampler::Worker { left_resampler: ResampleWorker::new( - MonoSincResampler::new(sample_rate), - format!("resampler:{player_id}:left"), + sample_rate, + format!("resampler:L:{player_id}"), ), right_resampler: ResampleWorker::new( - MonoSincResampler::new(sample_rate), - format!("resampler:{player_id}:right"), + sample_rate, + format!("resampler:R:{player_id}"), ), } } @@ -319,6 +351,26 @@ impl StereoInterleavedResampler { self.latency_pcm } + pub fn drain(&mut self) -> Option> { + match &mut self.resampler { + // Bypass is basically a no-op. + Resampler::Bypass => None, + Resampler::Worker { + left_resampler, + right_resampler, + } => { + left_resampler.drain(); + right_resampler.drain(); + + let (resampled, latency_pcm) = Self::get_resampled(left_resampler, right_resampler); + + self.latency_pcm = latency_pcm; + + resampled + } + } + } + pub fn resample(&mut self, input_samples: Vec) -> Option> { match &mut self.resampler { // Bypass is basically a no-op. @@ -332,17 +384,11 @@ impl StereoInterleavedResampler { left_resampler.resample(left_samples); right_resampler.resample(right_samples); - let (left_resampled, left_latency_pcm) = left_resampler.get_resampled(); - let (right_resampled, right_latency_pcm) = right_resampler.get_resampled(); + let (resampled, latency_pcm) = Self::get_resampled(left_resampler, right_resampler); - // They should always be equal - self.latency_pcm = left_latency_pcm.max(right_latency_pcm); + self.latency_pcm = latency_pcm; - left_resampled.and_then(|left_samples| { - right_resampled.map(|right_samples| { - Self::interleave_samples(&left_samples, &right_samples) - }) - }) + resampled } } } @@ -364,6 +410,24 @@ impl StereoInterleavedResampler { } } + fn get_resampled( + left_resampler: &mut ResampleWorker, + right_resampler: &mut ResampleWorker, + ) -> (Option>, u64) { + let (left_resampled, left_latency_pcm) = left_resampler.get_resampled(); + let (right_resampled, right_latency_pcm) = right_resampler.get_resampled(); + + let resampled = left_resampled.and_then(|left_samples| { + right_resampled + .map(|right_samples| Self::interleave_samples(&left_samples, &right_samples)) + }); + + // They should always be equal + let latency_pcm = left_latency_pcm.max(right_latency_pcm); + + (resampled, latency_pcm) + } + fn interleave_samples(left_samples: &[f64], right_samples: &[f64]) -> Vec { // Re-interleave the resampled channels. let mut output = Vec::with_capacity(left_samples.len() + right_samples.len()); diff --git a/playback/src/sample_pipeline.rs b/playback/src/sample_pipeline.rs index 53bbc29f..b8e438ef 100644 --- a/playback/src/sample_pipeline.rs +++ b/playback/src/sample_pipeline.rs @@ -10,15 +10,120 @@ use crate::{ MS_PER_PAGE, }; -pub struct SamplePipeline { +pub enum SamplePipeline { + PassThrough(Bypass), + Process(Pipeline), +} + +impl SamplePipeline { + pub fn new( + config: &PlayerConfig, + sink: Box, + volume_getter: Box, + ) -> Self { + if config.passthrough { + SamplePipeline::PassThrough(Bypass::new(config, sink)) + } else { + SamplePipeline::Process(Pipeline::new(config, sink, volume_getter)) + } + } + + pub fn get_latency_ms(&mut self) -> u32 { + use SamplePipeline::*; + + match self { + PassThrough(_) => 0, + Process(ref mut p) => p.get_latency_ms(), + } + } + + pub fn start(&mut self) -> SinkResult<()> { + use SamplePipeline::*; + + match self { + PassThrough(ref mut p) => p.start()?, + Process(ref mut p) => p.start()?, + } + + Ok(()) + } + + pub fn stop(&mut self) -> SinkResult<()> { + use SamplePipeline::*; + + match self { + PassThrough(ref mut p) => p.stop()?, + Process(ref mut p) => p.stop()?, + } + + Ok(()) + } + + pub fn update_normalisation_data( + &mut self, + auto_normalise_as_album: bool, + data: NormalisationData, + ) { + use SamplePipeline::*; + + match self { + PassThrough(_) => (), + Process(ref mut p) => p.update_normalisation_data(auto_normalise_as_album, data), + } + } + + pub fn write(&mut self, packet: AudioPacket) -> SinkResult<()> { + use SamplePipeline::*; + + match self { + PassThrough(ref mut p) => p.write(packet)?, + Process(ref mut p) => p.write(packet)?, + } + + Ok(()) + } +} + +pub struct Bypass { + converter: Converter, + sink: Box, +} + +impl Bypass { + fn new(config: &PlayerConfig, sink: Box) -> Self { + let converter = Converter::new(config.ditherer); + + Self { converter, sink } + } + + fn start(&mut self) -> SinkResult<()> { + self.sink.start()?; + + Ok(()) + } + + fn stop(&mut self) -> SinkResult<()> { + self.sink.stop()?; + + Ok(()) + } + + fn write(&mut self, packet: AudioPacket) -> SinkResult<()> { + self.sink.write(packet, &mut self.converter)?; + + Ok(()) + } +} + +pub struct Pipeline { resampler: StereoInterleavedResampler, normaliser: Normaliser, converter: Converter, sink: Box, } -impl SamplePipeline { - pub fn new( +impl Pipeline { + fn new( config: &PlayerConfig, sink: Box, volume_getter: Box, @@ -36,27 +141,34 @@ impl SamplePipeline { } } - pub fn get_latency_ms(&mut self) -> u32 { + fn get_latency_ms(&mut self) -> u32 { let total_latency_pcm = self.sink.get_latency_pcm() + self.resampler.get_latency_pcm(); (total_latency_pcm as f64 * MS_PER_PAGE) as u32 } - pub fn start(&mut self) -> SinkResult<()> { + fn start(&mut self) -> SinkResult<()> { self.sink.start()?; Ok(()) } - pub fn stop(&mut self) -> SinkResult<()> { + fn stop(&mut self) -> SinkResult<()> { + self.resampler + .drain() + .map(|processed_samples| self.normaliser.normalise(processed_samples)) + .map(|new_packet| self.sink.write(new_packet, &mut self.converter)) + .transpose()?; + self.resampler.stop(); self.normaliser.stop(); + self.sink.stop()?; Ok(()) } - pub fn update_normalisation_data( + fn update_normalisation_data( &mut self, auto_normalise_as_album: bool, data: NormalisationData, @@ -65,15 +177,13 @@ impl SamplePipeline { .update_normalisation_data(auto_normalise_as_album, data); } - pub fn write(&mut self, packet: AudioPacket) -> SinkResult<()> { + fn write(&mut self, packet: AudioPacket) -> SinkResult<()> { if let AudioPacket::Samples(samples) = packet { self.resampler .resample(samples) .map(|processed_samples| self.normaliser.normalise(processed_samples)) .map(|new_packet| self.sink.write(new_packet, &mut self.converter)) .transpose()?; - } else { - self.sink.write(packet, &mut self.converter)?; } Ok(())