tone

Files: tone.h, tone.c

First-order recursive lowpass filter

Functions

sp_tone_create(sp_tone **tone)
sp_tone_init(sp_data *sp, sp_tone *tone)
sp_tone_compute(sp_data *sp, sp_tone *tone, SPFLOAT *in, SPFLOAT *out)
sp_tone_destroy(sp_tone **tone)

Optional Parameters

hp: The response curve's half power point (aka cutoff frequency).
(Default value: 1000)

Inputs

in: 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_tone *tn;
} UserData;

void write_noise(sp_data *sp, void *udata) {
    UserData *ud = udata;
    SPFLOAT in = 0;
    SPFLOAT out = 0;
    sp_noise_compute(sp, ud->ns, NULL, &in);
    sp_tone_compute(sp, ud->tn, &in, &sp->out[0]); 
}
int main() {
    srand(time(NULL));
    UserData ud;
    sp_data *sp;
    sp_create(&sp);
    sp_noise_create(&ud.ns);
    sp_tone_create(&ud.tn);
    sp_noise_init(sp, ud.ns);
    sp_tone_init(sp, ud.tn);
    sp->len = 44100 * 5;
    sp_process(sp, &ud, write_noise);
    sp_noise_destroy(&ud.ns);
    sp_tone_destroy(&ud.tn);
    sp_destroy(&sp);
    return 0;
}