noise

Files: noise.h, noise.c

White noise generator

Functions

sp_noise_create(sp_noise **noise)
sp_noise_init(sp_data *sp, sp_noise *noise)
sp_noise_compute(sp_data *sp, sp_noise *noise, SPFLOAT *dummy, SPFLOAT *out)
sp_noise_destroy(sp_noise **noise)

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_noise *ns;
} UserData;

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