https://github.com/domohuhn/filter
Design and use digital filters with multiple programming languages.
https://github.com/domohuhn/filter
c cpp embedded fir-filters iir-filters javascript
Last synced: about 2 months ago
JSON representation
Design and use digital filters with multiple programming languages.
- Host: GitHub
- URL: https://github.com/domohuhn/filter
- Owner: domohuhn
- License: mit
- Created: 2022-06-05T20:09:10.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2026-03-11T20:14:27.000Z (4 months ago)
- Last Synced: 2026-03-12T00:10:12.443Z (3 months ago)
- Topics: c, cpp, embedded, fir-filters, iir-filters, javascript
- Language: C++
- Homepage:
- Size: 1.57 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Filter library for C
[](https://github.com/domohuhn/filter/actions/workflows/build-desktop.yml)
[](https://codecov.io/gh/domohuhn/filter)
This repository contains a C-library that can be used to both design digital filters, as well as use them.
The library also provides bindings to various other programming languages, like C++ and Javascript via emscripten.
You can try out the library [online on github pages](https://domohuhn.github.io/filter/design_filter.html).
The following filter types are supported:
| Name | Type | Characteristics | Examples
|----------|:-------------:|:-------------:|------------
| Moving average | FIR | lowpass, highpass | n/a
| exponential | FIR | lowpass | n/a
| exponential | IIR | lowpass | n/a
| butterworth | IIR | lowpass, highpass, bandpass, bandstop | n/a
| chebyshev (type 1) | IIR | lowpass, highpass, bandpass, bandstop | n/a
| chebyshev (type 2) | IIR | lowpass, highpass, bandpass, bandstop | n/a
| brickwall | FIR | lowpass, highpass, bandpass, bandstop | n/a
The filters are designed using the bilinear z-transform.
In broad terms, you start with the frequency response of the analog filter and compute its poles and zeros. These values are transformed via a bilinear z-transform and expanded into a polynomial. The polynomial is normalized for gain 1 at 0 or the middle of the pass band.
Here is a [Presentation](https://spinlab.wpi.edu/courses/ece503_2014/10-3bilinear_transform.pdf) explaining the process.
[MIT Signal processing continuous and discrete course](https://ocw.mit.edu/courses/2-161-signal-processing-continuous-and-discrete-fall-2008/pages/lecture-notes/)
## Build and run
Here is a quick start on how to build the code in this repo. On linux systems, you should be able to copy these command into bash.
```bash
git clone https://github.com/domohuhn/filter.git
mkdir -p filter/build
cd filter/build
cmake -DCMAKE_BUILD_TYPE='Release' ..
cmake --build .
# run the unit tests
ctest
# use the example program to design a chebyshev bandstop
# -o: order 4
# -c: cutoff 15 hz and 35 Hz
# -s: sampling rate 100 Hz
# -r: ripple 3 dB
# -g: generate graphs
./design-filter -p chebyshev -t bandstop -o 4 -c 15,35 -s 100 -r -3 -g
```
## Documentation
The API Documentation is generated with doxygen and can read online on [github pages](https://domohuhn.github.io/filter/).
## License
All code in this repository is licensed with the MIT license, see file "LICENSE".
## Dependencies
The library itself has no dependencies. However the tests, examples and documentation have the following dependencies:
- [Catch 2](https://github.com/catchorg/Catch2) is used for the test cases.
- [cxxopts](https://github.com/jarro2783/cxxopts) parses the command line options in the examples.
- [Doxygen Awesome](https://github.com/jothepro/doxygen-awesome-css) for the css styles of the api documentation.
- [Chart.js](https://www.chartjs.org/) to render the graphs in the documentation.
## Issues
Please report issues and bugs using the [issue tracker](https://github.com/domohuhn/filter/issues).