public void DrawFilterCurve(
        Rect r,
        float[] coeffs,
        bool lowGain, bool midGain, bool highGain,
        Color color,
        bool useLogScale,
        bool filled,
        double masterGain,
        double samplerate,
        double magScale)
    {
        double wm = -2.0f * 3.1415926 / samplerate;

        ComplexD one = new ComplexD(1.0f, 0.0f);

        AudioCurveRendering.AudioCurveEvaluator d = delegate(float x)
        {
            ComplexD w   = ComplexD.Exp(wm * GUIHelpers.MapNormalizedFrequency((double)x, samplerate, useLogScale, true));
            ComplexD hl  = (!lowGain) ? one : (w * (w * coeffs[0] + coeffs[1]) + coeffs[2]) / (w * (w * coeffs[3] + coeffs[4]) + 1.0f);
            ComplexD hp  = (!midGain) ? one : (w * (w * coeffs[5] + coeffs[6]) + coeffs[7]) / (w * (w * coeffs[8] + coeffs[9]) + 1.0f);
            ComplexD hh  = (!highGain) ? one : (w * (w * coeffs[10] + coeffs[11]) + coeffs[12]) / (w * (w * coeffs[13] + coeffs[14]) + 1.0f);
            ComplexD h   = hh * hp * hl;
            double   mag = masterGain + 10.0 * Math.Log10(h.Mag2());
            return((float)(mag * magScale));
        };

        if (filled)
        {
            AudioCurveRendering.DrawFilledCurve(r, d, color);
        }
        else
        {
            AudioCurveRendering.DrawCurve(r, d, color);
        }
    }
Exemplo n.º 2
0
    public void DrawFilterCurve(
        Rect r,
        float[] coeffs,
        Color color,
        int numModes,
        bool useLogScale,
        bool filled,
        double samplerate,
        double magScale)
    {
        double wm = -2.0f * 3.1415926 / samplerate;

        ComplexD zero = new ComplexD(0.0f, 0.0f);
        ComplexD one  = new ComplexD(1.0f, 0.0f);

        AudioCurveRendering.AudioCurveEvaluator d = delegate(float x)
        {
            ComplexD w   = ComplexD.Exp(wm * GUIHelpers.MapNormalizedFrequency((double)x, samplerate, useLogScale, true));
            ComplexD h   = zero;
            int      num = numModes * 3;
            for (int n = 0; n < num; n += 3)
            {
                h += coeffs[n] * (one - w * w) / (w * (w * coeffs[n + 2] + coeffs[n + 1]) + 1.0);
            }
            double mag = 10.0 * Math.Log10(h.Mag2());
            return((float)(mag * magScale));
        };

        if (filled)
        {
            AudioCurveRendering.DrawFilledCurve(r, d, color);
        }
        else
        {
            AudioCurveRendering.DrawCurve(r, d, color);
        }
    }