int main() { sp_data *sp; sp_create(&sp); sp_srand(sp, 12345); sp->sr = SR; sp->len = sp->sr * LEN; uint32_t t, u; SPFLOAT in = 0, out = 0; sp_clip *unit[NUM]; for(u = 0; u < NUM; u++) { sp_clip_create(&unit[u]); sp_clip_init(sp, unit[u]); } for(t = 0; t < sp->len; t++) { for(u = 0; u < NUM; u++) sp_clip_compute(sp, unit[u], &in, &out); } for(u = 0; u < NUM; u++) sp_clip_destroy(&unit[u]); sp_destroy(&sp); return 0; }
int sporth_clip(sporth_stack *stack, void *ud) { plumber_data *pd = ud; SPFLOAT in; SPFLOAT out; SPFLOAT lim; sp_clip *clip; switch(pd->mode) { case PLUMBER_CREATE: #ifdef DEBUG_MODE plumber_print(pd, "clip: Creating\n"); #endif sp_clip_create(&clip); plumber_add_ugen(pd, SPORTH_CLIP, clip); if(sporth_check_args(stack, "ff") != SPORTH_OK) { plumber_print(pd,"Not enough arguments for clip\n"); stack->error++; return PLUMBER_NOTOK; } lim = sporth_stack_pop_float(stack); in = sporth_stack_pop_float(stack); sporth_stack_push_float(stack, 0); break; case PLUMBER_INIT: #ifdef DEBUG_MODE plumber_print(pd, "clip: Initialising\n"); #endif lim = sporth_stack_pop_float(stack); in = sporth_stack_pop_float(stack); clip = pd->last->ud; sp_clip_init(pd->sp, clip); sporth_stack_push_float(stack, 0); break; case PLUMBER_COMPUTE: lim = sporth_stack_pop_float(stack); in = sporth_stack_pop_float(stack); clip = pd->last->ud; clip->lim = lim; sp_clip_compute(pd->sp, clip, &in, &out); sporth_stack_push_float(stack, out); break; case PLUMBER_DESTROY: clip = pd->last->ud; sp_clip_destroy(&clip); break; default: plumber_print(pd, "clip: Unknown mode!\n"); break; } return PLUMBER_OK; }
void process(AUAudioFrameCount frameCount, AUAudioFrameCount bufferOffset) override { for (int frameIndex = 0; frameIndex < frameCount; ++frameIndex) { int frameOffset = int(frameIndex + bufferOffset); limit = limitRamper.getAndStep(); clip->lim = (float)limit; for (int channel = 0; channel < channels; ++channel) { float *in = (float *)inBufferListPtr->mBuffers[channel].mData + frameOffset; float *out = (float *)outBufferListPtr->mBuffers[channel].mData + frameOffset; if (started) { sp_clip_compute(sp, clip, in, out); } else { *out = *in; } } } }
void write_clip(sp_data *sp, void *ud) { UserData *udp = ud; SPFLOAT out, osc, filt; if(sp->pos < (44100 * 2)) { sp_osc_compute(sp, udp->osc, NULL, &osc); sp_moogladder_compute(sp, udp->filt, &osc, &filt); sp->out[0] = filt; return; } else if(sp->pos >= (44100 * 2) && sp->pos < (44100 * 3)) { udp->clp->meth = 0; } else if(sp->pos >= (44100 * 3) && sp->pos < (44100 * 4)) { udp->clp->meth = 1; udp->clp->lim = 0.2; } else { udp->clp->meth = 2; udp->clp->lim = 0.03; } sp_osc_compute(sp, udp->osc, NULL, &osc); sp_moogladder_compute(sp, udp->filt, &osc, &filt); sp_clip_compute(sp, udp->clp, &filt, &out); sp->out[0] = out; }