Butterworth.h
#ifndef IIR1_BUTTERWORTH_H
#define IIR1_BUTTERWORTH_H
#include "Common.h"
#include "Cascade.h"
#include "PoleFilter.h"
#include "State.h"
namespace Iir {
namespace Butterworth {
class DllExport AnalogLowPass : public LayoutBase
{
public:
AnalogLowPass ();
void design (const int numPoles);
private:
int m_numPoles;
};
//------------------------------------------------------------------------------
class DllExport AnalogLowShelf : public LayoutBase
{
public:
AnalogLowShelf ();
void design (int numPoles, double gainDb);
private:
int m_numPoles;
double m_gainDb;
};
//------------------------------------------------------------------------------
struct DllExport LowPassBase : PoleFilterBase <AnalogLowPass>
{
void setup (int order,
double cutoffFrequency);
};
struct DllExport HighPassBase : PoleFilterBase <AnalogLowPass>
{
void setup (int order,
double cutoffFrequency);
};
struct DllExport BandPassBase : PoleFilterBase <AnalogLowPass>
{
void setup (int order,
double centerFrequency,
double widthFrequency);
};
struct DllExport BandStopBase : PoleFilterBase <AnalogLowPass>
{
void setup (int order,
double centerFrequency,
double widthFrequency);
};
struct DllExport LowShelfBase : PoleFilterBase <AnalogLowShelf>
{
void setup (int order,
double cutoffFrequency,
double gainDb);
};
struct DllExport HighShelfBase : PoleFilterBase <AnalogLowShelf>
{
void setup (int order,
double cutoffFrequency,
double gainDb);
};
struct DllExport BandShelfBase : PoleFilterBase <AnalogLowShelf>
{
void setup (int order,
double centerFrequency,
double widthFrequency,
double gainDb);
};
//------------------------------------------------------------------------------
//
// Filters for the user
//
template <int FilterOrder = DEFAULT_FILTER_ORDER, class StateType = DEFAULT_STATE>
struct DllExport LowPass : PoleFilter <LowPassBase, StateType, FilterOrder>
{
void setup (double sampleRate,
double cutoffFrequency) {
LowPassBase::setup (FilterOrder,
cutoffFrequency / sampleRate);
}
void setup (int reqOrder,
double sampleRate,
double cutoffFrequency) {
if (reqOrder > FilterOrder) throw std::invalid_argument(orderTooHigh);
LowPassBase::setup (reqOrder,
cutoffFrequency / sampleRate);
}
void setupN(double cutoffFrequency) {
LowPassBase::setup (FilterOrder,
cutoffFrequency);
}
void setupN(int reqOrder,
double cutoffFrequency) {
if (reqOrder > FilterOrder) throw std::invalid_argument(orderTooHigh);
LowPassBase::setup (reqOrder,
cutoffFrequency);
}
};
template <int FilterOrder = DEFAULT_FILTER_ORDER, class StateType = DEFAULT_STATE>
struct DllExport HighPass : PoleFilter <HighPassBase, StateType, FilterOrder>
{
void setup (double sampleRate,
double cutoffFrequency) {
HighPassBase::setup (FilterOrder,
cutoffFrequency / sampleRate);
}
void setup (int reqOrder,
double sampleRate,
double cutoffFrequency) {
if (reqOrder > FilterOrder) throw std::invalid_argument(orderTooHigh);
HighPassBase::setup (reqOrder,
cutoffFrequency / sampleRate);
}
void setupN(double cutoffFrequency) {
HighPassBase::setup (FilterOrder,
cutoffFrequency);
}
void setupN(int reqOrder,
double cutoffFrequency) {
if (reqOrder > FilterOrder) throw std::invalid_argument(orderTooHigh);
HighPassBase::setup (reqOrder,
cutoffFrequency);
}
};
template <int FilterOrder = DEFAULT_FILTER_ORDER, class StateType = DEFAULT_STATE>
struct DllExport BandPass : PoleFilter <BandPassBase, StateType, FilterOrder, FilterOrder*2>
{
void setup (double sampleRate,
double centerFrequency,
double widthFrequency) {
BandPassBase::setup(FilterOrder,
centerFrequency / sampleRate,
widthFrequency / sampleRate);
}
void setup (int reqOrder,
double sampleRate,
double centerFrequency,
double widthFrequency) {
if (reqOrder > FilterOrder) throw std::invalid_argument(orderTooHigh);
BandPassBase::setup(reqOrder,
centerFrequency / sampleRate,
widthFrequency / sampleRate);
}
void setupN(double centerFrequency,
double widthFrequency) {
BandPassBase::setup(FilterOrder,
centerFrequency,
widthFrequency);
}
void setupN(int reqOrder,
double centerFrequency,
double widthFrequency) {
if (reqOrder > FilterOrder) throw std::invalid_argument(orderTooHigh);
BandPassBase::setup(reqOrder,
centerFrequency,
widthFrequency);
}
};
template <int FilterOrder = DEFAULT_FILTER_ORDER, class StateType = DEFAULT_STATE>
struct DllExport BandStop : PoleFilter <BandStopBase, StateType, FilterOrder, FilterOrder*2>
{
void setup (double sampleRate,
double centerFrequency,
double widthFrequency) {
BandStopBase::setup (FilterOrder,
centerFrequency / sampleRate,
widthFrequency / sampleRate);
}
void setupN(int reqOrder,
double sampleRate,
double centerFrequency,
double widthFrequency) {
if (reqOrder > FilterOrder) throw std::invalid_argument(orderTooHigh);
BandStopBase::setup (reqOrder,
centerFrequency / sampleRate,
widthFrequency / sampleRate);
}
void setupN(double centerFrequency,
double widthFrequency) {
BandStopBase::setup (FilterOrder,
centerFrequency,
widthFrequency);
}
void setupN(int reqOrder,
double centerFrequency,
double widthFrequency) {
if (reqOrder > FilterOrder) throw std::invalid_argument(orderTooHigh);
BandStopBase::setup (reqOrder,
centerFrequency,
widthFrequency);
}
};
template <int FilterOrder = DEFAULT_FILTER_ORDER, class StateType = DEFAULT_STATE>
struct DllExport LowShelf : PoleFilter <LowShelfBase, StateType, FilterOrder>
{
void setup (double sampleRate,
double cutoffFrequency,
double gainDb) {
LowShelfBase::setup (FilterOrder,
cutoffFrequency / sampleRate,
gainDb);
}
void setup (int reqOrder,
double sampleRate,
double cutoffFrequency,
double gainDb) {
if (reqOrder > FilterOrder) throw std::invalid_argument(orderTooHigh);
LowShelfBase::setup (reqOrder,
cutoffFrequency / sampleRate,
gainDb);
}
void setupN(double cutoffFrequency,
double gainDb) {
LowShelfBase::setup (FilterOrder,
cutoffFrequency,
gainDb);
}
void setupN(int reqOrder,
double cutoffFrequency,
double gainDb) {
if (reqOrder > FilterOrder) throw std::invalid_argument(orderTooHigh);
LowShelfBase::setup (reqOrder,
cutoffFrequency,
gainDb);
}
};
template <int FilterOrder = DEFAULT_FILTER_ORDER, class StateType = DEFAULT_STATE>
struct DllExport HighShelf : PoleFilter <HighShelfBase, StateType, FilterOrder>
{
void setup (double sampleRate,
double cutoffFrequency,
double gainDb) {
HighShelfBase::setup (FilterOrder,
cutoffFrequency / sampleRate,
gainDb);
}
void setup (int reqOrder,
double sampleRate,
double cutoffFrequency,
double gainDb) {
if (reqOrder > FilterOrder) throw std::invalid_argument(orderTooHigh);
HighShelfBase::setup (reqOrder,
cutoffFrequency / sampleRate,
gainDb);
}
void setupN(double cutoffFrequency,
double gainDb) {
HighShelfBase::setup (FilterOrder,
cutoffFrequency,
gainDb);
}
void setupN(int reqOrder,
double cutoffFrequency,
double gainDb) {
if (reqOrder > FilterOrder) throw std::invalid_argument(orderTooHigh);
HighShelfBase::setup (reqOrder,
cutoffFrequency,
gainDb);
}
};
template <int FilterOrder = DEFAULT_FILTER_ORDER, class StateType = DEFAULT_STATE>
struct DllExport BandShelf : PoleFilter <BandShelfBase, StateType, FilterOrder, FilterOrder*2>
{
void setup (double sampleRate,
double centerFrequency,
double widthFrequency,
double gainDb) {
BandShelfBase::setup (FilterOrder,
centerFrequency / sampleRate,
widthFrequency / sampleRate,
gainDb);
}
void setup (int reqOrder,
double sampleRate,
double centerFrequency,
double widthFrequency,
double gainDb) {
if (reqOrder > FilterOrder) throw std::invalid_argument(orderTooHigh);
BandShelfBase::setup (reqOrder,
centerFrequency / sampleRate,
widthFrequency / sampleRate,
gainDb);
}
void setupN(double centerFrequency,
double widthFrequency,
double gainDb) {
BandShelfBase::setup (FilterOrder,
centerFrequency,
widthFrequency,
gainDb);
}
void setupN(int reqOrder,
double centerFrequency,
double widthFrequency,
double gainDb) {
if (reqOrder > FilterOrder) throw std::invalid_argument(orderTooHigh);
BandShelfBase::setup (reqOrder,
centerFrequency,
widthFrequency,
gainDb);
}
};
}
}
#endif
Iir::PoleFilterBase
Definition: PoleFilter.h:89
Iir::Butterworth::LowShelf::setup
void setup(double sampleRate, double cutoffFrequency, double gainDb)
Definition: Butterworth.h:406
Iir::Butterworth::LowPass::setup
void setup(double sampleRate, double cutoffFrequency)
Definition: Butterworth.h:154
Iir::Butterworth::HighShelf::setupN
void setupN(double cutoffFrequency, double gainDb)
Definition: Butterworth.h:511
Iir::Butterworth::LowPass::setup
void setup(int reqOrder, double sampleRate, double cutoffFrequency)
Definition: Butterworth.h:166
Iir::Butterworth::LowShelf::setupN
void setupN(int reqOrder, double cutoffFrequency, double gainDb)
Definition: Butterworth.h:452
Iir::Butterworth::BandShelf::setupN
void setupN(int reqOrder, double centerFrequency, double widthFrequency, double gainDb)
Definition: Butterworth.h:605
Iir::Butterworth::HighShelf::setupN
void setupN(int reqOrder, double cutoffFrequency, double gainDb)
Definition: Butterworth.h:524
Iir::Butterworth::BandPass
Definition: Butterworth.h:257
Iir::Butterworth::HighPass
Definition: Butterworth.h:203
Iir::Butterworth::BandStopBase
Definition: Butterworth.h:106
Iir::Butterworth::BandStop
Definition: Butterworth.h:327
Iir::Butterworth::BandShelfBase
Definition: Butterworth.h:127
Iir::Butterworth::LowPass
Definition: Butterworth.h:147
Iir::PoleFilter
Definition: PoleFilter.h:112
Iir::Butterworth::BandPass::setupN
void setupN(int reqOrder, double centerFrequency, double widthFrequency)
Definition: Butterworth.h:310
Iir::Butterworth::BandPass::setupN
void setupN(double centerFrequency, double widthFrequency)
Definition: Butterworth.h:297
Iir::Butterworth::BandStop::setupN
void setupN(double centerFrequency, double widthFrequency)
Definition: Butterworth.h:367
Iir::Butterworth::LowPass::setupN
void setupN(double cutoffFrequency)
Definition: Butterworth.h:179
Iir::Butterworth::HighShelf
Definition: Butterworth.h:471
Iir::Butterworth::BandStop::setupN
void setupN(int reqOrder, double sampleRate, double centerFrequency, double widthFrequency)
Definition: Butterworth.h:350
Iir::Butterworth::HighPassBase
Definition: Butterworth.h:93
Iir
Definition: Biquad.cpp:41
Iir::Butterworth::BandPassBase
Definition: Butterworth.h:99
Iir::Butterworth::HighPass::setupN
void setupN(int reqOrder, double cutoffFrequency)
Definition: Butterworth.h:243
Iir::Butterworth::BandShelf::setup
void setup(double sampleRate, double centerFrequency, double widthFrequency, double gainDb)
Definition: Butterworth.h:551
Iir::Butterworth::HighPass::setup
void setup(double sampleRate, double cutoffFrequency)
Definition: Butterworth.h:210
Iir::Butterworth::BandShelf
Definition: Butterworth.h:542
Iir::Butterworth::BandShelf::setup
void setup(int reqOrder, double sampleRate, double centerFrequency, double widthFrequency, double gainDb)
Definition: Butterworth.h:569
Iir::Butterworth::HighPass::setup
void setup(int reqOrder, double sampleRate, double cutoffFrequency)
Definition: Butterworth.h:221
Iir::Butterworth::BandPass::setup
void setup(int reqOrder, double sampleRate, double centerFrequency, double widthFrequency)
Definition: Butterworth.h:280
Iir::Butterworth::HighShelf::setup
void setup(int reqOrder, double sampleRate, double cutoffFrequency, double gainDb)
Definition: Butterworth.h:494
Iir::Butterworth::LowPass::setupN
void setupN(int reqOrder, double cutoffFrequency)
Definition: Butterworth.h:189
Iir::Butterworth::BandStop::setup
void setup(double sampleRate, double centerFrequency, double widthFrequency)
Definition: Butterworth.h:335
Iir::Butterworth::BandShelf::setupN
void setupN(double centerFrequency, double widthFrequency, double gainDb)
Definition: Butterworth.h:589
Iir::Butterworth::AnalogLowPass
Definition: Butterworth.h:57
Iir::LayoutBase
Definition: Layout.h:63
Iir::Butterworth::BandStop::setupN
void setupN(int reqOrder, double centerFrequency, double widthFrequency)
Definition: Butterworth.h:380
Iir::Butterworth::LowShelf::setup
void setup(int reqOrder, double sampleRate, double cutoffFrequency, double gainDb)
Definition: Butterworth.h:421
Iir::Butterworth::LowShelf
Definition: Butterworth.h:398
Iir::Butterworth::BandPass::setup
void setup(double sampleRate, double centerFrequency, double widthFrequency)
Definition: Butterworth.h:265
Iir::Butterworth::LowShelfBase
Definition: Butterworth.h:113
Iir::Butterworth::HighPass::setupN
void setupN(double cutoffFrequency)
Definition: Butterworth.h:234
Iir::Butterworth::HighShelf::setup
void setup(double sampleRate, double cutoffFrequency, double gainDb)
Definition: Butterworth.h:479
Iir::Butterworth::HighShelfBase
Definition: Butterworth.h:120
Iir::Butterworth::LowShelf::setupN
void setupN(double cutoffFrequency, double gainDb)
Definition: Butterworth.h:439
Iir::Butterworth::LowPassBase
Definition: Butterworth.h:87
Iir::Butterworth::AnalogLowShelf
Definition: Butterworth.h:73