diff --git a/src/media/audio/audio_core/mixer/test/audio_analysis.cc b/src/media/audio/audio_core/mixer/test/audio_analysis.cc index 45f480c1c9c7cf7920fd795b9cdd61aa505d439b..f61200e5354651f20fb5cdb5bcde79c6be1ab172 100644 --- a/src/media/audio/audio_core/mixer/test/audio_analysis.cc +++ b/src/media/audio/audio_core/mixer/test/audio_analysis.cc @@ -353,7 +353,12 @@ void MeasureAudioFreq(T* audio, uint32_t buf_size, uint32_t freq, // Calculate magnitude of primary signal (even if out-of-range aliased back!) if (freq_out_of_range) { - freq = buf_size - freq; + while (freq > buf_size) { + freq -= buf_size; + } + while (freq > buf_sz_2) { + freq = buf_size - freq; + } } *magn_signal = std::sqrt(reals[freq] * reals[freq] + imags[freq] * imags[freq]); diff --git a/src/media/audio/audio_core/mixer/test/audio_result.cc b/src/media/audio/audio_core/mixer/test/audio_result.cc index 6b6a1027487b69730072818b754318f00739ffce..04240ad6ff9ec0293bc7634a094e411b8a587c0e 100644 --- a/src/media/audio/audio_core/mixer/test/audio_result.cc +++ b/src/media/audio/audio_core/mixer/test/audio_result.cc @@ -81,6 +81,8 @@ std::array<double, FrequencySet::kNumReferenceFreqs> AudioResult::FreqRespPointUp1 = {NAN}; std::array<double, FrequencySet::kNumReferenceFreqs> AudioResult::FreqRespPointUp2 = {NAN}; +std::array<double, FrequencySet::kNumReferenceFreqs> + AudioResult::FreqRespPointUp3 = {NAN}; std::array<double, FrequencySet::kNumReferenceFreqs> AudioResult::FreqRespPointMicro = {NAN}; @@ -96,6 +98,8 @@ std::array<double, FrequencySet::kNumReferenceFreqs> AudioResult::FreqRespLinearUp1 = {NAN}; std::array<double, FrequencySet::kNumReferenceFreqs> AudioResult::FreqRespLinearUp2 = {NAN}; +std::array<double, FrequencySet::kNumReferenceFreqs> + AudioResult::FreqRespLinearUp3 = {NAN}; std::array<double, FrequencySet::kNumReferenceFreqs> AudioResult::FreqRespLinearMicro = {NAN}; @@ -130,14 +134,14 @@ const std::array<double, FrequencySet::kNumReferenceFreqs> const std::array<double, FrequencySet::kNumReferenceFreqs> AudioResult::kPrevFreqRespPointDown0 = { - 0.0000000e+00, -1.9772600e-09, -5.3325766e-10, -5.3325381e-10, -1.9772590e-09, -5.3325670e-10, - -5.3325188e-10, -5.3325574e-10, -5.3324995e-10, -5.3324802e-10, -5.3326249e-10, -5.3325477e-10, - -5.3324513e-10, -5.3045726e-10, -5.3318148e-10, -5.3318245e-10, -5.2755753e-10, -5.3029525e-10, - -5.3021232e-10, -5.2741866e-10, -5.3007731e-10, -5.2770507e-10, -5.2730198e-10, -5.2982369e-10, - -5.2357389e-10, -5.3061734e-10, -5.2437139e-10, -5.2554112e-10, -5.2557005e-10, -5.2816312e-10, - -5.2748809e-10, -5.2798954e-10, -4.9616384e-10, -5.0246283e-10, -5.2461536e-10, -5.0467693e-10, - -5.2828752e-10, -4.9564793e-10, -5.2133279e-10, 0.0000000e+00, -5.2786707e-10, -5.2110907e-10, - -4.8031994e-10, -4.4420202e-10, -4.8964788e-10, -4.9911276e-10, -4.8059960e-10 }; + 0.0000000e+00, 0.0000000e+00, -1.3126491e-07, 0.0000000e+00, -2.0876720e-07, -3.8765154e-07, + -6.3277078e-07, -8.7239859e-07, -1.4254718e-06, -2.3715742e-06, -4.0288977e-06, -5.7841053e-06, + -1.0358865e-05, -1.5023484e-05, -2.4492948e-05, -3.9024768e-05, -6.0366597e-05, -9.7631582e-05, + -1.5265413e-04, -2.4852011e-04, -3.8507092e-04, -6.0466871e-04, -9.9300886e-04, -1.5512596e-03, + -2.4256060e-03, -3.8511220e-03, -6.1972736e-03, -9.7008467e-03, -1.5404765e-02, -2.4804792e-02, + -3.8771409e-02, -5.5854122e-02, -9.9409879e-02, -1.4792272e-01, -1.5566146e-01, -1.6369384e-01, + -1.7185471e-01, -1.8944819e-01, -2.1463965e-01, -9.1209736e-01, -2.4295932e-01, -3.8786815e-01, + -6.2921487e-01, -7.6371200e-01, -7.6715614e-01, -8.9269835e-01, -9.1198639e-01 }; const std::array<double, FrequencySet::kNumReferenceFreqs> AudioResult::kPrevFreqRespPointDown1 = { @@ -183,6 +187,17 @@ const std::array<double, FrequencySet::kNumReferenceFreqs> -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY }; +const std::array<double, FrequencySet::kNumReferenceFreqs> + AudioResult::kPrevFreqRespPointUp3 = { + 0.0000000e+00, -2.8230396e-04, -2.8148971e-05, -3.8790435e-05, -3.2655760e-04, -8.9443851e-05, + -1.4946193e-04, -2.3885084e-04, -3.8442592e-04, -6.3216648e-04, -9.9867160e-04, -1.5197071e-03, + -2.5988524e-03, -3.9079472e-03, -6.1878777e-03, -9.8860927e-03, -1.5578368e-02, -2.4834878e-02, + -3.9296385e-02, -6.3424765e-02, -9.9074156e-02, -1.5486770e-01, -2.5506509e-01, -3.9996034e-01, + -6.2893611e-01, -1.0077116e+00, -1.6494604e+00, -2.6398568e+00, -INFINITY, -INFINITY, + -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, + -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, + -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY }; + const std::array<double, FrequencySet::kNumReferenceFreqs> AudioResult::kPrevFreqRespPointMicro = { 0.0000000e+00, 0.0000000e+00, 0.0000000e+00, 0.0000000e+00, 0.0000000e+00, 0.0000000e+00, @@ -207,14 +222,14 @@ const std::array<double, FrequencySet::kNumReferenceFreqs> const std::array<double, FrequencySet::kNumReferenceFreqs> AudioResult::kPrevFreqRespLinearDown0 = { - 0.0000000e+00, -1.9772600e-09, -5.3325766e-10, -5.3325381e-10, -1.9772590e-09, -5.3325670e-10, - -5.3325188e-10, -5.3325574e-10, -5.3324995e-10, -5.3324802e-10, -5.3326249e-10, -5.3325477e-10, - -5.3324513e-10, -5.3045726e-10, -5.3318148e-10, -5.3318245e-10, -5.2755753e-10, -5.3029525e-10, - -5.3021232e-10, -5.2741866e-10, -5.3007731e-10, -5.2770507e-10, -5.2730198e-10, -5.2982369e-10, - -5.2357389e-10, -5.3061734e-10, -5.2437139e-10, -5.2554112e-10, -5.2557005e-10, -5.2816312e-10, - -5.2748809e-10, -5.2798954e-10, -4.9616384e-10, -5.0246283e-10, -5.2461536e-10, -5.0467693e-10, - -5.2828752e-10, -4.9564793e-10, -5.2133279e-10, 0.0000000e+00, -5.2786707e-10, -5.2110907e-10, - -4.8031994e-10, -4.4420202e-10, -4.8964788e-10, -4.9911276e-10, -4.8059960e-10 }; + 0.0000000e+00, -1.3560410e-07, -2.2096572e-07, -3.0375984e-07, -4.8106798e-07, -7.0035404e-07, + -1.1697847e-06, -1.8670036e-06, -3.0073029e-06, -4.9423862e-06, -7.8059448e-06, -1.1877488e-05, + -2.0311420e-05, -3.0541582e-05, -4.8355041e-05, -7.7248342e-05, -1.2170773e-04, -1.9398439e-04, + -3.0684081e-04, -4.9496483e-04, -7.7253829e-04, -1.2060302e-03, -1.9817091e-03, -3.0970299e-03, + -4.8441738e-03, -7.6930799e-03, -1.2403072e-02, -1.9385618e-02, -3.0787663e-02, -4.9624471e-02, + -7.7560351e-02, -1.1172816e-01, -1.9882133e-01, -2.9574516e-01, -3.1119248e-01, -3.2699047e-01, + -3.4323223e-01, -3.7847585e-01, -4.2655399e-01, -4.4881934e-01, -4.8720667e-01, -7.7606042e-01, + -1.2584740e+00, -1.5274720e+00, -1.5345223e+00, -1.7856048e+00, -1.8241810e+00 }; const std::array<double, FrequencySet::kNumReferenceFreqs> AudioResult::kPrevFreqRespLinearDown1 = { @@ -260,6 +275,17 @@ const std::array<double, FrequencySet::kNumReferenceFreqs> -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY }; +const std::array<double, FrequencySet::kNumReferenceFreqs> + AudioResult::kPrevFreqRespLinearUp3 = { + 0.0000000e+00, -3.4481570e-05, -5.6307859e-05, -7.7595284e-05, -1.2303802e-04, -1.7892723e-04, + -2.9899015e-04, -4.7780857e-04, -7.6902606e-04, -1.2646195e-03, -1.9977967e-03, -3.0401078e-03, + -5.1988894e-03, -7.8176793e-03, -1.2378574e-02, -1.9776681e-02, -3.1163795e-02, -4.9680939e-02, + -7.8610299e-02, -1.2687738e-01, -1.9819079e-01, -3.0979930e-01, -5.1022835e-01, -8.0005931e-01, + -1.2580550e+00, -2.0156336e+00, -3.2990811e+00, -5.2796564e+00, -INFINITY, -INFINITY, + -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, + -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, + -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY }; + const std::array<double, FrequencySet::kNumReferenceFreqs> AudioResult::kPrevFreqRespLinearMicro = { 0.0000000e+00, -2.1585212e-06, -3.5194082e-06, -4.8526388e-06, -7.6796668e-06, -1.1183720e-05, @@ -284,6 +310,8 @@ std::array<double, FrequencySet::kNumReferenceFreqs> AudioResult::SinadPointUp1 = {NAN}; std::array<double, FrequencySet::kNumReferenceFreqs> AudioResult::SinadPointUp2 = {NAN}; +std::array<double, FrequencySet::kNumReferenceFreqs> + AudioResult::SinadPointUp3 = {NAN}; std::array<double, FrequencySet::kNumReferenceFreqs> AudioResult::SinadPointMicro = {NAN}; @@ -299,6 +327,8 @@ std::array<double, FrequencySet::kNumReferenceFreqs> AudioResult::SinadLinearUp1 = {NAN}; std::array<double, FrequencySet::kNumReferenceFreqs> AudioResult::SinadLinearUp2 = {NAN}; +std::array<double, FrequencySet::kNumReferenceFreqs> + AudioResult::SinadLinearUp3 = {NAN}; std::array<double, FrequencySet::kNumReferenceFreqs> AudioResult::SinadLinearMicro = {NAN}; @@ -322,7 +352,7 @@ std::array<double, FrequencySet::kNumReferenceFreqs> // clang-format off const std::array<double, FrequencySet::kNumReferenceFreqs> AudioResult::kPrevSinadPointUnity = { - 160.0, 153.71437, 153.74509, 153.74509, 153.71437, 153.74509, + 160.00000, 153.71437, 153.74509, 153.74509, 153.71437, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, @@ -333,29 +363,29 @@ const std::array<double, FrequencySet::kNumReferenceFreqs> const std::array<double, FrequencySet::kNumReferenceFreqs> AudioResult::kPrevSinadPointDown0 = { - 160.0, 153.71437, 153.74509, 153.74509, 153.71437, 153.74509, - 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, - 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, - 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, - 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, - 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, - 153.74509, 153.74509, 153.74509, 160.0, -0.00001, -0.00001, - 0.0, 0.0, 0.0, 0.0, 0.0 }; + 160.00000, 78.122180, 75.964356, 74.577171, 72.569334, 70.943237, + 68.713396, 66.677416, 64.610535, 62.450383, 60.464500, 58.641176, + 56.311061, 54.539519, 52.543811, 50.509344, 48.534933, 46.510440, + 44.518960, 42.442268, 40.508767, 38.574256, 36.417240, 34.477908, + 32.534728, 30.525208, 28.449757, 26.508483, 24.496655, 22.418787, + 20.472358, 18.878574, 16.353737, 14.604752, 14.379723, 14.160394, + 13.945699, 13.512413, 12.978650, 17.189886, -0.2435322, -0.3880030, + -0.6292312, -0.7637285, -0.7672283, -0.8927653, -0.9120527 }; const std::array<double, FrequencySet::kNumReferenceFreqs> AudioResult::kPrevSinadPointDown1 = { - 160.0, 153.71437, 153.74509, 153.74509, 153.71437, 153.74509, + 160.00000, 153.71437, 153.74509, 153.74509, 153.71437, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, - 153.74509, 153.74509, 153.74509, 160.0, -0.00001, -0.00001, + 153.74509, 153.74509, 153.74509, 160.00000, -0.00001, -0.00001, 0.0, 0.0, 0.0, 0.0, 0.0 }; const std::array<double, FrequencySet::kNumReferenceFreqs> AudioResult::kPrevSinadPointDown2 = { - 160.0, 71.336877, 69.207771, 67.815057, 65.812750, 64.186654, + 160.00000, 71.336877, 69.207771, 67.815057, 65.812750, 64.186654, 61.956811, 59.920832, 57.853947, 55.693796, 53.707909, 51.884581, 49.554461, 47.782913, 45.787171, 43.752690, 41.778220, 39.753644, 37.762035, 35.684914, 33.751618, 31.816288, 29.658355, 27.717787, @@ -366,7 +396,7 @@ const std::array<double, FrequencySet::kNumReferenceFreqs> const std::array<double, FrequencySet::kNumReferenceFreqs> AudioResult::kPrevSinadPointUp1 = { - 160.0, 65.316279, 63.187172, 61.794455, 59.792148, 58.166050, + 160.00000, 65.316279, 63.187172, 61.794455, 59.792148, 58.166050, 55.936206, 53.900223, 51.833335, 49.673175, 47.687276, 45.863930, 43.533774, 41.762183, 39.766365, 37.731761, 35.757101, 33.732217, 31.740126, 29.662201, 27.727717, 25.790544, 23.629300, 21.683967, @@ -377,18 +407,29 @@ const std::array<double, FrequencySet::kNumReferenceFreqs> const std::array<double, FrequencySet::kNumReferenceFreqs> AudioResult::kPrevSinadPointUp2 = { - 160.0, 61.281148, 59.152040, 57.759321, 55.757015, 54.130912, + 160.00000, 61.281148, 59.152040, 57.759321, 55.757015, 54.130912, 51.901065, 49.865075, 47.798174, 45.637992, 43.652064, 41.828677, 39.498430, 37.726726, 35.730739, 33.695819, 31.720708, 29.695082, 27.701826, 25.622181, 23.684311, 21.742982, 19.573739, 17.616782, 15.645886, 13.590901, 11.439506, 9.3839187, 7.1806586, 4.7728152, 2.3024022, 0.0024982, -INFINITY, -INFINITY, -INFINITY, -INFINITY, - -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, - -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY }; + -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, + -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY }; + +const std::array<double, FrequencySet::kNumReferenceFreqs> + AudioResult::kPrevSinadPointUp3 = { + 160.00000, 54.018289, 51.882570, 50.489845, 48.488997, 46.861413, + 44.631536, 42.595504, 40.528534, 38.368234, 36.382133, 34.558498, + 32.227739, 30.455414, 28.458345, 26.421669, 24.443854, 22.413830, + 20.413698, 18.322571, 16.367708, 14.399722, 12.182412, 10.155507, + 8.0730151, 5.8305794, 3.3535175, 0.7754679, -INFINITY, -INFINITY, + -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, + -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, + -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY }; const std::array<double, FrequencySet::kNumReferenceFreqs> AudioResult::kPrevSinadPointMicro = { - 160.0, 66.059499, 63.927625, 62.533706, 60.530232, 58.903508, + 160.00000, 66.059499, 63.927625, 62.533706, 60.530232, 58.903508, 56.673112, 54.636824, 52.569740, 50.409454, 48.423487, 46.600103, 44.269918, 42.498312, 40.502514, 38.467909, 36.493292, 34.468473, 32.476480, 30.398944, 28.464189, 26.527730, 24.367222, 22.422864, @@ -399,40 +440,40 @@ const std::array<double, FrequencySet::kNumReferenceFreqs> const std::array<double, FrequencySet::kNumReferenceFreqs> AudioResult::kPrevSinadLinearUnity = { - 160.0, 153.71437, 153.74509, 153.74509, 153.71437, 153.74509, + 160.00000, 153.71437, 153.74509, 153.74509, 153.71437, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, - 153.74509, 153.74509, 153.74509, 160.0, -INFINITY, -INFINITY, + 153.74509, 153.74509, 153.74509, 160.00000, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY }; const std::array<double, FrequencySet::kNumReferenceFreqs> AudioResult::kPrevSinadLinearDown0 = { - 160.0, 153.71437, 153.74509, 153.74509, 153.71437, 153.74509, - 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, - 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, - 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, - 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, - 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, - 153.74509, 153.74509, 153.74509, 160.0, -0.00001, -0.00001, - 0.0, 0.0, 0.0, 0.0, 0.0 }; + 160.00000, 150.11065, 149.19638, 148.35386, 146.70743, 144.98731, + 141.99425, 138.82310, 135.28481, 131.32290, 127.56169, 124.04061, + 119.47631, 115.97708, 112.01967, 107.97252, 104.03676, 99.996038, + 96.018321, 91.868146, 88.003019, 84.134935, 79.821129, 75.942074, + 72.054585, 68.033407, 63.878712, 59.990525, 55.957535, 51.786276, + 47.870582, 44.655243, 39.535613, 35.961366, 35.499314, 35.048955, + 34.607125, 33.713178, 32.613373, 29.374669, -0.0031581, -0.008696118, + -0.026062825, -0.041175638, -0.0416317, -0.0600556, -0.0632814 }; const std::array<double, FrequencySet::kNumReferenceFreqs> AudioResult::kPrevSinadLinearDown1 = { - 160.0, 153.71437, 153.74509, 153.74509, 153.71437, 153.74509, - 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, - 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, - 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, - 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, - 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, - 153.74509, 153.74509, 153.74509, 160.0, -0.00001, -0.00001, - 0.0, 0.0, 0.0, 0.0, 0.0 }; + 160.00000, 153.71437, 153.74509, 153.74509, 153.71437, 153.74509, + 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, + 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, + 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, + 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, + 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, 153.74509, + 153.74509, 153.74509, 153.74509, 160.00000, -0.00001, -0.00001, + 0.0, 0.0, 0.0, 0.0, 0.0 }; const std::array<double, FrequencySet::kNumReferenceFreqs> AudioResult::kPrevSinadLinearDown2 = { - 160.0, 145.49338, 142.76626, 140.72251, 137.37211, 134.53647, + 160.00000, 145.49338, 142.76626, 140.72251, 137.37211, 134.53647, 130.42254, 126.53508, 122.51076, 118.26515, 114.33387, 110.71175, 106.07058, 102.53716, 98.552405, 94.487585, 90.541183, 86.493364, 82.510726, 78.356875, 74.488568, 70.617160, 66.298521, 62.413089, @@ -443,36 +484,47 @@ const std::array<double, FrequencySet::kNumReferenceFreqs> const std::array<double, FrequencySet::kNumReferenceFreqs> AudioResult::kPrevSinadLinearUp1 = { - 160.0, 136.51568, 132.67958, 130.09359, 126.26617, 123.11086, + 160.00000, 136.51568, 132.67958, 130.09359, 126.26617, 123.11086, 118.73707, 114.71235, 110.60724, 106.30681, 102.34528, 98.704938, 94.049636, 90.508733, 86.518686, 82.450120, 78.500792, 74.450330, 70.464653, 66.306477, 62.432229, 58.551831, 54.217369, 50.309328, 46.377035, 42.283366, 38.009784, 33.947118, 29.633297, 25.007929, 20.438188, 16.448403, 9.4409550, 3.8414434, 3.0592776, 2.2816549, 1.5032161, -0.1228125, -INFINITY, -INFINITY, -INFINITY, -INFINITY, - -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY }; + -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY }; const std::array<double, FrequencySet::kNumReferenceFreqs> AudioResult::kPrevSinadLinearUp2 = { - 160.0, 122.55223, 118.30004, 115.51772, 111.51357, 108.26232, + 160.00000, 122.55222, 118.30004, 115.51772, 111.51357, 108.26232, 103.80239, 99.730105, 95.596368, 91.276051, 87.304125, 83.657303, 78.996866, 75.453467, 71.461492, 67.391637, 63.441417, 59.390164, 55.403653, 51.244363, 47.368622, 43.485964, 39.147478, 35.233563, - 31.291773, 27.181802, 22.879012, 18.767837, 14.361317, 9.5456304, + 31.291773, 27.181802, 22.879012, 18.767836, 14.361317, 9.5456304, 4.6048044, 0.0049964955, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY }; +const std::array<double, FrequencySet::kNumReferenceFreqs> + AudioResult::kPrevSinadLinearUp3 = { + 160.00000, 113.01860, 108.76100, 105.97600, 101.97155, 98.719172, + 94.259468, 90.187341, 86.053267, 81.732501, 77.760038, 74.112390, + 69.450098, 65.904512, 61.908740, 57.832737, 53.873032, 49.806370, + 45.795801, 41.596427, 37.661582, 33.686708, 29.183457, 25.033104, + 20.721753, 16.010185, 10.710873, 5.1025001, -INFINITY, -INFINITY, + -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, + -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, + -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY }; + const std::array<double, FrequencySet::kNumReferenceFreqs> AudioResult::kPrevSinadLinearMicro = { - 160.0, 137.77543, 134.01803, 131.46589, 127.68128, 124.54800, + 160.00000, 137.77543, 134.01803, 131.46589, 127.68128, 124.54800, 120.18252, 116.16993, 112.07004, 107.77290, 103.81385, 100.17442, 95.520355, 91.979876, 87.990125, 83.921932, 79.972951, 75.922907, 71.937750, 67.780410, 63.907352, 60.028788, 55.697592, 51.794229, 47.869227, 43.787357, 39.533082, 35.498577, 31.229654, 26.675984, 22.207908, 18.336999, 11.618540, 6.3382417, 5.6081329, 4.8842446, 4.1617533, 2.6594494, 0.72947217, -INFINITY, -INFINITY, -INFINITY, - -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, }; + -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY, }; // clang-format on // @@ -580,43 +632,9 @@ constexpr double AudioResult::kPrevFloorOutputFloat; // They display the current run's results in an easily-imported format. // void AudioResult::DumpThresholdValues() { - DumpFreqRespValues(AudioResult::FreqRespPointUnity.data(), "FR-PointUnity"); - DumpFreqRespValues(AudioResult::FreqRespPointDown0.data(), "FR-PointDown0"); - DumpFreqRespValues(AudioResult::FreqRespPointDown1.data(), "FR-PointDown1"); - DumpFreqRespValues(AudioResult::FreqRespPointDown2.data(), "FR-PointDown2"); - DumpFreqRespValues(AudioResult::FreqRespPointUp1.data(), "FR-PointUp1"); - DumpFreqRespValues(AudioResult::FreqRespPointUp2.data(), "FR-PointUp2"); - DumpFreqRespValues(AudioResult::FreqRespPointMicro.data(), "FR-PointMicro"); - - DumpFreqRespValues(AudioResult::FreqRespLinearUnity.data(), "FR-LinearUnity"); - DumpFreqRespValues(AudioResult::FreqRespLinearDown0.data(), "FR-LinearDown0"); - DumpFreqRespValues(AudioResult::FreqRespLinearDown1.data(), "FR-LinearDown1"); - DumpFreqRespValues(AudioResult::FreqRespLinearDown2.data(), "FR-LinearDown2"); - DumpFreqRespValues(AudioResult::FreqRespLinearUp1.data(), "FR-LinearUp1"); - DumpFreqRespValues(AudioResult::FreqRespLinearUp2.data(), "FR-LinearUp2"); - DumpFreqRespValues(AudioResult::FreqRespLinearMicro.data(), "FR-LinearMicro"); - - DumpFreqRespValues(AudioResult::FreqRespPointNxN.data(), "FR-PointNxN"); - DumpFreqRespValues(AudioResult::FreqRespLinearNxN.data(), "FR-LinearNxN"); - - DumpSinadValues(AudioResult::SinadPointUnity.data(), "SinadPointUnity"); - DumpSinadValues(AudioResult::SinadPointDown0.data(), "SinadPointDown0"); - DumpSinadValues(AudioResult::SinadPointDown1.data(), "SinadPointDown1"); - DumpSinadValues(AudioResult::SinadPointDown2.data(), "SinadPointDown2"); - DumpSinadValues(AudioResult::SinadPointUp1.data(), "SinadPointUp1"); - DumpSinadValues(AudioResult::SinadPointUp2.data(), "SinadPointUp2"); - DumpSinadValues(AudioResult::SinadPointMicro.data(), "SinadPointMicro"); - - DumpSinadValues(AudioResult::SinadLinearUnity.data(), "SinadLinearUnity"); - DumpSinadValues(AudioResult::SinadLinearDown0.data(), "SinadLinearDown0"); - DumpSinadValues(AudioResult::SinadLinearDown1.data(), "SinadLinearDown1"); - DumpSinadValues(AudioResult::SinadLinearDown2.data(), "SinadLinearDown2"); - DumpSinadValues(AudioResult::SinadLinearUp1.data(), "SinadLinearUp1"); - DumpSinadValues(AudioResult::SinadLinearUp2.data(), "SinadLinearUp2"); - DumpSinadValues(AudioResult::SinadLinearMicro.data(), "SinadLinearMicro"); - - DumpSinadValues(AudioResult::SinadPointNxN.data(), "SinadPointNxN"); - DumpSinadValues(AudioResult::SinadLinearNxN.data(), "SinadLinearNxN"); + DumpFreqRespValues(); + + DumpSinadValues(); DumpLevelValues(); DumpLevelToleranceValues(); @@ -626,32 +644,93 @@ void AudioResult::DumpThresholdValues() { printf("\n\n"); } +void AudioResult::DumpFreqRespValues() { + printf("\n\n Frequency Response"); + printf("\n (all results given in dB)"); + + DumpFreqRespValueSet(AudioResult::FreqRespPointUnity.data(), "FR-PointUnity"); + DumpFreqRespValueSet(AudioResult::FreqRespPointDown0.data(), "FR-PointDown0"); + DumpFreqRespValueSet(AudioResult::FreqRespPointDown1.data(), "FR-PointDown1"); + DumpFreqRespValueSet(AudioResult::FreqRespPointDown2.data(), "FR-PointDown2"); + DumpFreqRespValueSet(AudioResult::FreqRespPointUp1.data(), "FR-PointUp1"); + DumpFreqRespValueSet(AudioResult::FreqRespPointUp2.data(), "FR-PointUp2"); + DumpFreqRespValueSet(AudioResult::FreqRespPointUp3.data(), "FR-PointUp3"); + DumpFreqRespValueSet(AudioResult::FreqRespPointMicro.data(), "FR-PointMicro"); + + DumpFreqRespValueSet(AudioResult::FreqRespLinearUnity.data(), + "FR-LinearUnity"); + DumpFreqRespValueSet(AudioResult::FreqRespLinearDown0.data(), + "FR-LinearDown0"); + DumpFreqRespValueSet(AudioResult::FreqRespLinearDown1.data(), + "FR-LinearDown1"); + DumpFreqRespValueSet(AudioResult::FreqRespLinearDown2.data(), + "FR-LinearDown2"); + DumpFreqRespValueSet(AudioResult::FreqRespLinearUp1.data(), "FR-LinearUp1"); + DumpFreqRespValueSet(AudioResult::FreqRespLinearUp2.data(), "FR-LinearUp2"); + DumpFreqRespValueSet(AudioResult::FreqRespLinearUp3.data(), "FR-LinearUp3"); + DumpFreqRespValueSet(AudioResult::FreqRespLinearMicro.data(), + "FR-LinearMicro"); + + DumpFreqRespValueSet(AudioResult::FreqRespPointNxN.data(), "FR-PointNxN"); + DumpFreqRespValueSet(AudioResult::FreqRespLinearNxN.data(), "FR-LinearNxN"); +} + +void AudioResult::DumpSinadValues() { + printf("\n\n Signal-to-Noise+Distortion"); + printf("\n (all results given in dB)"); + + DumpSinadValueSet(AudioResult::SinadPointUnity.data(), "SinadPointUnity"); + DumpSinadValueSet(AudioResult::SinadPointDown0.data(), "SinadPointDown0"); + DumpSinadValueSet(AudioResult::SinadPointDown1.data(), "SinadPointDown1"); + DumpSinadValueSet(AudioResult::SinadPointDown2.data(), "SinadPointDown2"); + DumpSinadValueSet(AudioResult::SinadPointUp1.data(), "SinadPointUp1"); + DumpSinadValueSet(AudioResult::SinadPointUp2.data(), "SinadPointUp2"); + DumpSinadValueSet(AudioResult::SinadPointUp3.data(), "SinadPointUp3"); + DumpSinadValueSet(AudioResult::SinadPointMicro.data(), "SinadPointMicro"); + + DumpSinadValueSet(AudioResult::SinadLinearUnity.data(), "SinadLinearUnity"); + DumpSinadValueSet(AudioResult::SinadLinearDown0.data(), "SinadLinearDown0"); + DumpSinadValueSet(AudioResult::SinadLinearDown1.data(), "SinadLinearDown1"); + DumpSinadValueSet(AudioResult::SinadLinearDown2.data(), "SinadLinearDown2"); + DumpSinadValueSet(AudioResult::SinadLinearUp1.data(), "SinadLinearUp1"); + DumpSinadValueSet(AudioResult::SinadLinearUp2.data(), "SinadLinearUp2"); + DumpSinadValueSet(AudioResult::SinadLinearUp3.data(), "SinadLinearUp3"); + DumpSinadValueSet(AudioResult::SinadLinearMicro.data(), "SinadLinearMicro"); + + DumpSinadValueSet(AudioResult::SinadPointNxN.data(), "SinadPointNxN"); + DumpSinadValueSet(AudioResult::SinadLinearNxN.data(), "SinadLinearNxN"); +} + // Display a single frequency response results array, for import and processing. -void AudioResult::DumpFreqRespValues(double* freq_resp_vals, - const std::string& arr_name) { - printf("\n\n %s", arr_name.c_str()); +void AudioResult::DumpFreqRespValueSet(double* freq_resp_vals, + const std::string& arr_name) { + printf("\n %s", arr_name.c_str()); for (size_t freq = 0; freq < FrequencySet::kReferenceFreqs.size(); ++freq) { if (freq % 6 == 0) { - printf("\n\t\t"); + printf("\n "); } - printf(" %14.7le,", freq_resp_vals[freq]); + printf(" %14.7le,", freq_resp_vals[freq]); } + printf("\n"); } // Display a single sinad results array, for import and processing. -void AudioResult::DumpSinadValues(double* sinad_vals, - const std::string& arr_name) { - printf("\n\n %s", arr_name.c_str()); +void AudioResult::DumpSinadValueSet(double* sinad_vals, + const std::string& arr_name) { + printf("\n %s", arr_name.c_str()); for (size_t freq = 0; freq < FrequencySet::kReferenceFreqs.size(); ++freq) { if (freq % 6 == 0) { - printf("\n\t\t"); + printf("\n "); } - printf(" %11.7lf,", sinad_vals[freq]); + printf(" %11.7lf,", ((isinf(sinad_vals[freq]) && sinad_vals[freq] > 0.0) + ? 160.0 + : sinad_vals[freq])); } + printf("\n"); } void AudioResult::DumpLevelValues() { - printf("\n\n Level"); + printf("\n\n Level (in dB)"); printf("\n 8-bit: Source %15.8le Mix %15.8le Output %15.8le", AudioResult::LevelSource8, AudioResult::LevelMix8, AudioResult::LevelOutput8); @@ -668,10 +747,12 @@ void AudioResult::DumpLevelValues() { AudioResult::LevelSourceFloat, AudioResult::LevelMixFloat, AudioResult::LevelOutputFloat); printf("\n Stereo-to-Mono: %15.8le", AudioResult::LevelStereoMono); + + printf("\n"); } void AudioResult::DumpLevelToleranceValues() { - printf("\n\n Level Tolerance"); + printf("\n\n Level Tolerance (in dB)"); printf("\n 8-bit: Source %15.8le Mix %15.8le Output %15.8le", AudioResult::LevelToleranceSource8, AudioResult::LevelToleranceMix8, AudioResult::LevelToleranceOutput8); @@ -692,10 +773,12 @@ void AudioResult::DumpLevelToleranceValues() { printf("\n Stereo-to-Mono: %15.8le ", AudioResult::LevelToleranceStereoMono); printf("Interpolation: %15.8le", LevelToleranceInterpolation); + + printf("\n"); } void AudioResult::DumpNoiseFloorValues() { - printf("\n\n Noise Floor"); + printf("\n\n Noise Floor (in dB)"); printf("\n 8-bit: Source %11.7lf Mix %11.7lf Output %11.7lf", AudioResult::FloorSource8, AudioResult::FloorMix8, AudioResult::FloorOutput8); @@ -709,32 +792,36 @@ void AudioResult::DumpNoiseFloorValues() { AudioResult::FloorSourceFloat, AudioResult::FloorMixFloat, AudioResult::FloorOutputFloat); printf("\n Stereo-to-Mono: %11.7lf", AudioResult::FloorStereoMono); + + printf("\n"); } void AudioResult::DumpDynamicRangeValues() { printf("\n\n Dynamic Range"); - printf("\n Epsilon: %10.8f (%13.6le dB)", AudioResult::ScaleEpsilon, - Gain::ScaleToDb(AudioResult::ScaleEpsilon)); - printf(" Level: %12.8lf dB Sinad: %10.6lf dB", + printf("\n Epsilon: %10.7e (%13.6le dB)", AudioResult::ScaleEpsilon, + Gain::ScaleToDb(1.0 - AudioResult::ScaleEpsilon)); + printf(" Level: %15.8le dB Sinad: %10.6lf dB", AudioResult::LevelEpsilonDown, AudioResult::SinadEpsilonDown); - printf("\n -30 dB down: "); - printf(" Level: %12.8lf dB Sinad: %10.6lf dB", AudioResult::Level30Down, + printf("\n -30 dB down: "); + printf(" Level: %15.8lf dB Sinad: %10.6lf dB", AudioResult::Level30Down, AudioResult::Sinad30Down); - printf("\n -60 dB down: "); - printf(" Level: %12.8lf dB Sinad: %10.6lf dB", AudioResult::Level60Down, + printf("\n -60 dB down: "); + printf(" Level: %15.8lf dB Sinad: %10.6lf dB", AudioResult::Level60Down, AudioResult::Sinad60Down); - printf("\n -90 dB down: "); - printf(" Level: %12.8lf dB Sinad: %10.6lf dB", AudioResult::Level90Down, + printf("\n -90 dB down: "); + printf(" Level: %15.8lf dB Sinad: %10.6lf dB", AudioResult::Level90Down, AudioResult::Sinad90Down); - printf("\n Gain Accuracy: +/- %12.6le dB", + printf("\n Gain Accuracy: +/- %12.7le dB", AudioResult::DynRangeTolerance); printf("\n MinScale: %10.8f (%11.8f dB)", AudioResult::MinScaleNonZero, Gain::ScaleToDb(AudioResult::MinScaleNonZero)); + + printf("\n"); } } // namespace media::audio::test diff --git a/src/media/audio/audio_core/mixer/test/audio_result.h b/src/media/audio/audio_core/mixer/test/audio_result.h index da0a31dcda946efffe45d2996effc1f48ced95c9..9f2ead30736a6cb4351df600981512b314518adc 100644 --- a/src/media/audio/audio_core/mixer/test/audio_result.h +++ b/src/media/audio/audio_core/mixer/test/audio_result.h @@ -64,9 +64,9 @@ class AudioResult { // Related to the above, these constants store the previous measurements. // These are used as threshold limits -- if any current test EXCEEDS this // tolerance, it is considered an error and causes the test case to fail. - static constexpr double kPrevLevelToleranceSource8 = 6.7219077e-02; - static constexpr double kPrevLevelToleranceSource16 = 1.0548786e-06; - static constexpr double kPrevLevelToleranceSource24 = 3.0346074e-09; + static constexpr double kPrevLevelToleranceSource8 = 6.4082082e-04; + static constexpr double kPrevLevelToleranceSource16 = 6.8541681e-07; + static constexpr double kPrevLevelToleranceSource24 = 2.3196300e-09; static constexpr double kPrevLevelToleranceSourceFloat = 5.3282082e-10; // These variables store the specific result magnitude (in dBFS) for the input @@ -103,7 +103,7 @@ class AudioResult { // measurement LESS than this threshold limit is considered a test failure. static constexpr double kPrevFloorSource8 = 49.952957; static constexpr double kPrevFloorSource16 = 98.104753; - static constexpr double kPrevFloorSource24 = 146.30926; + static constexpr double kPrevFloorSource24 = 153.71926; static constexpr double kPrevFloorSourceFloat = 153.74509; // @@ -118,7 +118,7 @@ class AudioResult { static double LevelToleranceStereoMono; // Previously-cached tolerance. If difference between input magnitude and // result magnitude EXCEEDS this tolerance, then the test case fails. - static constexpr double kPrevLevelToleranceStereoMono = 2.9724227e-05; + static constexpr double kPrevLevelToleranceStereoMono = 6.0681545e-09; // Absolute output level measured in this test case. static double LevelStereoMono; @@ -130,7 +130,7 @@ class AudioResult { static double FloorStereoMono; // Previously-cached noise floor that serves as a threshold limit. If result // magnitude is LESS than this value, then the test case fails. - static constexpr double kPrevFloorStereoMono = 93.607405; + static constexpr double kPrevFloorStereoMono = 152.09879; // // @@ -184,10 +184,11 @@ class AudioResult { FreqRespPointDown2; static std::array<double, FrequencySet::kNumReferenceFreqs> FreqRespPointUp1; static std::array<double, FrequencySet::kNumReferenceFreqs> FreqRespPointUp2; + static std::array<double, FrequencySet::kNumReferenceFreqs> FreqRespPointUp3; static std::array<double, FrequencySet::kNumReferenceFreqs> FreqRespPointMicro; - // Same as the above section, but for LinearSampler instead of PointSampler + // Same as the above section, but for LinearSampler static std::array<double, FrequencySet::kNumReferenceFreqs> FreqRespLinearUnity; static std::array<double, FrequencySet::kNumReferenceFreqs> @@ -198,6 +199,7 @@ class AudioResult { FreqRespLinearDown2; static std::array<double, FrequencySet::kNumReferenceFreqs> FreqRespLinearUp1; static std::array<double, FrequencySet::kNumReferenceFreqs> FreqRespLinearUp2; + static std::array<double, FrequencySet::kNumReferenceFreqs> FreqRespLinearUp3; static std::array<double, FrequencySet::kNumReferenceFreqs> FreqRespLinearMicro; @@ -225,10 +227,12 @@ class AudioResult { kPrevFreqRespPointUp1; static const std::array<double, FrequencySet::kNumReferenceFreqs> kPrevFreqRespPointUp2; + static const std::array<double, FrequencySet::kNumReferenceFreqs> + kPrevFreqRespPointUp3; static const std::array<double, FrequencySet::kNumReferenceFreqs> kPrevFreqRespPointMicro; - // Same as the above section, but for LinearSampler instead of PointSampler + // Same as the above section, but for LinearSampler static const std::array<double, FrequencySet::kNumReferenceFreqs> kPrevFreqRespLinearUnity; static const std::array<double, FrequencySet::kNumReferenceFreqs> @@ -241,6 +245,8 @@ class AudioResult { kPrevFreqRespLinearUp1; static const std::array<double, FrequencySet::kNumReferenceFreqs> kPrevFreqRespLinearUp2; + static const std::array<double, FrequencySet::kNumReferenceFreqs> + kPrevFreqRespLinearUp3; static const std::array<double, FrequencySet::kNumReferenceFreqs> kPrevFreqRespLinearMicro; @@ -268,20 +274,21 @@ class AudioResult { static std::array<double, FrequencySet::kNumReferenceFreqs> SinadPointDown2; static std::array<double, FrequencySet::kNumReferenceFreqs> SinadPointUp1; static std::array<double, FrequencySet::kNumReferenceFreqs> SinadPointUp2; + static std::array<double, FrequencySet::kNumReferenceFreqs> SinadPointUp3; static std::array<double, FrequencySet::kNumReferenceFreqs> SinadPointMicro; - // Same as the above section, but for LinearSampler instead of PointSampler + // Same as the above section, but for LinearSampler static std::array<double, FrequencySet::kNumReferenceFreqs> SinadLinearUnity; static std::array<double, FrequencySet::kNumReferenceFreqs> SinadLinearDown0; static std::array<double, FrequencySet::kNumReferenceFreqs> SinadLinearDown1; static std::array<double, FrequencySet::kNumReferenceFreqs> SinadLinearDown2; static std::array<double, FrequencySet::kNumReferenceFreqs> SinadLinearUp1; static std::array<double, FrequencySet::kNumReferenceFreqs> SinadLinearUp2; + static std::array<double, FrequencySet::kNumReferenceFreqs> SinadLinearUp3; static std::array<double, FrequencySet::kNumReferenceFreqs> SinadLinearMicro; - // These are the previous-cached results for SINAD, for this sampler and this - // rate conversion, represented in dBr. If any current result magnitude is - // LESS than this value, then the test case fails. + // Previous-cached SINAD results for this sampler and rate conversion ratio, + // in dBr. If current result is LESS than this value, the test case fails. static const std::array<double, FrequencySet::kNumReferenceFreqs> kPrevSinadPointUnity; static const std::array<double, FrequencySet::kNumReferenceFreqs> @@ -294,10 +301,12 @@ class AudioResult { kPrevSinadPointUp1; static const std::array<double, FrequencySet::kNumReferenceFreqs> kPrevSinadPointUp2; + static const std::array<double, FrequencySet::kNumReferenceFreqs> + kPrevSinadPointUp3; static const std::array<double, FrequencySet::kNumReferenceFreqs> kPrevSinadPointMicro; - // Same as the above section, but for LinearSampler instead of PointSampler + // Same as the above section, but for LinearSampler static const std::array<double, FrequencySet::kNumReferenceFreqs> kPrevSinadLinearUnity; static const std::array<double, FrequencySet::kNumReferenceFreqs> @@ -310,6 +319,8 @@ class AudioResult { kPrevSinadLinearUp1; static const std::array<double, FrequencySet::kNumReferenceFreqs> kPrevSinadLinearUp2; + static const std::array<double, FrequencySet::kNumReferenceFreqs> + kPrevSinadLinearUp3; static const std::array<double, FrequencySet::kNumReferenceFreqs> kPrevSinadLinearMicro; @@ -394,17 +405,17 @@ class AudioResult { static double DynRangeTolerance; // The previous-cached worst-case tolerance value, for Dynamic range testing. // If a current tolerance EXCEEDS this value, then the test case fails. - static constexpr double kPrevDynRangeTolerance = 7.5380325e-03; + static constexpr double kPrevDynRangeTolerance = 4.6729294e-07; // Level and unwanted artifacts, applying the smallest-detectable gain change. static double LevelEpsilonDown; // If current value is LESS than this value, then the test case fails. - static constexpr double kPrevLevelEpsilonDown = -1.6807164e-04; + static constexpr double kPrevLevelEpsilonDown = -2.5886558e-07; // Previously-cached sinad when applying the smallest-detectable gain change. static double SinadEpsilonDown; // If current value is LESS than this value, then the test case fails. - static constexpr double kPrevSinadEpsilonDown = 91.3090642; + static constexpr double kPrevSinadEpsilonDown = 152.25480; // Level and unwanted artifacts -- as well as previously-cached threshold // limits for the same -- when applying -30dB gain (measures dynamic range). @@ -417,17 +428,17 @@ class AudioResult { // Current measured SINAD at -30 gain. static double Sinad30Down; // If current value is LESS than this value, then the test case fails. - static constexpr double kPrevSinad30Down = 64.091308; + static constexpr double kPrevSinad30Down = 149.95967; // Current measured SINAD at -60 gain. static double Sinad60Down; // If current value is LESS than this value, then the test case fails. - static constexpr double kPrevSinad60Down = 34.196326; + static constexpr double kPrevSinad60Down = 149.69530; // Current measured SINAD at -90 gain. static double Sinad90Down; // If current value is LESS than this value, then the test case fails. - static constexpr double kPrevSinad90Down = 2.8879823; + static constexpr double kPrevSinad90Down = 149.58577; // // @@ -444,9 +455,9 @@ class AudioResult { static double LevelToleranceMixFloat; // If current tolerance EXCEEDS this value, then the test case fails. - static constexpr double kPrevLevelToleranceMix8 = 6.7219077e-02; - static constexpr double kPrevLevelToleranceMix16 = 1.7031199e-04; - static constexpr double kPrevLevelToleranceMix24 = 3.0346074e-09; + static constexpr double kPrevLevelToleranceMix8 = 6.40820813e-04; + static constexpr double kPrevLevelToleranceMix16 = 6.85416802e-07; + static constexpr double kPrevLevelToleranceMix24 = 2.3196300e-09; static constexpr double kPrevLevelToleranceMixFloat = 5.3282082e-10; // Absolute output level (dBFS) measured in Mix tests for this input type. @@ -469,8 +480,8 @@ class AudioResult { // If current value is LESS than this value, then the test case fails. static constexpr double kPrevFloorMix8 = 49.952317; - static constexpr double kPrevFloorMix16 = 90.677331; - static constexpr double kPrevFloorMix24 = 146.30926; + static constexpr double kPrevFloorMix16 = 98.104753; + static constexpr double kPrevFloorMix24 = 153.71927; static constexpr double kPrevFloorMixFloat = 153.74509; // @@ -489,10 +500,10 @@ class AudioResult { static double LevelToleranceOutputFloat; // If current tolerance EXCEEDS this value, then the test case fails. - static constexpr double kPrevLevelToleranceOutput8 = 6.5638245e-02; - static constexpr double kPrevLevelToleranceOutput16 = 6.7860087e-02; - static constexpr double kPrevLevelToleranceOutput24 = 3.0250373e-07; - static constexpr double kPrevLevelToleranceOutputFloat = 6.8541681e-07; + static constexpr double kPrevLevelToleranceOutput8 = 6.4082082e-04; + static constexpr double kPrevLevelToleranceOutput16 = 9.9668031e-07; + static constexpr double kPrevLevelToleranceOutput24 = 2.5596549e-09; + static constexpr double kPrevLevelToleranceOutputFloat = 5.3282082e-10; // Absolute output level (dBFS) measured in Output tests for this type. static double LevelOutput8; @@ -517,9 +528,9 @@ class AudioResult { static double FloorOutputFloat; // If current value is LESS than this value, then the test case fails. - static constexpr double kPrevFloorOutput8 = 45.920261; - static constexpr double kPrevFloorOutput16 = 97.944722; - static constexpr double kPrevFloorOutput24 = 146.22129; + static constexpr double kPrevFloorOutput8 = 49.952957; + static constexpr double kPrevFloorOutput16 = 98.104911; + static constexpr double kPrevFloorOutput24 = 153.72051; static constexpr double kPrevFloorOutputFloat = 153.74509; // class is static only - prevent attempts to instantiate it @@ -533,13 +544,17 @@ class AudioResult { static void DumpThresholdValues(); private: - static void DumpFreqRespValues(double* freq_resp_vals, - const std::string& arr_name); - static void DumpSinadValues(double* sinad_vals, const std::string& arr_name); + static void DumpFreqRespValues(); + static void DumpSinadValues(); static void DumpNoiseFloorValues(); static void DumpLevelValues(); static void DumpLevelToleranceValues(); static void DumpDynamicRangeValues(); + + static void DumpFreqRespValueSet(double* freq_resp_vals, + const std::string& arr_name); + static void DumpSinadValueSet(double* sinad_vals, + const std::string& arr_name); }; } // namespace media::audio::test diff --git a/src/media/audio/audio_core/mixer/test/mixer_range_tests.cc b/src/media/audio/audio_core/mixer/test/mixer_range_tests.cc index a07d19c86f409c393f126256794b632ebee49a4f..f8c75987d107167d7cf3755daa5a88fbb5923cbc 100644 --- a/src/media/audio/audio_core/mixer/test/mixer_range_tests.cc +++ b/src/media/audio/audio_core/mixer/test/mixer_range_tests.cc @@ -51,8 +51,7 @@ void MeasureSummaryDynamicRange(float gain_db, double* level_db, // increment possible, as well as the smallest increment detectable (the // closest-to-1.0 gain that actually causes incoming data values to change). TEST(DynamicRange, Epsilon) { - double unity_level_db, unity_sinad_db, level_db, sinad_db; - + double unity_level_db, unity_sinad_db; MeasureSummaryDynamicRange(0.0f, &unity_level_db, &unity_sinad_db); EXPECT_NEAR(unity_level_db, 0.0, AudioResult::kPrevLevelToleranceSourceFloat); EXPECT_GE(unity_sinad_db, AudioResult::kPrevFloorSourceFloat); @@ -62,10 +61,11 @@ TEST(DynamicRange, Epsilon) { // kMinGainDbUnity is the lowest (furthest-from-Unity) with no observable // attenuation on float32 (i.e. the smallest indistinguishable from Unity). // Just above the 'first detectable reduction' scale; should be same as unity. - MeasureSummaryDynamicRange(AudioResult::kMinGainDbUnity, &level_db, - &sinad_db); - EXPECT_EQ(level_db, unity_level_db); - EXPECT_EQ(sinad_db, unity_sinad_db); + double near_unity_level_db, near_unity_sinad_db; + MeasureSummaryDynamicRange(AudioResult::kMinGainDbUnity, &near_unity_level_db, + &near_unity_sinad_db); + EXPECT_EQ(near_unity_level_db, unity_level_db); + EXPECT_EQ(near_unity_sinad_db, unity_sinad_db); // kMaxGainDbNonUnity is the highest (closest-to-Unity) with observable effect // on full-scale (i.e. largest sub-Unity AScale distinguishable from Unity). @@ -81,6 +81,13 @@ TEST(DynamicRange, Epsilon) { EXPECT_LT(AudioResult::LevelEpsilonDown, unity_level_db); EXPECT_GE(AudioResult::SinadEpsilonDown, AudioResult::kPrevSinadEpsilonDown); + + // Update the min distinguishable gain value, for display later (if --dump). + if (near_unity_level_db < unity_level_db) { + AudioResult::ScaleEpsilon = AudioResult::kMinGainDbUnity; + } else if (AudioResult::LevelEpsilonDown < unity_level_db) { + AudioResult::ScaleEpsilon = AudioResult::kMaxGainDbNonUnity; + } } // Measure dynamic range (signal level, noise floor) when gain is -30dB. diff --git a/src/media/audio/audio_core/mixer/test/mixer_response_tests.cc b/src/media/audio/audio_core/mixer/test/mixer_response_tests.cc index 7d44b6872766668219226864f16e99933b8c83c6..0fb3682233bc3255a174d0faf414fa0373fe95cc 100644 --- a/src/media/audio/audio_core/mixer/test/mixer_response_tests.cc +++ b/src/media/audio/audio_core/mixer/test/mixer_response_tests.cc @@ -403,14 +403,16 @@ void TestUnitySampleRatio(Resampler sampler_type, double* freq_resp_results, sinad_results); } -// For the given resampler, target a 3:1 downsampling ratio. We articulate this -// by specifying a source buffer three times the length of the destination. +// For the given resampler, target a 4:1 downsampling ratio. We articulate this +// by specifying a source buffer almost 4x the length of the destination. We +// need to subtract 2 (not 1) because the audio analysis module adds one to the +// buffer length (in order to measure the Nyquist frequency bin). void TestDownSampleRatio0(Resampler sampler_type, double* freq_resp_results, double* sinad_results) { auto mixer = SelectMixer(fuchsia::media::AudioSampleFormat::FLOAT, 1, - 48000 * 3, 1, 48000, sampler_type); + 192000 - 2, 1, 48000, sampler_type); - MeasureFreqRespSinad(mixer.get(), round(kFreqTestBufSize * 3.0), + MeasureFreqRespSinad(mixer.get(), round(kFreqTestBufSize * 4) - 2, freq_resp_results, sinad_results); } @@ -458,14 +460,27 @@ void TestUpSampleRatio2(Resampler sampler_type, double* freq_resp_results, freq_resp_results, sinad_results); } +// For this resampler, target the upsampling ratio "almost 1:4". We don't use +// 1:4, as this (combined with the buffer size we have chosen, and the system +// definition of STEP_SIZE), exactly exceeds MAX_INT for src_pos. We specify a +// source buffer at just above 1/4 the length of the destination buffer. +void TestUpSampleRatio3(Resampler sampler_type, double* freq_resp_results, + double* sinad_results) { + auto mixer = SelectMixer(fuchsia::media::AudioSampleFormat::FLOAT, 1, 12000, + 1, 48000, sampler_type); + + MeasureFreqRespSinad(mixer.get(), (kFreqTestBufSize / 4), freq_resp_results, + sinad_results); +} + // For the given resampler, target micro-sampling -- with a 47999:48000 ratio. void TestMicroSampleRatio(Resampler sampler_type, double* freq_resp_results, double* sinad_results) { auto mixer = SelectMixer(fuchsia::media::AudioSampleFormat::FLOAT, 1, 47999, 1, 48000, sampler_type); - MeasureFreqRespSinad(mixer.get(), round(kFreqTestBufSize * 47999.0 / 48000.0), - freq_resp_results, sinad_results); + MeasureFreqRespSinad(mixer.get(), kFreqTestBufSize - 1, freq_resp_results, + sinad_results); } // Measure Freq Response for Point sampler, no rate conversion. @@ -588,6 +603,26 @@ TEST(Sinad, Point_UpSamp2) { AudioResult::kPrevSinadPointUp2.data()); } +// Measure Freq Response for Point sampler for up-sampling ratio #3. +TEST(FrequencyResponse, Point_UpSamp3) { + TestUpSampleRatio3(Resampler::SampleAndHold, + AudioResult::FreqRespPointUp3.data(), + AudioResult::SinadPointUp3.data()); + + EvaluateFreqRespResults(AudioResult::FreqRespPointUp3.data(), + AudioResult::kPrevFreqRespPointUp3.data()); +} + +// Measure SINAD for Point sampler for up-sampling ratio #3. +TEST(Sinad, Point_UpSamp3) { + TestUpSampleRatio3(Resampler::SampleAndHold, + AudioResult::FreqRespPointUp3.data(), + AudioResult::SinadPointUp3.data()); + + EvaluateSinadResults(AudioResult::SinadPointUp3.data(), + AudioResult::kPrevSinadPointUp3.data()); +} + // Measure Freq Response for Point sampler with minimum rate change. TEST(FrequencyResponse, Point_MicroSRC) { TestMicroSampleRatio(Resampler::SampleAndHold, @@ -728,6 +763,26 @@ TEST(Sinad, Linear_UpSamp2) { AudioResult::kPrevSinadLinearUp2.data()); } +// Measure Freq Response for Linear sampler for up-sampling ratio #3. +TEST(FrequencyResponse, Linear_UpSamp3) { + TestUpSampleRatio3(Resampler::LinearInterpolation, + AudioResult::FreqRespLinearUp3.data(), + AudioResult::SinadLinearUp3.data()); + + EvaluateFreqRespResults(AudioResult::FreqRespLinearUp3.data(), + AudioResult::kPrevFreqRespLinearUp3.data()); +} + +// Measure SINAD for Linear sampler for up-sampling ratio #3. +TEST(Sinad, Linear_UpSamp3) { + TestUpSampleRatio3(Resampler::LinearInterpolation, + AudioResult::FreqRespLinearUp3.data(), + AudioResult::SinadLinearUp3.data()); + + EvaluateSinadResults(AudioResult::SinadLinearUp3.data(), + AudioResult::kPrevSinadLinearUp3.data()); +} + // Measure Freq Response for Linear sampler with minimum rate change. TEST(FrequencyResponse, Linear_MicroSRC) { TestMicroSampleRatio(Resampler::LinearInterpolation, diff --git a/src/media/audio/audio_core/mixer/test/mixer_tests_recap.cc b/src/media/audio/audio_core/mixer/test/mixer_tests_recap.cc index 7a4dcf7316f4cb465bae503f3a9fe4d49670611b..5f983450e948dbbb4c97b4aaba7903db62f01c65 100644 --- a/src/media/audio/audio_core/mixer/test/mixer_tests_recap.cc +++ b/src/media/audio/audio_core/mixer/test/mixer_tests_recap.cc @@ -17,21 +17,22 @@ TEST(Recap, FreqResp) { printf("\n (in dB, with prior results)"); uint32_t num_freqs; - printf("\n\n Point resampler\n "); + printf("\n\n Point resampler\n "); - printf(" No SRC "); + printf(" No SRC "); if (FrequencySet::UseFullFrequencySet) { - printf(" 144k->48k"); + printf(" 191999->48k"); num_freqs = FrequencySet::kReferenceFreqs.size(); } else { num_freqs = FrequencySet::kSummaryIdxs.size(); } - printf(" 96k->48k "); + printf(" 96k->48k "); if (FrequencySet::UseFullFrequencySet) { - printf(" 88.2k->48k"); - printf(" 44.1k->48k"); - printf(" 24k->48k "); - printf(" Micro-SRC"); + printf(" 88.2k->48k "); + printf(" 44.1k->48k "); + printf(" 24k->48k "); + printf(" 12001->48k "); + printf(" Micro-SRC "); } for (uint32_t idx = 0; idx < num_freqs; ++idx) { @@ -85,6 +86,13 @@ TEST(Recap, FreqResp) { } else { printf(" "); } + if (AudioResult::kPrevFreqRespPointUp3[freq] != + -std::numeric_limits<double>::infinity()) { + printf(" %9.6lf (%9.6lf)", AudioResult::FreqRespPointUp3[freq], + AudioResult::kPrevFreqRespPointUp3[freq]); + } else { + printf(" "); + } if (AudioResult::kPrevFreqRespPointMicro[freq] != -std::numeric_limits<double>::infinity()) { printf(" %9.6lf (%9.6lf)", AudioResult::FreqRespPointMicro[freq], @@ -93,18 +101,19 @@ TEST(Recap, FreqResp) { } } - printf("\n\n Linear resampler\n "); + printf("\n\n Linear resampler\n "); if (FrequencySet::UseFullFrequencySet) { - printf(" No SRC "); - printf(" 144k->48k"); - printf(" 96k->48k "); + printf(" No SRC "); + printf(" 191999->48k"); + printf(" 96k->48k "); } - printf(" 88.2k->48k"); - printf(" 44.1k->48k"); + printf(" 88.2k->48k "); + printf(" 44.1k->48k "); if (FrequencySet::UseFullFrequencySet) { - printf(" 24k->48k "); - printf(" Micro-SRC"); + printf(" 24k->48k "); + printf(" 12001->48k "); + printf(" Micro-SRC "); } for (uint32_t idx = 0; idx < num_freqs; ++idx) { @@ -160,6 +169,13 @@ TEST(Recap, FreqResp) { } else { printf(" "); } + if (AudioResult::kPrevFreqRespLinearUp3[freq] != + -std::numeric_limits<double>::infinity()) { + printf(" %9.6lf (%9.6lf)", AudioResult::FreqRespLinearUp3[freq], + AudioResult::kPrevFreqRespLinearUp3[freq]); + } else { + printf(" "); + } if (AudioResult::kPrevFreqRespLinearMicro[freq] != -std::numeric_limits<double>::infinity()) { printf(" %9.6lf (%9.6lf)", AudioResult::FreqRespLinearMicro[freq], @@ -178,21 +194,22 @@ TEST(Recap, SINAD) { printf("\n (in dB, with prior results)"); uint32_t num_freqs; - printf("\n\n Point resampler\n "); + printf("\n\n Point resampler\n "); - printf(" No SRC "); + printf(" No SRC "); if (FrequencySet::UseFullFrequencySet) { - printf(" 144k->48k"); + printf(" 191999->48k"); num_freqs = FrequencySet::kReferenceFreqs.size(); } else { num_freqs = FrequencySet::kSummaryIdxs.size(); } - printf(" 96k->48k "); + printf(" 96k->48k "); if (FrequencySet::UseFullFrequencySet) { - printf(" 88.2k->48k"); - printf(" 44.1k->48k"); - printf(" 24k->48k "); - printf(" Micro-SRC"); + printf(" 88.2k->48k "); + printf(" 44.1k->48k "); + printf(" 24k->48k "); + printf(" 12001->48k "); + printf(" Micro-SRC "); } for (uint32_t idx = 0; idx < num_freqs; ++idx) { @@ -246,7 +263,13 @@ TEST(Recap, SINAD) { } else { printf(" "); } - + if (AudioResult::kPrevSinadPointUp3[freq] != + -std::numeric_limits<double>::infinity()) { + printf(" %6.2lf (%6.2lf)", AudioResult::SinadPointUp3[freq], + AudioResult::kPrevSinadPointUp3[freq]); + } else { + printf(" "); + } if (AudioResult::kPrevSinadPointMicro[freq] != -std::numeric_limits<double>::infinity()) { printf(" %6.2lf (%6.2lf)", AudioResult::SinadPointMicro[freq], @@ -255,18 +278,19 @@ TEST(Recap, SINAD) { } } - printf("\n\n Linear resampler\n "); + printf("\n\n Linear resampler\n "); if (FrequencySet::UseFullFrequencySet) { - printf(" No SRC "); - printf(" 144k->48k"); - printf(" 96k->48k "); + printf(" No SRC "); + printf(" 191999->48k"); + printf(" 96k->48k "); } - printf(" 88.2k->48k"); - printf(" 44.1k->48k"); + printf(" 88.2k->48k "); + printf(" 44.1k->48k "); if (FrequencySet::UseFullFrequencySet) { - printf(" 24k->48k "); - printf(" Micro-SRC"); + printf(" 24k->48k "); + printf(" 12001->48k "); + printf(" Micro-SRC "); } for (uint32_t idx = 0; idx < num_freqs; ++idx) { @@ -322,7 +346,13 @@ TEST(Recap, SINAD) { } else { printf(" "); } - + if (AudioResult::kPrevSinadLinearUp3[freq] != + -std::numeric_limits<double>::infinity()) { + printf(" %6.2lf (%6.2lf)", AudioResult::SinadLinearUp3[freq], + AudioResult::kPrevSinadLinearUp3[freq]); + } else { + printf(" "); + } if (AudioResult::kPrevSinadLinearMicro[freq] != -std::numeric_limits<double>::infinity()) { printf(" %6.2lf (%6.2lf)", AudioResult::SinadLinearMicro[freq],