Skip to content

Commit

Permalink
iirfilt: adjusting integrator gain, adding test
Browse files Browse the repository at this point in the history
  • Loading branch information
jgaeddert committed Mar 7, 2024
1 parent 32d28c7 commit 28bca17
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/filter/src/iirfilt.proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ IIRFILT() IIRFILT(_create_integrator)()
0.1641457f * cexpf(_Complex_I * M_PI / 180.0f * -21.89539f),
0.1641457f * cexpf(_Complex_I * M_PI / 180.0f * 21.89539f),
1.0f,};
// gain, digital, integrator
float complex kdi = -1.89213380759321e-05f;
// gain, digital, integrator (slight adjustment added for proper gain)
float complex kdi = -1.89213380759321e-05f / 0.9695401191711425781f;

// second-order sections
// allocate 12 values for 4 second-order sections each with
Expand Down
24 changes: 24 additions & 0 deletions src/filter/tests/iirfilt_copy_autotest.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,30 @@ void autotest_iirfilt_dcblock()
iirfilt_crcf_destroy(filter);
}

void autotest_iirfilt_integrator()
{
// options
unsigned int num_ones = 10;
unsigned int num_samples = 200;

// allocate memory for data arrays
float buf_0[num_samples]; // filter input
float buf_1[num_samples]; // filter output

// generate input signal
unsigned int i;
for (i=0; i<num_samples; i++)
buf_0[i] = i < num_ones ? 1 : 0;

// create integrator and run on sample data
iirfilt_rrrf q = iirfilt_rrrf_create_integrator();
iirfilt_rrrf_execute_block(q, buf_0, num_samples, buf_1);
iirfilt_rrrf_destroy(q);

// check that last value matches expected
CONTEND_DELTA(buf_1[num_samples-1], num_ones, 0.1f);
}

void testbench_iirfilt_copy(liquid_iirdes_format _format)
{
// create base object
Expand Down

0 comments on commit 28bca17

Please sign in to comment.