Exemplo n.º 1
0
Error_t
DecimatorProcessD(DecimatorD*   decimator,
                  double*       outBuffer,
                  const double* inBuffer,
                  unsigned      n_samples)
{
    if (decimator && outBuffer)
    {
        unsigned declen = n_samples / decimator->factor;
        double temp_buf[declen];
        ClearBufferD(outBuffer, declen);

        for (unsigned filt = 0; filt < decimator->factor; ++filt)
        {
            CopyBufferStrideD(temp_buf, 1, inBuffer, decimator->factor, declen);
            FIRFilterProcessD(decimator->polyphase[filt], temp_buf, temp_buf, declen);
            VectorVectorAddD(outBuffer, (const double*)outBuffer, temp_buf, declen);
        }
        return NOERR;
    }
    else
    {
        return NULL_PTR_ERROR;
    }
}
Exemplo n.º 2
0
BiquadFilterD*
BiquadFilterInitD(const double  *bCoeff, const double  *aCoeff)
{

    // Allocate Memory
    BiquadFilterD* filter = (BiquadFilterD*)malloc(sizeof(BiquadFilterD));

    if (filter)
    {
        // Initialize Buffers
        CopyBufferD(filter->b, bCoeff, 3);
        CopyBufferD(filter->a, aCoeff, 2);

        ClearBufferD(filter->x, 2);
        ClearBufferD(filter->y, 2);
        ClearBufferD(filter->w, 2);
    }
    return filter;
}
Exemplo n.º 3
0
TEST(DSPDouble, TestStrideCopy)
{
    double out[10];
    double in1[5] = {1.,2.,3.,4.,5.};
    double in2[10] = {1., 2., 3., 4., 5., 6., 7., 8., 9., 10.};
    double ex1[10] = {1., 0., 2., 0., 3., 0., 4., 0., 5., 0.};
    double ex2[5] = {1., 3., 5., 7., 9.};
    
    ClearBufferD(out, 10);
    CopyBufferStrideD(out, 2, in1, 1, 5);
    for (unsigned i = 0; i < 10; ++i)
    {
        ASSERT_DOUBLE_EQ(ex1[i], out[i]);
    }
    
    ClearBufferD(out, 10);
    CopyBufferStrideD(out, 1, in2, 2, 5);
    for (unsigned i = 0; i < 5; ++i)
    {
        ASSERT_DOUBLE_EQ(ex2[i], out[i]);
    }
}
Exemplo n.º 4
0
TEST(DSPDouble, TestClearBuffer)
{
    double out[10];
    for (unsigned i = 0; i < 10; ++i)
    {
        out[i] = i;
    }
    ClearBufferD(out, 10);
    for (unsigned i = 0; i < 10; ++i)
    {
        ASSERT_DOUBLE_EQ(0.0, out[i]);
    }
}