gbuzz

Files: gbuzz.h, gbuzz.c

Series of partials from the harmonic series
GBuzz comes from the "buzz" family of Csound opcodes, and is capable of producing a rich spectrum of harmonic content, useful for subtractive synthesis implementation.

Functions

sp_gbuzz_create(sp_gbuzz **gbuzz)
sp_gbuzz_init(sp_data *sp, sp_gbuzz *gbuzz, sp_ftbl *ft, SPFLOAT iphs)
sp_gbuzz_compute(sp_data *sp, sp_gbuzz *gbuzz, SPFLOAT *in, SPFLOAT *out)
sp_gbuzz_destroy(sp_gbuzz **gbuzz)

Mandatory Parameters

ft: Soundpipe function table used internally. This should be a sine wave.
(Recommended value: N/A)
iphs: Phase to start on (in the range 0-1)
(Recommended value: 0)

Optional Parameters

freq: Frequency, in Hertz.
(Default value: 440)
amp: Amplitude (Typically a value between 0 and 1).
(Default value: 0.4)
nharm: Number of harmonics.
(Default value: 4)
lharm: Lowest harmonic present. This should be a whole number integer.
(Default value: 0)
mul: Multiplier. This determines the relative strength of each harmonic.
(Default value: 0.1)

Outputs

out: Signal output

Example Code

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

typedef struct {
    sp_gbuzz *buzz;
    sp_ftbl *ft; 
    int counter;
} UserData;

void process(sp_data *sp, void *udata) {
    UserData *ud = udata;
    sp_gbuzz_compute(sp, ud->buzz, NULL, &sp->out[0]);
}

int main() {
    srand(time(NULL));
    UserData ud;
    sp_data *sp;
    sp_create(&sp);
    sp_ftbl_create(sp, &ud.ft, 2048);
    sp_gbuzz_create(&ud.buzz);

    sp_gen_sine(sp, ud.ft);
    sp_gbuzz_init(sp, ud.buzz, ud.ft, 0);
    sp->len = 44100 * 5;
    sp_process(sp, &ud, process);

    sp_ftbl_destroy(&ud.ft);
    sp_gbuzz_destroy(&ud.buzz);
    sp_destroy(&sp);
    return 0;
}