Пример #1
0
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_mincer *unit[NUM];
    sp_ftbl *wav;

    sp_ftbl_loadfile(sp, &wav, SAMPDIR "oneart.wav");

    for(u = 0; u < NUM; u++) { 
        sp_mincer_create(&unit[u]);
        sp_mincer_init(sp, unit[u], wav, 2048);
    }

    for(t = 0; t < sp->len; t++) {
        for(u = 0; u < NUM; u++) sp_mincer_compute(sp, unit[u], &in, &out);
    }

    for(u = 0; u < NUM; u++) sp_mincer_destroy(&unit[u]);

    sp_destroy(&sp);
    sp_ftbl_destroy(&wav);
    return 0;
}
Пример #2
0
int main() {
    UserData ud;
    sp_data *sp;
    sp_create(&sp);
    sp_srand(sp, 1234567);

    sp_mincer_create(&ud.mincer);
    /* allocates loads an audio file into a ftable */
    sp_ftbl_loadfile(sp, &ud.ft, "oneart.wav");

    sp_randi_create(&ud.randi);

    sp_mincer_init(sp, ud.mincer, ud.ft);
    sp_randi_init(sp, ud.randi);
    ud.randi->min = 0;
    ud.randi->max = 5;
    ud.randi->cps = 1;

    sp->len = 44100 * 5;
    sp_process(sp, &ud, process);

    sp_mincer_destroy(&ud.mincer);
    sp_ftbl_destroy(&ud.ft);
    sp_randi_destroy(&ud.randi);

    sp_destroy(&sp);
    return 0;
}
Пример #3
0
int sporth_mincer(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;
    SPFLOAT out = 0;
    sp_ftbl * ft = NULL;
    const char *ftname = NULL;
    SPFLOAT time = 0;
    SPFLOAT amp = 0;
    SPFLOAT pitch = 0;
    SPFLOAT winsize = 0;
    sp_mincer *mincer = NULL;

    switch(pd->mode) {
        case PLUMBER_CREATE:

#ifdef DEBUG_MODE
            plumber_print(pd, "mincer: Creating\n");
#endif

            sp_mincer_create(&mincer);
            plumber_add_ugen(pd, SPORTH_MINCER, mincer);

            if(sporth_check_args(stack, "ffffs") != SPORTH_OK) {
                plumber_print(pd,"Not enough arguments for mincer\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }

            ftname = sporth_stack_pop_string(stack);
            winsize = sporth_stack_pop_float(stack);
            pitch = sporth_stack_pop_float(stack);
            amp = sporth_stack_pop_float(stack);
            time = sporth_stack_pop_float(stack);

            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_INIT:

#ifdef DEBUG_MODE
            plumber_print(pd, "mincer: Initialising\n");
#endif

            ftname = sporth_stack_pop_string(stack);
            winsize = sporth_stack_pop_float(stack);
            pitch = sporth_stack_pop_float(stack);
            amp = sporth_stack_pop_float(stack);
            time = sporth_stack_pop_float(stack);
            mincer = pd->last->ud;

            if(plumber_ftmap_search(pd, ftname, &ft) == PLUMBER_NOTOK) {
                stack->error++;
                return PLUMBER_NOTOK;
            }

            sp_mincer_init(pd->sp, mincer, ft, winsize);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_COMPUTE:
            winsize = sporth_stack_pop_float(stack);
            pitch = sporth_stack_pop_float(stack);
            amp = sporth_stack_pop_float(stack);
            time = sporth_stack_pop_float(stack);
            mincer = pd->last->ud;
            mincer->time = time;
            mincer->amp = amp;
            mincer->pitch = pitch;
            sp_mincer_compute(pd->sp, mincer, NULL, &out);
            sporth_stack_push_float(stack, out);
            break;
        case PLUMBER_DESTROY:
            mincer = pd->last->ud;
            sp_mincer_destroy(&mincer);
            break;
        default:
            plumber_print(pd, "mincer: Unknown mode!\n");
            break;
    }
    return PLUMBER_OK;
}
 void destroy() {
     sp_mincer_destroy(&mincer);
     sp_destroy(&sp);
 }