Beispiel #1
0
int sporth_moogladder(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;
    SPFLOAT input;
    SPFLOAT out;
    SPFLOAT freq;
    SPFLOAT res;
    sp_moogladder *moogladder;

    switch(pd->mode) {
        case PLUMBER_CREATE:

#ifdef DEBUG_MODE
            fprintf(stderr, "moogladder: Creating\n");
#endif

            sp_moogladder_create(&moogladder);
            plumber_add_ugen(pd, SPORTH_MOOGLADDER, moogladder);
            if(sporth_check_args(stack, "fff") != SPORTH_OK) {
                fprintf(stderr,"Not enough arguments for moogladder\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            res = sporth_stack_pop_float(stack);
            freq = sporth_stack_pop_float(stack);
            input = sporth_stack_pop_float(stack);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_INIT:

#ifdef DEBUG_MODE
            fprintf(stderr, "moogladder: Initialising\n");
#endif
            res = sporth_stack_pop_float(stack);
            freq = sporth_stack_pop_float(stack);
            input = sporth_stack_pop_float(stack);
            moogladder = pd->last->ud;
            sp_moogladder_init(pd->sp, moogladder);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_COMPUTE:
            res = sporth_stack_pop_float(stack);
            freq = sporth_stack_pop_float(stack);
            input = sporth_stack_pop_float(stack);
            moogladder = pd->last->ud;
            moogladder->freq = freq;
            moogladder->res = res;
            sp_moogladder_compute(pd->sp, moogladder, &input, &out);
            sporth_stack_push_float(stack, out);
            break;
        case PLUMBER_DESTROY:
            moogladder = pd->last->ud;
            sp_moogladder_destroy(&moogladder);
            break;
        default:
            fprintf(stderr, "moogladder: Unknown mode!\n");
            break;
    }
    return PLUMBER_OK;
}
Beispiel #2
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;
}
 void destroy() {
     sp_moogladder_destroy(&moogladder0);
     sp_moogladder_destroy(&moogladder1);
     AKSoundpipeKernel::destroy();
 }
 void destroy() {
     sp_moogladder_destroy(&moogladder);
     sp_destroy(&sp);
 }