Example #1
0
int t_butbr(sp_test *tst, sp_data *sp, const char *hash) 
{
    uint32_t n;
    int fail = 0;
    SPFLOAT noise = 0, butbr = 0;
    UserData ud;

    sp_butbr_create(&ud.butbr);
    sp_noise_create(&ud.ns);

    sp_butbr_init(sp, ud.butbr);
    sp_noise_init(sp, ud.ns);

    for(n = 0; n < tst->size; n++) {
        noise = 0, butbr = 0;
        sp_noise_compute(sp, ud.ns, NULL, &noise);
        sp_butbr_compute(sp, ud.butbr, &noise, &butbr);
        sp_test_add_sample(tst, butbr);
    }

    if(sp_test_compare(tst, hash) == SP_NOT_OK) {
        printf("Generated hash %s does not match reference hash %s\n", 
                tst->md5string, hash);
        fail = 1;
    }
    
    sp_butbr_destroy(&ud.butbr);
    sp_noise_destroy(&ud.ns);
     
    if(fail) return SP_NOT_OK;
    else return SP_OK;
}
    void process(AUAudioFrameCount frameCount, AUAudioFrameCount bufferOffset) override {
        // For each sample.
        for (int frameIndex = 0; frameIndex < frameCount; ++frameIndex) {
            double centerFrequency = double(centerFrequencyRamper.getStep());
            double bandwidth = double(bandwidthRamper.getStep());

            int frameOffset = int(frameIndex + bufferOffset);

            butbr->freq = (float)centerFrequency;
            butbr->bw = (float)bandwidth;

            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_butbr_compute(sp, butbr, in, out);
            }
        }
    }