int main (void){ printf("Start program.\n"); num_coeff[4] = 9.7E-3; num_coeff[3] = 1.8E-2; num_coeff[2] = 2.4E-2; num_coeff[1] = 1.8E-2; num_coeff[0] = 9.7E-3; denom_coeff[4] = 1.8E-1; denom_coeff[3] = -1.0E0; denom_coeff[2] = 2.2E0; denom_coeff[1] = -2.3E0; denom_coeff[0] = 1.0E0; //main part iir_filter(y, x, inputlen, num_coeff, denom_coeff, filterlen); printf("Filter output is %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f\n", y[0], y[1], y[2], y[3], y[4], y[5], y[6], y[7], y[8], y[9], y[10], y[11]); return 1; }
// -------------------- Gaussian Blur filter --------------------- static void blur_line (const gdouble *ctable, const gdouble *cmatrix, gint cmatrix_length, const guchar *src, guchar *dest, gint len, /* length of src and dest */ glong bytes) /* Bits per plane */ { gint b = 0; gint row; gint w = c2g_params.radius+10; // For each channel, dealing with double, so for (b = 0; b<bytes; b++){ gint idx; for (row = b, idx=0 ; idx < len; row +=bytes, idx++) iir.p[idx+w] = src[row]; iir_filter(iir.p+w, len); for (row =b, idx=0; idx < len; row +=bytes, idx++){ gdouble value = iir.p[idx+w]; dest[row] = CLAMP( (gint) value, 0, 255); } } }
void Filter::GetOutput(int V, Sample &data) { float Cutoff; float Resonance; if (m_FilterBypass || fc<0) return; for (int n=0; n<data.GetLength(); n++) { coef = iir[V].coef + 1; /* Skip k, or gain */ k=0.25; Cutoff = fc; Resonance = Q; Cutoff/=2; if (Resonance>MAX_RES) Resonance=MAX_RES; if (Cutoff>MAX_CUTOFF) Cutoff=MAX_CUTOFF; if (Resonance<MIN_RES) Resonance=MIN_RES; if (Cutoff<MIN_CUTOFF) Cutoff=MIN_CUTOFF; if (n%10==0) { // if different from last time //if (m_LastQ!=Q || m_LastFC!=fc) { for (nInd = 0; nInd < iir[V].length; nInd++) { a2 = ProtoCoef[nInd].a2; a0 = ProtoCoef[nInd].a0; a1 = ProtoCoef[nInd].a1; b0 = ProtoCoef[nInd].b0; b1 = ProtoCoef[nInd].b1 / Resonance; b2 = ProtoCoef[nInd].b2; szxform(&a0, &a1, &a2, &b0, &b1, &b2, Cutoff*(Cutoff/1000.0f), fs, &k, coef); coef += 4; } iir[V].coef[0] = k; m_LastQ=Q; m_LastFC=fc; } } data.Set(n,iir_filter(data[n],&iir[V])); } }
float value( float v ) { return iir_filter( v, &(iir) ); }