void run_equalizer(FloatBuffer *fbin, FloatBuffer *fbout, EqualizerData *data) { int i, rpos; float lpf_out[EQUALIZER_BANDS + 1]; float sum = 0.0; /* Save the input read location; we can reuse the same input data on all * of the LPFs. */ rpos = fbin->rpos; /* Run the child filters. */ for (i = 0; i < EQUALIZER_BANDS + 1; i++) { fbin->rpos = rpos; run_lpf(fbin, &data->fb[i], &data->lpf[i]); lpf_out[i] = data->fb[i].buff[data->fb[i].rpos++]; } /* Now process the results of the filters. Remember that each band is * output(hi)-output(lo). */ for (i = 0; i < EQUALIZER_BANDS; i++) sum += (lpf_out[i+1] - lpf_out[i]) * data->gain[i]; /* Write that result. */ fb_ensure_writable(fbout, 1); fbout->buff[fbout->rlen++] = sum; }
void run_lpf(FloatBuffer *fbin, FloatBuffer *fbout, LPFData *data) { float sum = 0.0; int i = 0; if (fbin->rpos + data->taps - 1 >= fbin->rlen) { print("WARNING: upcoming underflow in run_lpf()\n"); } for (i = 0; i < data->taps; i++) { sum += fbin->buff[fbin->rpos + i] * data->coeff[i]; } fbin->rpos += data->decimation + 1; /* */ /* Check that there's room in the output buffer; */ /* move data if necessary. */ /* */ fb_ensure_writable(fbout, 1); fbout->buff[fbout->rlen++] = sum; return; }
void run_demod(FloatBuffer *fbin, FloatBuffer *fbout) { float temp, gain; gain = MAX_AMPLITUDE * SAMPLING_RATE / (BANDWIDTH * M_PI); temp = fbin->buff[fbin->rpos] * fbin->buff[fbin->rpos + 1]; temp = gain * atan(temp); fbin->rpos++; fb_ensure_writable(fbout, 1); fbout->buff[fbout->rlen++] = temp; }