Fir filter

This is a discussion on Fir filter within the C Programming forums, part of the General Programming Boards category; Hi i was just wondering if anyone knew any way to get open source FIR filter code in C or ...

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    192

    Fir filter

    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

  2. #2
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,160
    Quote Originally Posted by kiros88 View Post
    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:

    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 ];
        }
    }
    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.

    The output is smaller than the input by ksize - 1 elements.
    Last edited by brewbuck; 06-04-2010 at 09:17 PM. Reason: Said "bytes" instead of "elements" in a few places
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  3. #3
    Registered User
    Join Date
    Aug 2009
    Posts
    192
    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
    Code:
    out[ i ] += in[ i + j ] * kernel[ j ];
    Would u need to put this in an array if ur just continously adding to the out[] +=
    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

  4. #4
    Registered User
    Join Date
    Aug 2009
    Posts
    192
    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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Gabor Filter in C#
    By nanang in forum C# Programming
    Replies: 0
    Last Post: 05-17-2009, 08:22 PM
  2. Trouble adding source filter for WMV
    By abachler in forum Windows Programming
    Replies: 2
    Last Post: 07-03-2008, 08:38 AM
  3. Replies: 1
    Last Post: 12-30-2007, 09:08 AM
  4. "Multiple Filter Randoms"
    By gnimblegnome in forum C++ Programming
    Replies: 3
    Last Post: 10-28-2007, 12:24 PM
  5. Simple Filter
    By 00Sven in forum C Programming
    Replies: 3
    Last Post: 03-14-2006, 07:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21