ref: 25a9fcc24ad00c6a406042818b9e6f2e7bba0dd1
dir: /modules/slice.c/
/* This code is placed in the public domain. */ #include <stdlib.h> #include "soundpipe.h" int sp_slice_create(sp_slice **p) { *p = malloc(sizeof(sp_slice)); return SP_OK; } int sp_slice_destroy(sp_slice **p) { free(*p); return SP_OK; } int sp_slice_init(sp_data *sp, sp_slice *p, sp_ftbl *vals, sp_ftbl *buf) { USED(sp); p->vals = vals; p->buf = buf; p->pos = 0; p->nextpos = 0; p->id = 0; return SP_OK; } int sp_slice_compute(sp_data *sp, sp_slice *p, SPFLOAT *in, SPFLOAT *out) { USED(sp); *out = 0; if(*in != 0) { if(p->id < p->vals->size) { p->pos = p->vals->tbl[p->id]; if(p->id == p->vals->size - 1) { p->nextpos = p->buf->size; } else { p->nextpos = p->vals->tbl[p->id + 1]; } } } if(p->pos < p->nextpos) { *out = p->buf->tbl[p->pos]; p->pos++; } return SP_OK; }