void destroy() {
     sp_oscmorph_destroy(&oscmorph);
     sp_destroy(&sp);
 }
示例#2
0
 void destroy() {
     sp_oscmorph_destroy(&oscmorph);
     AKSoundpipeKernel::destroy();
 }
示例#3
0
文件: oscmorph.c 项目: Luckyncl/3rd
int sporth_oscmorph4(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;
    SPFLOAT out;
    sporth_oscmorph *oscmorph;

    switch(pd->mode) {
        case PLUMBER_CREATE:

#ifdef DEBUG_MODE
            fprintf(stderr, "oscmorph: Creating\n");
#endif
            oscmorph = malloc(sizeof(sporth_oscmorph));
            sp_oscmorph_create(&oscmorph->data);
            oscmorph->nft = 4;
            oscmorph->ft = malloc(sizeof(sp_ftbl *) * 4);
            oscmorph->ftname = malloc(sizeof(char *) * 4);
            plumber_add_ugen(pd, SPORTH_OSCMORPH4, oscmorph);

            if(sporth_check_args(stack, "ffffssss") != SPORTH_OK) {
                fprintf(stderr,"Not enough arguments for oscmorph\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }

            get_strings(stack, oscmorph);
            pop_args(stack, oscmorph);

            if(search_for_ft(pd, oscmorph) == PLUMBER_NOTOK) {
                stack->error++;
                return PLUMBER_NOTOK;
            }

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

#ifdef DEBUG_MODE
            fprintf(stderr, "oscmorph: Initialising\n");
#endif

            oscmorph = pd->last->ud;
            get_strings(stack, oscmorph);

            pop_args(stack, oscmorph);

            sp_oscmorph_init(pd->sp, oscmorph->data, oscmorph->ft, oscmorph->nft, oscmorph->phase);

            sporth_stack_push_float(stack, 0);
            free_strings(oscmorph);
            break;
        case PLUMBER_COMPUTE:
            oscmorph = pd->last->ud;
            pop_args(stack, oscmorph);
            
            set_args(oscmorph);

            sp_oscmorph_compute(pd->sp, oscmorph->data, NULL, &out);
            sporth_stack_push_float(stack, out);
            break;
        case PLUMBER_DESTROY:
            oscmorph = pd->last->ud;
            free(oscmorph->ftname);
            free(oscmorph->ft);
            sp_oscmorph_destroy(&oscmorph->data);
            free(oscmorph);
            break;
        default:
            fprintf(stderr, "oscmorph: Unknown mode!\n");
            break;
    }
    return PLUMBER_OK;
}