public void TestLowPassLeastSquareFiltering() { const int order = 64; const int fs = 44100; const double cutoffFrequency = 2000d; const int cycles = 10; double[] frequencies = { 770, 5830 }; var validFrequencies = frequencies.TakeWhile(f => f < cutoffFrequency); var coeff = new LowPassLeastSquareCoefficients(order, fs, cutoffFrequency); TestFilter(order, fs, cycles, coeff, frequencies, validFrequencies); }
private static void TestLowPass(int order, double fs, double cutoffFrequency, double[] expected, double error, bool scale) { var coeff = new LowPassLeastSquareCoefficients(order, fs, cutoffFrequency) { UseScaling = scale }; var chain = coeff.Calculate(); Assert.AreEqual(expected.Length, chain.Count); for (int i = 0; i < expected.Length; i++) { Assert.AreEqual(expected[i], chain[i], error); } }