AnsweredAssumed Answered

Trouble adding FIR filter to example program

Question asked by klhett on Jun 20, 2011
Latest reply on Jun 21, 2011 by Mitesh

I am trying to build a simple application that will allow me to test sets of various filter coefficients.

 

To do this, I am modifying the SPDIFToAnalogTalkthrough example code to run on a 21489 EZKit eval board.

 

This example has a function named processBlock(unsigned int *block_ptr).  The original example code just copies the block_ptr back into block_ptr.

What I would like to do is to insert a call to the fir() function in this method.

The problem that I'm running into is that the input vector for the fir() function is of type float[].

 

I found other example code that uses the compiler to cast unsigned int -> float.

However, the code to convert from float -> int causes the output buffer array to be 2x the size of the input.

 

The example code for converting between float and int is below:

 

void  fix2float(unsigned int dummy1[], float dummy2[], int size )
{
     int i;
     for(i=0; i<size; i++)
     {
          dummy2[i] = dummy1[i];
     }
}

void  float2fix(float dummy1[], unsigned int dummy2[], int size)
{
int i;
int j = 0;
for(i=0; i<size; i++)
{
asm("%0 = FIX %1;"
      : "=d" (dummy2[j])          //copy dummy1[i] to dummy2[j]
      : "F" (dummy1[i])    
       );
 
        asm("%0 = FIX %1;"
      : "=d" (dummy2[j + 1])     //copy dummy1[i] to dummy2[j + 1]
      : "F" (dummy1[i])
       );
                    
       j = j + 1;           
}
}
I would expect that you should be able to take in a vector of type unsigned int, filter that vector, and then output that vector of data to the output codec.
Is there another way to convert from float->int that does not inflate the output array size?
Is the a better way to do this kind of filtering?
Any input or advice is greatly appreciated.
Thanks in advance,
Kristopher

Outcomes