Hi i was just wondering if anyone knew any way to get open source FIR filter code in C or like any examples to help. any website links
Printable View
Hi i was just wondering if anyone knew any way to get open source FIR filter code in C or like any examples to help. any website links
Your basic FIR filter looks like this:
in points to an array of input values which is appropriately padded at the beginning and end to achieve the desired filter offset. out points to an array where the filter output will be stored. kernel points to an array representing the time-reversed impulse response. ksize is the size of this kernel. n is the number of elements in the input array INCLUDING any padding.Code:void FIRFilter( double *in, double *out, double *kernel, unsigned int ksize,
unsigned int n )
{
unsigned int i, j;
for( i = 0; i < n - ksize + 1; ++i )
{
out[ i ] = 0.0;
for( j = 0; j < ksize; ++j )
out[ i ] += in[ i + j ] * kernel[ j ];
}
}
The output is smaller than the input by ksize - 1 elements.
okay thanks this really helps but i have a few questions if anyone else knows about FIR filters the only thing im unsure about is the
Would u need to put this in an array if ur just continously adding to the out[] +=Code:out[ i ] += in[ i + j ] * kernel[ j ];
cuz each array is just going to be the sum + so does out really need to be an array this might be more for me understanding the FIR filter being created in C code
Actually i had a question to anyone knowing there filters in C if u have an array of
in*
if u do audio in .wav files it comes to sample sets of 2 bytes usually or 4 so if i was to filter the data in the wav file. wouldn't i just filter byte by byte or gather a whole bunch of bytes then filter