Exemple #1
0
        public void EvenWindowSize()
        {
            var filter = OnlineFilterFactory.Create(OnlineFilterDesign.Median,
                                                    new MedianFilterDesignSettings {
                WindowSize = 4
            });

            var result = Accumulate(filter, 1, 2, 3, 4, 5, 6, 7);

            Assert.AreEqual(1, result[0]); // 1 - - -
            Assert.AreEqual(1, result[1]); // 1 2 - -
            Assert.AreEqual(2, result[2]); // 1 2 3 -
            Assert.AreEqual(2, result[3]); // 1 2 3 4
            Assert.AreEqual(3, result[4]); // 2 3 4 5
            Assert.AreEqual(4, result[5]); // 3 4 5 6
            Assert.AreEqual(5, result[6]); // 4 5 6 7
        }
        protected static void TestFilter(OnlineFilterDesigner designer, bool extended)
        {
            var samples = CreateTestSamples();

            var lowPass = OnlineFilterFactory.Create(FilterKind.LowPass, designer, CreateSettings(), SamplingRate / 4);

            AssertSomethingChanged(samples, lowPass.Process(samples));

            var highPass = OnlineFilterFactory.Create(FilterKind.HighPass, designer, CreateSettings(), SamplingRate / 4);

            AssertSomethingChanged(samples, highPass.Process(samples));

            var notch = OnlineFilterFactory.Create(FilterKind.Notch, designer, CreateSettings(), SamplingRate / 4);

            AssertSomethingChanged(samples, notch.Process(samples));

            var bandPass = OnlineFilterFactory.Create(FilterKind.BandPass, designer, CreateSettings(), new Range <double>(SamplingRate / 4 - 10, SamplingRate / 4 + 10));

            AssertSomethingChanged(samples, bandPass.Process(samples));

            var bandStop = OnlineFilterFactory.Create(FilterKind.BandStop, designer, CreateSettings(), new Range <double>(SamplingRate / 4 - 10, SamplingRate / 4 + 10));

            AssertSomethingChanged(samples, bandStop.Process(samples));

            if (extended)
            {
                var allPass = OnlineFilterFactory.Create(FilterKind.AllPass, designer, CreateSettings(), new Range <double>(SamplingRate / 4 - 10, SamplingRate / 4 + 10));
                AssertSomethingChanged(samples, allPass.Process(samples));

                var lowShelf = OnlineFilterFactory.Create(FilterKind.LowShelf, designer, CreateSettings(), SamplingRate / 4);
                AssertSomethingChanged(samples, lowShelf.Process(samples));

                var highShelf = OnlineFilterFactory.Create(FilterKind.HighShelf, designer, CreateSettings(), SamplingRate / 4);
                AssertSomethingChanged(samples, highShelf.Process(samples));
            }
        }