int sp_revsc_init(sp_data *sp, sp_revsc *p) { p->iSampleRate = sp->sr; p->sampleRate = sp->sr; p->feedback = 0.97; p->lpfreq = 10000; p->iPitchMod = 1; p->iSkipInit = 0; p->dampFact = 1.0; p->prv_LPFreq = 0.0; p->initDone = 1; int i, nBytes = 0; for(i = 0; i < 8; i++){ nBytes += delay_line_bytes_alloc(sp->sr, 1, i); } sp_auxdata_alloc(&p->aux, nBytes); nBytes = 0; for (i = 0; i < 8; i++) { p->delayLines[i].buf = (p->aux.ptr) + nBytes; init_delay_line(p, &p->delayLines[i], i); nBytes += delay_line_bytes_alloc(sp->sr, 1, i); } return SP_OK; }
int sp_reverse_init(sp_data *sp, sp_reverse *p, SPFLOAT delay) { size_t size = delay * sp->sr * sizeof(SPFLOAT) * 2; p->bufpos = 0; sp_auxdata_alloc(&p->buf, size); p->bufsize = p->buf.size / sizeof(SPFLOAT); return SP_OK; }
int sp_vdelay_init(sp_data *sp, sp_vdelay *p, SPFLOAT maxdel) { uint32_t n = (int32_t)(maxdel * sp->sr)+1; p->sr = sp->sr; p->del = maxdel * 0.5; p->maxdel = maxdel; sp_auxdata_alloc(&p->buf, n * sizeof(SPFLOAT)); p->left = 0; return SP_OK; }
int sp_allpass_init(sp_data *sp, sp_allpass *p, SPFLOAT looptime) { p->revtime = 3.5; p->looptime = looptime; p->bufsize = 0.5 + looptime * sp->sr; sp_auxdata_alloc(&p->aux, p->bufsize * sizeof(SPFLOAT)); p->prvt = 0.0; p->coef = 0.0; p->bufpos = 0; return SP_OK; }
int sp_waveset_init(sp_data *sp, sp_waveset *p, SPFLOAT ilen) { p->length = 1 + (sp->sr * ilen); sp_auxdata_alloc(&p->auxch, p->length * sizeof(SPFLOAT)); p->cnt = 1; p->start = 0; p->current = 0; p->end = 0; p->direction = 1; p->lastsamp = 1.0; p->noinsert = 0; return SP_OK; }
int sp_smoothdelay_init(sp_data *sp, sp_smoothdelay *p, SPFLOAT maxdel, uint32_t interp) { uint32_t n = (int32_t)(maxdel * sp->sr)+1; p->sr = sp->sr; p->del = maxdel * 0.5; p->pdel = -1; p->maxdel = maxdel; p->feedback = 0; p->maxbuf = n - 1; p->maxcount = interp; sp_auxdata_alloc(&p->buf1, n * sizeof(SPFLOAT)); p->bufpos1 = 0; p->deltime1 = (uint32_t) (p->del * sp->sr); sp_auxdata_alloc(&p->buf2, n * sizeof(SPFLOAT)); p->bufpos2 = 0; p->deltime2 = p->deltime1; p->counter = 0; p->curbuf = 0; return SP_OK; }
int sp_spa_init(sp_data *sp, sp_spa *p, const char *filename) { if(spa_open(sp, &p->spa, filename, SPA_READ) != SP_OK) { return SP_NOT_OK; } p->pos = 0; p->bufsize = SPA_BUFSIZE; sp_auxdata_alloc(&p->aux, sizeof(SPFLOAT) * p->bufsize); p->buf = p->aux.ptr; return SP_OK; }
int sp_mincer_init(sp_data *sp, sp_mincer *p, sp_ftbl *ft) { p->ft = ft; p->idecim = 4; p->iN = 2048; p->lock = 1; p->pitch = 1; p->amp = 1; p->time = 0; int N = p->iN, ui; unsigned int size; int decim = p->idecim; /* 2^11 = 2048, the default fftsize, will probably not change */ sp_fft_init(&p->fft, 11); if (decim == 0) decim = 4; p->hsize = N/decim; p->cnt = p->hsize; p->curframe = 0; p->pos = 0; size = (N+2)*sizeof(SPFLOAT); sp_auxdata_alloc(&p->fwin, size); sp_auxdata_alloc(&p->bwin, size); sp_auxdata_alloc(&p->prev, size); size = decim*sizeof(int); sp_auxdata_alloc(&p->framecount, size); { int k=0; for (k=0; k < decim; k++) { ((int *)(p->framecount.ptr))[k] = k*N; } } size = decim*sizeof(SPFLOAT)*N; sp_auxdata_alloc(&p->outframe, size); size = N*sizeof(SPFLOAT); sp_auxdata_alloc(&p->win, size); { SPFLOAT x = 2.0 * M_PI/N; for (ui=0; ui < N; ui++) ((SPFLOAT *)p->win.ptr)[ui] = 0.5 - 0.5 * cos((SPFLOAT)ui*x); } p->N = N; p->decim = decim; return SP_OK; }
int sp_pluck_init(sp_data *sp, sp_pluck *p, SPFLOAT ifreq) { int32_t npts; p->amp = 0.5; p->ifreq = ifreq; p->freq = ifreq; if ((npts = (int32_t)(sp->sr / p->ifreq)) < PLUKMIN) { npts = PLUKMIN; } sp_auxdata_alloc(&p->auxch, (npts + 1) * sizeof(SPFLOAT)); p->maxpts = npts; p->npts = npts; sp_pluck_reinit(sp, p); /* tuned pitch convt */ p->sicps = (npts * 256.0 + 128.0) * (1.0 / sp->sr); return SP_OK; }