gen_sinesum

Files: ftbl.h, ftbl.c

Waveform as a sum of harmonically related sine waves

Functions

sp_gen_sinesum(sp_data *sp, sp_ftbl *ft , char *argstring)

Parameters

argstring: A list of amplitudes, in the range 0-1, separated by spaces.Each position coordinates to their partial number. Position 1 is the fundamental amplitude (1 * freq). Position 2 is the first overtone (2 * freq), 3 is the second (3 * freq), etc...
(Recommended value: 1 0.5 0.25)

Example Code

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

int main() {
    sp_data *sp;
    sp_create(&sp);
    sp_ftbl *ft;
    sp_ftbl_create(sp, &ft, 4096);
    sp_gen_sinesum(sp, ft, "1 0.5 0.25");
    int i;
    FILE *fp= fopen("plot.dat", "w");
    for(i = 0; i < ft->size; i++) {
        fprintf(fp, "%d %g\n", i, ft->tbl[i]);
    }
    printf("%d plot points written to plot.dat. Run write_plot.sh to see the result.\n", ft->size); 
    fclose(fp);
    sp_ftbl_destroy(&ft);
    sp_destroy(&sp);
    return 0;
}