streson

Files: streson.h, streson.c

String resonator filter

Functions

sp_streson_create(sp_streson **streson)
sp_streson_init(sp_data *sp, sp_streson *streson)
sp_streson_compute(sp_data *sp, sp_streson *streson, SPFLOAT *input, SPFLOAT *output)
sp_streson_destroy(sp_streson **streson)

Optional Parameters

freq: Fundamental frequency of string.
(Default value: 440.0)
fdbgain: Feedback amount (value between 0-1)
(Default value: 0.8)

Inputs

input: Signal input.

Outputs

output: Signal output.

Example Code

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

typedef struct {
    sp_noise *ns;
    sp_streson *stres;
} UserData;

void write_noise(sp_data *data, void *ud) {
    UserData *udata = ud;
    SPFLOAT in = 0;
    SPFLOAT noise = 0;
    sp_noise_compute(data, udata->ns, NULL, &noise);
    sp_streson_compute(data, udata->stres, &noise, &data->out[0]);
}
int main() {
    srand(time(NULL));
    UserData ud;
    sp_data *sp;
    sp_create(&sp);
    sp_streson_create(&ud.stres);
    sp_noise_create(&ud.ns);
    sp_noise_init(sp, ud.ns);
    sp_streson_init(sp, ud.stres);
    sp->len = 44100 * 5;
    sp_process(sp, &ud, write_noise);
    sp_noise_destroy(&ud.ns);
    sp_streson_destroy(&ud.stres);
    sp_destroy(&sp);
    return 0;
}