Ejemplo n.º 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_dcblock *unit[NUM];

    for(u = 0; u < NUM; u++) { 
        sp_dcblock_create(&unit[u]);
        sp_dcblock_init(sp, unit[u]);
    }

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

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

    sp_destroy(&sp);
    return 0;
}
Ejemplo n.º 2
0
void growl_compute(sp_data *sp, growl_d *form, SPFLOAT *in, SPFLOAT *out)
{
    int i;
    SPFLOAT tmp_in = *in;
    SPFLOAT tmp_out = *in;
    SPFLOAT tf = 0.0;
    SPFLOAT bf = 0.0;
    SPFLOAT freq = 0.0;
    SPFLOAT *x = &form->x;
    SPFLOAT *y = &form->y;
//    *out = 0.0;
//
    for(i = 0; i < 4; i++) {
        tf = (*x) *
            (formants[i + 3] - formants[i]) +
            formants[i];
        bf = (*x) *
            (formants[i + 11] - formants[i + 7]) +
            formants[i + 7];
        freq = (*y) * (bf - tf) + tf;
        form->filt[i]->freq = freq;
        form->filt[i]->bw =
            ((freq * 0.02) + 50);
        sp_reson_compute(sp, form->filt[i], &tmp_in, &tmp_out);
        tmp_in = tmp_out;
    }
    *out = *in;
    sp_bal_compute(sp, form->bal, &tmp_out, in, out);
    tmp_out = *out;
    sp_dcblock_compute(sp, form->dcblk, &tmp_out, out);
}
Ejemplo n.º 3
0
    void process(AUAudioFrameCount frameCount, AUAudioFrameCount bufferOffset) override {
        // For each sample.
        for (int frameIndex = 0; frameIndex < frameCount; ++frameIndex) {

            int frameOffset = int(frameIndex + bufferOffset);

            if (!started) {
                outBufferListPtr->mBuffers[0] = inBufferListPtr->mBuffers[0];
                outBufferListPtr->mBuffers[1] = inBufferListPtr->mBuffers[1];
                return;
            }
            for (int channel = 0; channel < channels; ++channel) {
                float *in  = (float *)inBufferListPtr->mBuffers[channel].mData  + frameOffset;
                float *out = (float *)outBufferListPtr->mBuffers[channel].mData + frameOffset;

                sp_dcblock_compute(sp, dcblock, in, out);
            }
        }
    }
Ejemplo n.º 4
0
    void process(AUAudioFrameCount frameCount, AUAudioFrameCount bufferOffset) override {

        for (int frameIndex = 0; frameIndex < frameCount; ++frameIndex) {

            int frameOffset = int(frameIndex + bufferOffset);


            for (int channel = 0; channel < channels; ++channel) {
                float *in  = (float *)inBufferListPtr->mBuffers[channel].mData  + frameOffset;
                float *out = (float *)outBufferListPtr->mBuffers[channel].mData + frameOffset;

                if (started) {
                    sp_dcblock_compute(sp, dcblock, in, out);
                } else {
                    *out = *in;
                }
            }
        }
    }