fofilt

Files: fofilt.h, fofilt.c

Formant filter When fed with a pulse train, it will generate a series of overlapping grains. Overlapping will occur when 1/freq < dec, but there is no upper limit on the number of overlaps. (cited from www.csounds.com/manual/html/fofilter.html)

Functions

sp_fofilt_create(sp_fofilt **fofilt)
sp_fofilt_init(sp_data *sp, sp_fofilt *fofilt)
sp_fofilt_compute(sp_data *sp, sp_fofilt *fofilt, SPFLOAT *input, SPFLOAT *out)
sp_fofilt_destroy(sp_fofilt **fofilt)

Optional Parameters

freq: Center frequency.
(Default value: 1000)
atk: Impulse response attack time (in seconds).
(Default value: 0.007)
dec: Impulse reponse decay time (in seconds)
(Default value: 0.04)

Inputs

input: Signal input.

Outputs

out: Signal output

Example Code

#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include "soundpipe.h"

typedef struct {
    sp_noise *ns;
    sp_fofilt *tn;
} UserData;

void write_noise(sp_data *data, void *ud) {
    UserData *udata = ud;
    SPFLOAT in = 0;
    SPFLOAT out = 0;
    sp_noise_compute(data, udata->ns, NULL, &in);
    sp_fofilt_compute(data, udata->tn, &in, &data->out[0]); 
}
int main() {
    srand(time(NULL));
    UserData ud;
    sp_data *sp;
    sp_create(&sp);
    sp_noise_create(&ud.ns);
    sp_fofilt_create(&ud.tn);
    sp_noise_init(sp, ud.ns);
    sp_fofilt_init(sp, ud.tn);
    ud.tn->freq = 500;
    sp->len = 44100 * 5;
    sp_process(sp, &ud, write_noise);
    sp_noise_destroy(&ud.ns);
    sp_fofilt_destroy(&ud.tn);
    sp_destroy(&sp);
    return 0;
}