Mercurial > hg > qm-dsp
changeset 507:d7b9691817a3
Fix a further overrun that caused the wrong input to be provided to sub-filters!
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Wed, 05 Jun 2019 16:02:20 +0100 |
parents | 285f18c0992a |
children | 855d862cf02b |
files | dsp/signalconditioning/FiltFilt.cpp tests/TestFiltFilt.cpp |
diffstat | 2 files changed, 3 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/dsp/signalconditioning/FiltFilt.cpp Wed Jun 05 15:50:38 2019 +0100 +++ b/dsp/signalconditioning/FiltFilt.cpp Wed Jun 05 16:02:20 2019 +0100 @@ -58,7 +58,7 @@ } index = 0; for (i = 0; i < nFact; i++) { - if (i < length) { + if (i + 1 < length) { filtScratchIn[(nExt - nFact) + index] = sampleN - src[ (length - 2) - i ]; }
--- a/tests/TestFiltFilt.cpp Wed Jun 05 15:50:38 2019 +0100 +++ b/tests/TestFiltFilt.cpp Wed Jun 05 16:02:20 2019 +0100 @@ -66,7 +66,7 @@ vector<double> b(iir_b); vector<double> in({ 1.0 }); vector<double> out({ 0.0 }); - vector<double> expected({ -0.000236642942007 }); + vector<double> expected({ 0.000607783187363 }); FiltFilt f({ a, b }); @@ -83,7 +83,7 @@ vector<double> b(iir_b); vector<double> in { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; - vector<double> expected { 0.0180395628158, -0.0317213769922, 0.0276928584707, -0.00944844359572, -0.0119394068579, 0.0252763627734, -0.0239770024451, 0.010560830803, 0.00726290602379, -0.0191915890394, 0.0202451156989, -0.0103434265023, -0.00341952789985, 0.0142823904341, -0.0160627659442, 0.00984876782803 }; + vector<double> expected { 0.0183210564167, -0.0251812631055, 0.0182718199887, -0.00232894428926, -0.0131783133711, 0.0204387725824, -0.016092298975, 0.00402175146108, 0.00913732971217, -0.0158214509991, 0.0138601876508, -0.00455783828038, -0.00563875593951, 0.0121184171941, -0.011073916445, 0.00491681731861 }; FiltFilt f({ a, b });