Esempio n. 1
0
        public void TestBrickwall()
        {
            var saw = Utils.Saw(1024, 1.0f);

            var sine1 = Utils.Sinewave(1024, 0, 1 / 1024.0f * 2.0f * (double)Math.PI, 1.0f);
            var sine2 = Utils.Sinewave(1024, 0, 2 / 1024.0f * 2.0f * (double)Math.PI, 1.0f);
            //var sine1 = Utils.Sinewave(1024, 0, 1 / 1024.0f * 2.0f * (double)Math.PI, 1.0f);
            //var sine1 = Utils.Sinewave(1024, 0, 1 / 1024.0f * 2.0f * (double)Math.PI, 1.0f);

            for (int i = 0; i < saw.Length; i++)
                saw[i] = sine1[i] + sine2[i] + 0.02f;

            var kernel = Utils.SincFilter(1/2024.0f, 256, "Blackman");

            var s = new Stopwatch();
            s.Restart();
            var filtered = Convolution.ConvSimpleCircular(saw, kernel);
            s.Stop();

            //MessageBox.Show("Millisec: " + s.ElapsedMilliseconds);

            Line l = new Line(Utils.Linspace(-1, 1, saw.Length), saw); l.LinePen = Pens.Blue;
            Line l2 = new Line(Utils.Linspace(-1, 1, filtered.Length), filtered); l2.LinePen = Pens.Red;
            Line l3 = new Line(Utils.Linspace(-1, 1, saw.Length), sine1); l3.LinePen = Pens.Green;
            Line l4 = new Line(Utils.Linspace(-1, 1, saw.Length), sine2); l4.LinePen = Pens.Gray;
            var list = new List<Line>() { l, l2, l3, l4 };
            Plot.Plot.ShowPlot(list);
        }