473,404 Members | 2,174 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

fir filter buffer issue in C

Hi I've been trying to write a function to perform fir filtering with a buffer in C and am having trouble with the output. My filter coefficients were generated in MATLAB with 29 taps and I'm trying to multiply and accumulate with an input signal of 1400 samples. After the 29th calculation, the results are inaccurate and I'm not sure how to alleivate the issue.

My programming skills in C are very poor and any assistance would be greatly appreciated. Below is my source code for the function:

*Note iIndex is the # of rows in the signal = 1400
float filterdata(int iIndex, float signal[], float filtercoeffs[])
{
int m;
float accum;

/* calc FIR */
accum = 0;
for (m = 0; m < iIndex;m++) {
accum += filtercoeffs[m] * signal[m];
}

/* shift delay line */
for (m = iIndex - 2; m >= 0; m--) {
signal[m + 1] = signal[m];
}
return accum;
}
Dec 5 '07 #1
1 2662
weaknessforcats
9,208 Expert Mod 8TB
What do you mean by inaccurate?? A float has only 6 significant digits so you may be encountering round-off error.

Also, this code:
accum += filtercoeffs[m] * signal[m];
assumes there are 1400 filtercoeffs. Is that true?? If not, your are suffering from an array out-of-bounds error.
Dec 5 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Lou | last post by:
I'm using the Response Filter Class in MS KB article 811162 (http://support.microsoft.com/default.aspx?scid=kb;EN-US;811162) to generate a static htm page from an asp.net template page being...
8
by: jvyyuie | last post by:
// My email is jvyyuie@hotmail.com // I want to make some friends and discuss about programing. #include "stdafx.h" #include <malloc.h> #include <string.h> #define sec1...
8
by: noe | last post by:
Hello all devs!! I’m a student and I’m developing my Final Project in the University. I have to develop a driver for Windows XP that work so: I have a file in the HD (NTFS file system) of my PC...
1
by: Woojtos | last post by:
Hi, I have a problem. I don't know how to create lowpass, highpass and bandpass filter. I capture the sound using CaptureBuffer from DirectX library. Then I create memory buffor as follow: ...
3
by: Brad | last post by:
I have a response filter which injects "standard" html into my pages. The filter works fine when the initial stream is small enough not to buffer...or....if I have a large unbuffered stream (i.e. I...
0
by: Tim Mavers | last post by:
I have built a web app where I need to parse the entire http page before it is returned to the client. Basically I am running a RegEx replace on it which looks for any predefined macros and...
0
by: Salim Afsar | last post by:
Hi, I'm trying to compress all requests. When client send a request, I will compress the response and send it to client. For this purpose I get Response.Filter stream and try to read this...
4
by: Greg Young | last post by:
Ok so I think everyone can agree that creating buffers on the fly in an async socket server is bad ... there is alot of literature available on the problems this will cause with the heap. I am...
0
by: elliott | last post by:
Hello, I'm trying to use a C# IHttpModule to install a Response filter however IIS keeps removing the Content-Encoding header from the response; but all the other headers I set stay intact. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.