Esempio n. 1
0
    public static void DrawWave(Graphics g,
                                RectangleF r,
                                float phase,
                                IStream Source)
    {
        g.SmoothingMode   = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
        g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
        DrawPaper(g, r);
        phase = Source?.ElapsedTime ?? 0;
        float hz = Source?.Hz ?? 0;

        float[] X =
            Source?.Read();
        if (X == null)
        {
            return;
        }
        DrawFunction(g, r, (i, cc) => Envelopes.Hann(i, cc) * X[i * X.Length / cc], Brushes.DarkOrange);
        var fft = Complex.FFT(X);

        X = Complex.InverseFFT(fft);
        DrawFunction(g, r, (i, cc) => Envelopes.Hann(i, cc) * X[i * X.Length / cc], Brushes.DarkViolet);

        DrawLabels(g, r, Source.ElapsedTime, hz, X);
    }
Esempio n. 2
0
        public static void Envelope(float[] X)
        {
            var samples = X.Length;

            for (int s = 0; s < samples; s++)
            {
                X[s] = X[s]
                       * (float)Envelopes.Hann(s, samples);
            }
        }