Exemplo n.º 1
0
    void init(int _channels, double _sampleRate) override {
        AKSoundpipeKernel::init(_channels, _sampleRate);

        sp_moogladder_create(&moogladder0);
        sp_moogladder_create(&moogladder1);
        sp_moogladder_init(sp, moogladder0);
        sp_moogladder_init(sp, moogladder1);
        moogladder0->freq = 1000;
        moogladder1->freq = 1000;
        moogladder0->res = 0.5;
        moogladder1->res = 0.5;

        cutoffFrequencyRamper.init();
        resonanceRamper.init();
    }
Exemplo n.º 2
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;
}
Exemplo n.º 3
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;
}
Exemplo n.º 4
0
    void init(int channelCount, double inSampleRate) {
        channels = channelCount;

        sampleRate = float(inSampleRate);

        sp_create(&sp);
        sp->sr = sampleRate;
        sp->nchan = channels;
        sp_moogladder_create(&moogladder);
        sp_moogladder_init(sp, moogladder);
        moogladder->freq = 1000;
        moogladder->res = 0.5;
    }
Exemplo n.º 5
0
    void init(int channelCount, double inSampleRate) {
        channels = channelCount;

        sampleRate = float(inSampleRate);

        sp_create(&sp);
        sp->sr = sampleRate;
        sp->nchan = channels;
        sp_moogladder_create(&moogladder);
        sp_moogladder_init(sp, moogladder);
        moogladder->freq = 1000;
        moogladder->res = 0.5;

        cutoffFrequencyRamper.init();
        resonanceRamper.init();
    }