ref: 25a9fcc24ad00c6a406042818b9e6f2e7bba0dd1
dir: /modules/tblrec.c/
/* This code is placed in the public domain. */ #include <stdlib.h> #include <string.h> #include "soundpipe.h" int sp_tblrec_create(sp_tblrec **p) { *p = malloc(sizeof(sp_tblrec)); return SP_OK; } int sp_tblrec_destroy(sp_tblrec **p) { free(*p); return SP_OK; } int sp_tblrec_init(sp_data *sp, sp_tblrec *p, sp_ftbl *ft) { USED(sp); p->index = 0; p->record = 0; p->ft = ft; return SP_OK; } int sp_tblrec_compute(sp_data *sp, sp_tblrec *p, SPFLOAT *in, SPFLOAT *trig, SPFLOAT *out) { USED(sp); if(*trig != 0) { if(p->record == 1) { p->record = 0; } else { p->record = 1; p->index = 0; memset(p->ft->tbl, 0, sizeof(SPFLOAT) * p->ft->size); } } if(p->record) { p->ft->tbl[p->index] = *in; p->index = (p->index + 1) % p->ft->size; } *out = *in; return SP_OK; }