Forum: GNU Radio I think I solved a bug in gri_iir.h

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
3719f4fea703e38bcbf8de6fe6bcdf55?d=identicon&s=25 Martin Dvh (Guest)
on 2007-07-13 19:24
(Received via mailing list)
Hi all,
I think I solved a bug in gri_iir.h
I think the index numbers are wrong when you decrement the latest_n and
latest_m after you set prev_output and prev_input.
I created a simple standalone program to test the index numbers.
The patch and the test program are at:
http://www.olifantasia.com/pub/projects/gnuradio/m...

Because these things are tricky to understand I would appreciate some
feedback if the algorithm is correct now.
If it is, let me know and I can apply the patch.

I think gri_iir is only used in gr_iir_filter_ffd which is only used in
the emphasis filter of the wfm modulator.
And there it isn't even used properly because the filter taps are not
set.


Greetings,
Martin

Index: gri_iir.h
===================================================================
--- gri_iir.h  (revision 5766)
+++ gri_iir.h  (working copy)
@@ -143,12 +143,6 @@
   for (i = 1; i < m; i ++)
     acc += (d_fbtaps[i] * d_prev_output[latest_m + i]);

-  // store the values twice to avoid having to handle wrap-around in
the loop
-  d_prev_output[latest_m] = acc;
-  d_prev_output[latest_m+m] = acc;
-  d_prev_input[latest_n] = input;
-  d_prev_input[latest_n+n] = input;
-
   latest_n--;
   latest_m--;
   if (latest_n < 0)
@@ -156,6 +150,13 @@
   if (latest_m < 0)
     latest_m += m;

+  // store the values twice to avoid having to handle wrap-around in
the loop
+  d_prev_output[latest_m] = acc;
+  d_prev_output[latest_m+m] = acc;
+  d_prev_input[latest_n] = input;
+  d_prev_input[latest_n+n] = input;
+
+
   d_latest_m = latest_m;
   d_latest_n = latest_n;
   return (o_type) acc;
This topic is locked and can not be replied to.