0
$\begingroup$

I have been using FIR filters for float variables, can I know how can I pass complex float variables ( complex float buf[1024] ) to the filter equations? I mean pointers to the variables of type complex float needs to be passed. I am reading complex float samples from the RTL SDR dongle and here is what I use for float samples:

void FIRFilter(float *x, int len) 
{     
 for (int k = 0; k < len; ++k) {
          float y = 0.0;
          int j = in_idx;
          bufff[in_idx] = x[k];
            
          for (int i = 0; i < n_tap; ++i) {
        if (j < 0)
          j += n_tap;
        y = y + m[i] * bufff[j--];  //mine a=coeff array
          }
          in_idx++;
          if (in_idx >= n_tap) {
        in_idx -= n_tap;
          }
          x[k] = (float)y;
        }
}
$\endgroup$
4
  • $\begingroup$ just the same. the math is identical. So, your code needs to change in nothing but the type of data you pass in and out. (I can't really follow your code, but if it works for a real filter applied to real data, it works for the same filter applied to complex data). So, what's the signal processing question here? $\endgroup$ Jan 28, 2023 at 15:01
  • $\begingroup$ I think he’s asking a coding question, in which case one answer is to pass the real part as an argument, the imaginary as another. $\endgroup$
    – Jdip
    Jan 28, 2023 at 17:20
  • $\begingroup$ I suggest that this question be migrated to StackOverflow. Whether or not it is migrated, you should edit the question to (A) say whether this is C or C++, and (B) the actual data type you're planning on using (i.e., float complex would apply in C99 and later). Note that if you're coding in C++, the best answer is probably to use a template function, and make a filter class. $\endgroup$
    – TimWescott
    Jan 28, 2023 at 23:57
  • $\begingroup$ Thanks to all. I finally did it by passing real and imaginary parts and then putting results back in respective real and imaginary parts of complex float. $\endgroup$
    – Mas
    Jan 29, 2023 at 1:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.