pinknoise

Files: pinknoise.h, pinknoise.c

Pink pinknoise generator

Functions

sp_pinknoise_create(sp_pinknoise **pinknoise)
sp_pinknoise_init(sp_data *sp, sp_pinknoise *pinknoise)
sp_pinknoise_compute(sp_data *sp, sp_pinknoise *pinknoise, SPFLOAT *dummy, SPFLOAT *out)
sp_pinknoise_destroy(sp_pinknoise **pinknoise)

Optional Parameters

amp: Amplitude. (Value between 0-1).
(Default value: 1.0)

Outputs

out: Signal output.

Example Code

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

typedef struct {
    sp_pinknoise *ns;
} UserData;

void write_pinknoise(sp_data *sp, void *udata) {
    UserData *ud = udata;
    SPFLOAT out = 0;
    sp_pinknoise_compute(sp, ud->ns, NULL, &out);
    sp_out(sp, 0, out);
}

int main() {
    srand(time(NULL));
    UserData ud;
    sp_data *sp;
    sp_create(&sp);
    sp_pinknoise_create(&ud.ns);
    sp_pinknoise_init(sp, ud.ns);
    sp->len = 44100 * 5;
    sp_process(sp, &ud, write_pinknoise);
    sp_pinknoise_destroy(&ud.ns);
    sp_destroy(&sp);
    return 0;
}