public static ComplexD Div(double a, ComplexD b) { var d = (b.real * b.real) + (b.imag * b.imag); var s = a / d; return(new ComplexD(s * b.real, -s * b.imag)); }
public static ComplexD Pow(ComplexD a, double b) { var p = Math.Atan2(a.imag, a.real); var m = Math.Pow(a.Mag2(), b * 0.5f); return(new ComplexD(m * Math.Cos(p * b), m * Math.Sin(p * b))); }
public static ComplexD Div(ComplexD a, ComplexD b) { var d = (b.real * b.real) + (b.imag * b.imag); var s = 1.0 / d; return(new ComplexD( ((a.real * b.real) + (a.imag * b.imag)) * s, ((a.imag * b.real) - (a.real * b.imag)) * s )); }
private void DrawFilterCurve( Rect r, float[] coeffs, float lowGain, float midGain, float highGain, Color color, bool filled, double samplerate, double magScale) { var wm = (-2.0 * 3.1415926) / samplerate; AudioCurveRendering.AudioCurveEvaluator d = delegate(float x) { var w = ComplexD.Exp(wm * GUIHelpers.MapNormalizedFrequency(x, samplerate, useLogScale, true)); var lpf = ComplexD.Pow( ((w * ((w * coeffs[0]) + coeffs[1])) + coeffs[2]) / ((w * ((w * coeffs[3]) + coeffs[4])) + 1.0f), filterOrder ); var bpf1 = ComplexD.Pow( ((w * ((w * coeffs[5]) + coeffs[6])) + coeffs[7]) / ((w * ((w * coeffs[8]) + coeffs[9])) + 1.0f), filterOrder ); var bpf2 = ComplexD.Pow( ((w * ((w * coeffs[10]) + coeffs[11])) + coeffs[12]) / ((w * ((w * coeffs[13]) + coeffs[14])) + 1.0f), filterOrder ); var hpf = ComplexD.Pow( ((w * ((w * coeffs[15]) + coeffs[16])) + coeffs[17]) / ((w * ((w * coeffs[18]) + coeffs[19])) + 1.0f), filterOrder ); var h = (lpf * lowGain).Mag2() + (bpf1 * bpf2 * midGain).Mag2() + (hpf * highGain).Mag2(); var mag = masterGain + (10.0 * Math.Log10(h)); return((float)(mag * magScale)); }; if (filled) { AudioCurveRendering.DrawFilledCurve(r, d, color); } else { AudioCurveRendering.DrawCurve(r, d, color); } }
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) { var wm = (-2.0f * 3.1415926) / samplerate; var one = new ComplexD(1.0f, 0.0f); AudioCurveRendering.AudioCurveEvaluator d = delegate(float x) { var w = ComplexD.Exp(wm * GUIHelpers.MapNormalizedFrequency(x, samplerate, useLogScale, true)); var hl = !lowGain ? one : ((w * ((w * coeffs[0]) + coeffs[1])) + coeffs[2]) / ((w * ((w * coeffs[3]) + coeffs[4])) + 1.0f); var hp = !midGain ? one : ((w * ((w * coeffs[5]) + coeffs[6])) + coeffs[7]) / ((w * ((w * coeffs[8]) + coeffs[9])) + 1.0f); var hh = !highGain ? one : ((w * ((w * coeffs[10]) + coeffs[11])) + coeffs[12]) / ((w * ((w * coeffs[13]) + coeffs[14])) + 1.0f); var h = hh * hp * hl; var 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); } }
public void DrawFilterCurve( Rect r, float[] coeffs, Color color, int numModes, bool useLogScale, bool filled, double samplerate, double magScale) { var wm = (-2.0f * 3.1415926) / samplerate; var zero = new ComplexD(0.0f, 0.0f); var one = new ComplexD(1.0f, 0.0f); AudioCurveRendering.AudioCurveEvaluator d = delegate(float x) { var w = ComplexD.Exp(wm * GUIHelpers.MapNormalizedFrequency(x, samplerate, useLogScale, true)); var h = zero; var num = numModes * 3; for (var n = 0; n < num; n += 3) { h += (coeffs[n] * (one - (w * w))) / ((w * ((w * coeffs[n + 2]) + coeffs[n + 1])) + 1.0); } var mag = 10.0 * Math.Log10(h.Mag2()); return((float)(mag * magScale)); }; if (filled) { AudioCurveRendering.DrawFilledCurve(r, d, color); } else { AudioCurveRendering.DrawCurve(r, d, color); } }
public static ComplexD Div(ComplexD a, double b) { var s = 1.0 / b; return(new ComplexD(a.real * s, a.imag * s)); }
public static ComplexD Mul(double a, ComplexD b) { return(new ComplexD(a * b.real, a * b.imag)); }
public static ComplexD Mul(ComplexD a, double b) { return(new ComplexD(a.real * b, a.imag * b)); }
public static ComplexD Mul(ComplexD a, ComplexD b) { return(new ComplexD((a.real * b.real) - (a.imag * b.imag), (a.real * b.imag) + (a.imag * b.real))); }
public static ComplexD Sub(double a, ComplexD b) { return(new ComplexD(a - b.real, -b.imag)); }
public static ComplexD Sub(ComplexD a, double b) { return(new ComplexD(a.real - b, a.imag)); }
public static ComplexD Sub(ComplexD a, ComplexD b) { return(new ComplexD(a.real - b.real, a.imag - b.imag)); }
public static ComplexD Add(double a, ComplexD b) { return(new ComplexD(a + b.real, b.imag)); }
public static ComplexD Add(ComplexD a, double b) { return(new ComplexD(a.real + b, a.imag)); }
public static ComplexD Add(ComplexD a, ComplexD b) { return(new ComplexD(a.real + b.real, a.imag + b.imag)); }