Exemplo n.º 1
0
        public override void Render(Graphics g, float[] samples)
        {
            float[] heights = FFT.SampleToFreq(samples, Settings.SampleCount);
            GetLastIndex(heights);
            List <PointF> points = new List <PointF>();

            points.Add(new PointF(0, g.VisibleClipBounds.Height / 2));

            for (int i = 0; i < lastIndex; i++)
            {
                float height = Smooth(heights, i, Settings.Smoothing);
                float x      = i / (float)heights.Length * g.VisibleClipBounds.Width * Settings.XScale;
                float y      = (float)(g.VisibleClipBounds.Height / 2 - height * Settings.YScale * ((i % 2) * 2 - 1));

                points.Add(new PointF(x, y));
            }

            points.Add(new PointF(g.VisibleClipBounds.Width, g.VisibleClipBounds.Height / 2));

            Pen p = new Pen(Settings.GetColor("Color"), 2.0f);

            g.DrawLines(p, points.ToArray());
        }