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 main() { UserData ud; sp_data *sp; sp_create(&sp); sp_clip_create(&ud.clp); sp_osc_create(&ud.osc); sp_ftbl_create(sp, &ud.ft, 4096); sp_moogladder_create(&ud.filt); sp_gen_line(sp, ud.ft, "0 1 4096 -1"); sp_osc_init(sp, ud.osc, ud.ft, 0); ud.osc->freq = sp_midi2cps(48); sp_clip_init(sp, ud.clp); sp_moogladder_init(sp, ud.filt); ud.filt->freq = 1000; ud.filt->res = 0.8; sp->len = 44100 * 5; sp_process(sp, &ud, write_clip); sp_osc_destroy(&ud.osc); sp_clip_destroy(&ud.clp); sp_ftbl_destroy(&ud.ft); sp_moogladder_destroy(&ud.filt); 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 init(int channelCount, double inSampleRate) { channels = channelCount; sampleRate = float(inSampleRate); sp_create(&sp); sp->sr = sampleRate; sp->nchan = channels; sp_clip_create(&clip); sp_clip_init(sp, clip); clip->lim = 1.0; limitRamper.init(); }