void init() {
     sp_adsr_create(&adsr);
     sp_adsr_init(kernel->sp, adsr);
     sp_blsquare_create(&blsquare);
     sp_blsquare_init(kernel->sp, blsquare);
     *blsquare->freq = 0;
     *blsquare->amp = 0;
     *blsquare->width = 0.5;
 }
    void init(int channelCount, double inSampleRate) {
        channels = channelCount;

        sampleRate = float(inSampleRate);

        sp_create(&sp);
        sp->sr = sampleRate;
        sp->nchan = channels;
        sp_blsquare_create(&blsquare);
        sp_blsquare_init(sp, blsquare);
        *blsquare->freq = 440;
        *blsquare->amp = 1.0;
        *blsquare->width = 0.5;
    }
    void init(int channelCount, double inSampleRate) {
        channels = channelCount;

        sampleRate = float(inSampleRate);

        sp_create(&sp);
        sp->sr = sampleRate;
        sp->nchan = channels;
        sp_blsquare_create(&blsquare);
        sp_blsquare_init(sp, blsquare);
        *blsquare->freq = 440;
        *blsquare->amp = 1.0;
        *blsquare->width = 0.5;

        frequencyRamper.init();
        amplitudeRamper.init();
        pulseWidthRamper.init();
        detuningOffsetRamper.init();
        detuningMultiplierRamper.init();
    }
Exemple #4
0
int sporth_blsquare(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;
    SPFLOAT out;
    SPFLOAT freq;
    SPFLOAT amp;
    SPFLOAT width;
    sp_blsquare *blsquare;

    switch(pd->mode) {
        case PLUMBER_CREATE:

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

            sp_blsquare_create(&blsquare);
            plumber_add_ugen(pd, SPORTH_SQUARE, blsquare);
            if(sporth_check_args(stack, "fff") != SPORTH_OK) {
                fprintf(stderr,"Not enough arguments for blsquare\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            width = sporth_stack_pop_float(stack);
            amp = sporth_stack_pop_float(stack);
            freq = sporth_stack_pop_float(stack);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_INIT:

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

            width = sporth_stack_pop_float(stack);
            amp = sporth_stack_pop_float(stack);
            freq = sporth_stack_pop_float(stack);
            blsquare = pd->last->ud;
            sp_blsquare_init(pd->sp, blsquare);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_COMPUTE:
            if(sporth_check_args(stack, "fff") != SPORTH_OK) {
                fprintf(stderr,"Not enough arguments for blsquare\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            width = sporth_stack_pop_float(stack);
            amp = sporth_stack_pop_float(stack);
            freq = sporth_stack_pop_float(stack);
            blsquare = pd->last->ud;
            *blsquare->freq = freq;
            *blsquare->amp = amp;
            *blsquare->width = width;
            sp_blsquare_compute(pd->sp, blsquare, NULL, &out);
            sporth_stack_push_float(stack, out);
            break;
        case PLUMBER_DESTROY:
            blsquare = pd->last->ud;
            sp_blsquare_destroy(&blsquare);
            break;
        default:
            fprintf(stderr, "blsquare: Uknown mode!\n");
            break;
    }
    return PLUMBER_OK;
}
 NoteState() {
     sp_blsquare_create(&blsquare);
 }