/// <summary>Calculates IIR</summary> /// <param name="sample">sample rate</param> /// <param name="b">biquad pointer</param> public void BiQuad(ref Int16 sample, biquad *b) { // compute result double result = b->a0 * sample + b->a1 * b->x1 + b->a2 * b->x2 - b->a3 * b->y1 - b->a4 * b->y2; // shift x1 to x2, sample to x1 b->x2 = b->x1; b->x1 = sample; // shift y1 to y2, result to y1 b->y2 = b->y1; b->y1 = result; sample = (Int16)result; }
/// <summary>Release heap memory</summary> /// <param name="pmem">memory address</param> private void Free(biquad *b) { HeapFree(GetProcessHeap(), 0, b); }
public void FreeMem(biquad *b) { Free(b); }
private static extern bool HeapFree(IntPtr hHeap, uint dwFlags, biquad *lpMem);