Giter Site home page Giter Site logo

jan9401 / butterworth-filter-design Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ruohoruotsi/butterworth-filter-design

0.0 0.0 0.0 5.42 MB

C++ classes for designing high-order Butterworth IIR & equalization filters

License: GNU General Public License v3.0

C++ 94.92% Python 0.03% MATLAB 5.05%

butterworth-filter-design's Introduction

Butterworth Filter Design

Butterworth Filter Design is a collection of C++ classes and an accompanying suite of unit tests for designing high order Butterworth IIR and EQ filters using the bilinear transform.

The generated filter coefficients are split out into cascaded biquad sections, for easy use in any biquad or second-order section (SOS) implementation.

Features

  • Lowpass, Highpass, Bandpass and Bandstop IIR & EQ filter design
  • Low and High Shelving filter design
  • High order Parametric boost/cut EQ filter design *Biquad and Biquad Chain implementations (for filtering audio buffers with cascaded biquad sections)
  • Compact, readable and well-commented codebase

Unit tests

As with any good audio signal processing toolkit, there are unit tests that provide basic proof of correctness. There are currently 6 primary test cases that check 113 different conditions.

Unit tests live in main.cpp and are written using the compact Catch test framework for C++.

Prerequisites

  • SCONS as a cross-platform build system to build, test and run examples.
    • On MacOS use Homebrew: $brew install scons or MacPorts port install scons
    • On Linux: apt-get install scons
  • libsndfile: brew install libsndfile

Usage

The unit tests are a good place to start for a survey of usage.

For example, to design an 8-tap Butterworth lowpass filter with a cutoff @ 500Hz (which will generate coefficients for 4 biquad filters), running @ 44100Hz, with unity gain (1.0) execute the following:

vector <Biquad> coeffs;  // array of biquad filters (for this case, array size = 4 )
Butterworth butterworth;
bool designedCorrectly = butterworth.loPass(44100,  // fs
					    500,    // freq1
					    0,      // freq2. N/A for lowpass
					    8, 	    // filter order,
					    coeffs, // coefficient array being filled
					    1.0);   // overall gain

To generate the same set of coefficients in MATLAB (R14) as a comparison, to double-check our work, execute the following MATLAB commands:

[z, p, k] = butter(8, 500, 's');		% designs a 8-tap lowpass s-domain filter
[Zd, Pd, Kd] = bilinear(z, p, k, 44100);	% analog-to-digital filter conversion
[sos, g] = zpk2sos(Zd, Pd, Kd)			% zero-pole-gain form to second-order sections (SOS)

Other filter design repos on GitHub

Terms and Conditions

For my Master's thesis, and in the course of work writing audio plugins and music apps, I've implemented a few different IIR and EQ filter design classes (e.g. RBJ's EQ Cookbook, Cheby and Butter IIRs). These classes are a fresh rewrite and should be considered unoptimized reference code, with an emphasis on clarity (and for pedagogical reasons, being able to refer to the textbook, see the math and understand the code). For this reason, in the hope they can be useful, these classes are provided under GPL v3.

Butterworth Filter Design - Copyright © 2013   iroro orife

Source code is provided under GPL v3

butterworth-filter-design's People

Contributors

ruohoruotsi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.