From 00bf859fa707aade3027e5c27325637e09edd06a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Thu, 20 Apr 2023 09:21:59 +0200 Subject: [PATCH 1/4] Fix conditional IIR_ANALYSIS --- src/engine/filters/enginefilteriir.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/engine/filters/enginefilteriir.h b/src/engine/filters/enginefilteriir.h index b00996b9ba8..bd0446538b5 100644 --- a/src/engine/filters/enginefilteriir.h +++ b/src/engine/filters/enginefilteriir.h @@ -126,16 +126,16 @@ class EngineFilterIIR : public EngineFilterIIRBase { } double resp2, phase2; resp2 = fid_response_pha(filt, freq0 / sampleRate / 2, &phase2); - qDebug() << "freq2:" << freq0 / 2 << resp2 << phase0; + qDebug() << "freq2:" << freq0 / 2 << resp2 << phase2; double resp3, phase3; resp3 = fid_response_pha(filt, freq0 / sampleRate * 2, &phase3); - qDebug() << "freq3:" << freq0 * 2 << resp3 << phase0; + qDebug() << "freq3:" << freq0 * 2 << resp3 << phase3; double resp4, phase4; resp4 = fid_response_pha(filt, freq0 / sampleRate / 2.2, &phase4); - qDebug() << "freq4:" << freq0 / 2.2 << resp2 << phase0; + qDebug() << "freq4:" << freq0 / 2.2 << resp4 << phase4; double resp5, phase5; resp5 = fid_response_pha(filt, freq0 / sampleRate * 2.2, &phase5); - qDebug() << "freq5:" << freq0 * 2.2 << resp3 << phase0; + qDebug() << "freq5:" << freq0 * 2.2 << resp5 << phase5; free(filt); #endif } @@ -209,16 +209,16 @@ class EngineFilterIIR : public EngineFilterIIRBase { } double resp2, phase2; resp2 = fid_response_pha(filt, freq01 / sampleRate / 2, &phase2); - qDebug() << "freq2:" << freq01 / 2 << resp2 << phase0; + qDebug() << "freq2:" << freq01 / 2 << resp2 << phase2; double resp3, phase3; resp3 = fid_response_pha(filt, freq01 / sampleRate * 2, &phase3); - qDebug() << "freq3:" << freq01 * 2 << resp3 << phase0; + qDebug() << "freq3:" << freq01 * 2 << resp3 << phase3; double resp4, phase4; resp4 = fid_response_pha(filt, freq01 / sampleRate / 2.2, &phase4); - qDebug() << "freq4:" << freq01 / 2.2 << resp2 << phase0; + qDebug() << "freq4:" << freq01 / 2.2 << resp4 << phase4; double resp5, phase5; resp5 = fid_response_pha(filt, freq01 / sampleRate * 2.2, &phase5); - qDebug() << "freq5:" << freq01 * 2.2 << resp3 << phase0; + qDebug() << "freq5:" << freq01 * 2.2 << resp5 << phase5; free(filt); #endif } From a44cfce89d7e272650d6b0b3dd387cd32f22f704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Thu, 20 Apr 2023 10:22:38 +0200 Subject: [PATCH 2/4] Improve IIR debug --- src/engine/filters/enginefilteriir.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/engine/filters/enginefilteriir.h b/src/engine/filters/enginefilteriir.h index bd0446538b5..f14ff5a0d86 100644 --- a/src/engine/filters/enginefilteriir.h +++ b/src/engine/filters/enginefilteriir.h @@ -115,7 +115,8 @@ class EngineFilterIIR : public EngineFilterIIRBase { char* desc; FidFilter* filt = fid_design(spec_d, sampleRate, freq0, freq1, adj, &desc); int delay = fid_calc_delay(filt); - qDebug() << QString().fromLatin1(desc) << "delay:" << delay; + qDebug() << QString().fromLatin1(desc); + qDebug() << spec_d << "delay:" << delay; double resp0, phase0; resp0 = fid_response_pha(filt, freq0 / sampleRate, &phase0); qDebug() << "freq0:" << freq0 << resp0 << phase0; @@ -191,7 +192,8 @@ class EngineFilterIIR : public EngineFilterIIRBase { FidFilter* filt = fid_cat(1, filt1, filt2, NULL); int delay = fid_calc_delay(filt); qDebug() << QString().fromLatin1(desc1) << "X" - << QString().fromLatin1(desc2) << "delay:" << delay; + << QString().fromLatin1(desc2); + qDebug() << spec1 << "X" << spec2 << "delay:" << delay; double resp0, phase0; resp0 = fid_response_pha(filt, freq01 / sampleRate, &phase0); qDebug() << "freq01:" << freq01 << resp0 << phase0; From c707ecd2d5cb62589ab62949479cb68ccb6d5e2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Thu, 20 Apr 2023 10:23:31 +0200 Subject: [PATCH 3/4] Add fidlib analysis tests --- src/test/enginefilterbiquadtest.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/test/enginefilterbiquadtest.cpp b/src/test/enginefilterbiquadtest.cpp index bc3e37c851f..6bc9237601c 100644 --- a/src/test/enginefilterbiquadtest.cpp +++ b/src/test/enginefilterbiquadtest.cpp @@ -19,4 +19,32 @@ TEST_F(EngineFilterBiquadTest, fidspecLengthIsLongEnough) { ASSERT_TRUE(FIDSPEC_LENGTH > strlen("LsBq/1.2200000000/-12.0000000000")); } +TEST_F(EngineFilterBiquadTest, analysisPkBq) { + char spec_d[FIDSPEC_LENGTH]; + format_fidspec(spec_d, sizeof(spec_d), "PkBq/%.10f/%.10f", 1.75, 0.0); + + char* desc; + FidFilter* filt = fid_design(spec_d, 44100, 1000, 0, 0, &desc); + int delay = fid_calc_delay(filt); + EXPECT_EQ(delay, 0); + double resp0, phase0; + resp0 = fid_response_pha(filt, 1000 / 44100, &phase0); + EXPECT_DOUBLE_EQ(resp0, 1); + EXPECT_DOUBLE_EQ(phase0, 0); + free(filt); +} + +TEST_F(EngineFilterBiquadTest, analysisLpBe4) { + char* desc; + FidFilter* filt = fid_design("LpBe4", 44100, 600, 0, 0, &desc); + int delay = fid_calc_delay(filt); + EXPECT_EQ(delay, 24); + + double resp0, phase0; + resp0 = fid_response_pha(filt, 600 / 44100, &phase0); + EXPECT_DOUBLE_EQ(resp0, 1); + EXPECT_DOUBLE_EQ(phase0, 0); + free(filt); +} + } // namespace From 7b272a145ede72c04ced86b612ade2a25b7b5384 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sun, 23 Apr 2023 20:13:37 +0200 Subject: [PATCH 4/4] Add placholder value to check if the value has really been written as expected. --- src/test/enginefilterbiquadtest.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/test/enginefilterbiquadtest.cpp b/src/test/enginefilterbiquadtest.cpp index 6bc9237601c..7ba4c06e8b8 100644 --- a/src/test/enginefilterbiquadtest.cpp +++ b/src/test/enginefilterbiquadtest.cpp @@ -23,27 +23,32 @@ TEST_F(EngineFilterBiquadTest, analysisPkBq) { char spec_d[FIDSPEC_LENGTH]; format_fidspec(spec_d, sizeof(spec_d), "PkBq/%.10f/%.10f", 1.75, 0.0); - char* desc; - FidFilter* filt = fid_design(spec_d, 44100, 1000, 0, 0, &desc); + char* pDesc = nullptr; + FidFilter* filt = fid_design(spec_d, 44100, 1000, 0, 0, &pDesc); + EXPECT_NE(pDesc, nullptr); int delay = fid_calc_delay(filt); EXPECT_EQ(delay, 0); - double resp0, phase0; + + double resp0 = 0.0; + double phase0 = 1.0; resp0 = fid_response_pha(filt, 1000 / 44100, &phase0); - EXPECT_DOUBLE_EQ(resp0, 1); - EXPECT_DOUBLE_EQ(phase0, 0); + EXPECT_DOUBLE_EQ(resp0, 1.0); + EXPECT_DOUBLE_EQ(phase0, 0.0); free(filt); } TEST_F(EngineFilterBiquadTest, analysisLpBe4) { - char* desc; - FidFilter* filt = fid_design("LpBe4", 44100, 600, 0, 0, &desc); + char* pDesc = nullptr; + FidFilter* filt = fid_design("LpBe4", 44100, 600, 0, 0, &pDesc); + EXPECT_NE(pDesc, nullptr); int delay = fid_calc_delay(filt); EXPECT_EQ(delay, 24); - double resp0, phase0; + double resp0 = 0.0; + double phase0 = 1.0; resp0 = fid_response_pha(filt, 600 / 44100, &phase0); - EXPECT_DOUBLE_EQ(resp0, 1); - EXPECT_DOUBLE_EQ(phase0, 0); + EXPECT_DOUBLE_EQ(resp0, 1.0); + EXPECT_DOUBLE_EQ(phase0, 0.0); free(filt); }