Exemple #1
0
        public void Should_maintain_separation_of_channels()
        {
            var format = new WaveFormat(44100, 2);
            target = new FirFilter();
            target.Format = format;

            target.Coefficients = new[] { 0.2f, 0.1f };
            var buffers = new float[][]
            {
                new[] { 5f, 11f },
                new [] { 7f, 13f }
            };

            target.Process(buffers, 2);

            Assert.AreEqual(2, buffers.Length);
            Assert.AreEqual(2, buffers[0].Length);
            Assert.AreEqual(2, buffers[1].Length);

            Assert.AreEqual(0.2f * 5f, buffers[0][0], FloatComparer.Epsilon);
            Assert.AreEqual(0.2f * 11f + 0.1f * 5f, buffers[0][1], FloatComparer.Epsilon);

            Assert.AreEqual(0.2f * 7f, buffers[1][0], FloatComparer.Epsilon);
            Assert.AreEqual(0.2f * 13f + 0.1f * 7f, buffers[1][1], FloatComparer.Epsilon);
        }
Exemple #2
0
        public void Should_correctly_store_format()
        {
            target = new FirFilter();

            var expectedFormat = new WaveFormat();
            target.Format = expectedFormat;

            Assert.AreEqual(expectedFormat, target.Format);
        }
Exemple #3
0
        public void Should_correctly_store_coefficients()
        {
            target = new FirFilter();

            var expectedCoefficients = new float[1];
            target.Coefficients = expectedCoefficients;

            Assert.AreEqual(expectedCoefficients, target.Coefficients);
        }
Exemple #4
0
        public void FirFilter_20_coefficients_64_samples_and_1000000_iterations()
        {
            var format = new WaveFormat(44100, 1);
            var target = new FirFilter();
            target.Format = format;

            target.Coefficients = new float[20];

            var time = Helpers.Time(() =>
            {
                var buffer = new float[64];
                for (int i = 0; i < 1000000; i++)
                {
                    target.Process(new float[][] { buffer }, 64);
                }
            });
            Debug.WriteLine(string.Format("FirFilter performance test: {0}", time));
        }
Exemple #5
0
        public void Should_preserve_historic_values_with_multiple_channels()
        {
            var format = new WaveFormat(44100, 2);
            target = new FirFilter();
            target.Format = format;

            target.Coefficients = new[] { 1f, 0.5f };

            var buffers = new float[][]
            {
                new[] { 1f, 3f },
                new[] { 2f, 4f }
            };
            target.Process(buffers, 2);

            buffers = new float[][]
            {
                new[] { 5f, 7f },
                new[] { 6f, 8f }
            };
            target.Process(buffers, 2);

            Assert.AreEqual(5f + 0.5f * 3f, buffers[0][0], FloatComparer.Epsilon);
            Assert.AreEqual(7f + 0.5f * 5f, buffers[0][1], FloatComparer.Epsilon);
            Assert.AreEqual(6f + 0.5f * 4f, buffers[1][0], FloatComparer.Epsilon);
            Assert.AreEqual(8f + 0.5f * 6f, buffers[1][1], FloatComparer.Epsilon);
        }
Exemple #6
0
 public void Initialise()
 {
     var format = new WaveFormat(44100, 1);
     target = new FirFilter();
     target.Format = format;
 }
Exemple #7
0
        public void Should_return_the_name_fir_filter()
        {
            target = new FirFilter();

            Assert.AreEqual("FIR Filter", target.Name);
        }