void init(int channelCount, double inSampleRate) {
        channels = channelCount;

        sampleRate = float(inSampleRate);

        sp_create(&sp);
        sp->sr = sampleRate;
        sp->nchan = channels;
        sp_oscmorph_create(&oscmorph);

    }
示例#2
0
    void init(int _channels, double _sampleRate) override {
        AKSoundpipeKernel::init(_channels, _sampleRate);

        sp_oscmorph_create(&oscmorph);

        frequencyRamper.init();
        amplitudeRamper.init();
        indexRamper.init();
        detuningOffsetRamper.init();
        detuningMultiplierRamper.init();
    }
示例#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;
}