0
$\begingroup$

I am trying to apply some filtering in C/C++ code, I have designed an algorithm using Matlab and it works well, so now I am moving it to native code.

I am interested in the filter function.
In my matlab script it is used as follows.

[y_blk, fir1_state] = filter( h, 1, x.*c, fir1_state ); 

Where the h argument is coefficients generated by firpm function.

I have tried to find any implementation, but unfortunately no results.

I would be very grateful if someone could provide an implementation of this function

Or maybe there is an existing implementation of this function in some library.

Thanks

$\endgroup$
1
$\begingroup$

FIR filtering is an operation whose implementation hugely benefits from utilization of architecture-specific instructions, compiler intrinsics, etc. Hence, if your only goal is to get a performant FIR algorithm, you should try to find a dsp library specifically for your target architecture. Those are most likely written in assembly language with a C interface and you can expect an orders-of-magnitude better performance than you would achieve with a generic C implementation of a transversal FIR.

If the latter is exactly what you're looking for - a generic FIR implementation in C - let me point you towards https://iowegian.com/. They offer a commercial filter design software called ScopeFIR. You can download and install a free trial version of it (no registration). In the program directory, you can find a source file "FirAlgs.c" that offers a variety of well-documented FIR implementations. It's written for MSVC but should be portable to basically anywhere without hassle.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.