Files: fog.h, fog.c

Sucession of grains from data in a stored function table


sp_fog_create(sp_fog **fog)
sp_fog_init(sp_data *sp, sp_fog *fog, sp_ftbl *wav, sp_ftbl *win, int iolaps, SPFLOAT iphs)
sp_fog_compute(sp_data *sp, sp_fog *fog, SPFLOAT *out)
sp_fog_destroy(sp_fog **fog)

Mandatory Parameters

wav: ftable for sample.
(Recommended value: N/A)
win: Ftable for envelope function (use either gen_line or gen_sinecomp)
(Recommended value: N/A)
iolaps: Maximum number of foglet overlaps.
(Recommended value: 100)
iphs: Phase
(Recommended value: 0)

Optional Parameters

amp: Overall amplitude
(Default value: 0.5)
dens: Density. The frequency of grains/second.
(Default value: 80)
trans: Transposition, in terms of playback speed
(Default value: 1)
spd: Starting sample index, normalized 0-1.
(Default value: 0)
oct: Octaviation index, if greater than zero, lowers the effective fund frequency by attenuating odd-numbered sine bursts. whole numbers are full octaves. fractions transpositional.
(Default value: 0)
band: Bandwidth (in -6db) expressed in Hz. The bandwidth determines the rate of exponential decay throughout the sineburst, before the enveloping is applied.
(Default value: 50)
ris: Rise of sinusoid burst (in seconds)
(Default value: 0.003)
dec: Decay of the sinusoid burst (in seconds).
(Default value: 0.0007)
dur: OVerall duration of sinusoid burst (in seconds).
(Default value: 0.02)


out: Signal output.

Example Code

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

typedef struct {
    sp_fog *fog;
    sp_ftbl *wav;
    sp_ftbl *win;
    sp_phasor *phs;
} UserData;

void process(sp_data *sp, void *udata) {
    UserData *ud = udata;
    SPFLOAT phs = 0, fog = 0;
    sp_phasor_compute(sp, ud->phs, NULL, &phs);
    ud->fog->spd = phs;
    sp_fog_compute(sp, ud->fog, NULL, &fog);
    sp->out[0] = fog;

int main() {
    UserData ud;
    sp_data *sp;

    sp_ftbl_loadfile(sp, &ud.wav, "oneart.wav");
    sp_ftbl_create(sp, &, 1024);

    sp_gen_composite(sp,, "0.5 0.5 270 0.5");

    sp_fog_init(sp, ud.fog, ud.wav,, 100, 0);
    ud.fog->trans = 0.9;

    sp_phasor_init(sp, ud.phs, 0);
    ud.phs->freq = 0.3 / ((SPFLOAT)ud.wav->size / sp->sr); 

    sp->len = 44100 * 10;
    sp_process(sp, &ud, process);


    return 0;