Nsound
0.9.4
|
Implementation of Zoelzer's parametric equalizer filters, with some modifications by the author. More...
#include <Nsound/FilterParametricEqualizer.h>
Public Types | |
enum | Type { PEAKING, LOW_SHELF, HIGH_SHELF } |
Public Member Functions | |
FilterParametricEqualizer (const Type &type, const float64 &sample_rate, const float64 &frequency, const float64 &resonance=0.707106781187, const float64 &boost_dB=0.0) | |
boost is in dB More... | |
virtual | ~FilterParametricEqualizer () |
AudioStream | filter (const AudioStream &x) |
AudioStream | filter (const AudioStream &x, const Buffer &frequencies) |
AudioStream | filter (const AudioStream &x, const Buffer &frequencies, const Buffer &resonance) |
AudioStream | filter (const AudioStream &x, const Buffer &frequencies, const Buffer &resonance, const Buffer &boost_dB) |
boost is in dB More... | |
Buffer | filter (const Buffer &x) |
Buffer | filter (const Buffer &x, const Buffer &frequencies) |
Buffer | filter (const Buffer &x, const Buffer &frequencies, const Buffer &resonance) |
Buffer | filter (const Buffer &x, const Buffer &frequencies, const Buffer &resonance, const Buffer &boost_dB) |
boost is in dB More... | |
float64 | filter (const float64 &x) |
float64 | filter (const float64 &x, const float64 &frequency) |
float64 | filter (const float64 &x, const float64 &frequency, const float64 &resonance) |
boost is in dB More... | |
float64 | filter (const float64 &x, const float64 &frequency, const float64 &resonance, const float64 &boost_dB) |
boost is in dB More... | |
void | makeKernel (const float64 &frequency, const float64 &resonance, const float64 &boost) |
void | plot (boolean show_fc=true, boolean show_phase=false) |
void | reset () |
void | setRealtime (bool flag) |
AudioStream | filter (const AudioStream &x, const float64 &frequency) |
Buffer | filter (const Buffer &x, const float64 &frequency) |
Buffer | getFrequencyAxis (const uint32 n_fft=8192) |
Buffer | getFrequencyResponse (const uint32 n_fft=8192) |
Buffer | getImpulseResponse (const uint32 n_samples=8192) |
virtual uint32 | getKernelSize () const |
Buffer | getPhaseResponse () |
float64 | getSampleRate () const |
void | plot (boolean show_phase=false) |
Protected Attributes | |
Type | type_ |
float64 | frequency_ |
float64 | resonance_ |
float64 | boost_ |
float64 * | a_ |
float64 * | b_ |
float64 * | x_history_ |
float64 * | x_ptr_ |
float64 * | x_end_ptr_ |
float64 * | y_history_ |
float64 * | y_ptr_ |
float64 * | y_end_ptr_ |
KernelCache | kernel_cache_ |
float64 | sample_rate_ |
float64 | two_pi_over_sample_rate_ |
float64 | sample_time_ |
uint32 | kernel_size_ |
bool | is_realtime_ |
Private Member Functions | |
FilterParametricEqualizer (const FilterParametricEqualizer ©) | |
FilterParametricEqualizer & | operator= (const FilterParametricEqualizer &rhs) |
Implementation of Zoelzer's parametric equalizer filters, with some modifications by the author.
Below are the formulas for the 3 different types of parametric equalizer filters.
f = Frequency in Hz sr = Sample Rate in samples per second V = Percent boost (1.0 = no boost, < 1.0 = cut signal, > 1.0 boost signal) Q = Resonance or Q of the filter, sqrt(1/2) == no resonance
omega = 2*pi*f/sr K = tan(omega/2)
a0 = 1 + sqrt(2*V)*K + V*K^2 a1 = 2*(V*K^2 - 1) a2 = 1 - sqrt(2*V)*K + V*K^2
b0 = 1 + K/Q + K^2 b1 = 2*(K^2 - 1) b2 = 1 - K/Q + K^2
The formula for the High Shelf filter is:
omega = 2*pi*f/sr K = tan((pi-omega)/2)
a0 = 1 + sqrt(2*V)*K + V*K^2 a1 = -2*(V*K^2 - 1) a1 = 1 - sqrt(2*V)*K + V*K^2
b0 = 1 + K/Q + K^2 b1 = -2*(K^2 - 1) b2 = 1 - K/Q + K^2
The formula for the Peaking filter is:
omega = 2*pi*f/sr K = tan(omega/2)
a0 = 1 + V*K/2 + K^2 a1 = 2*(K^2 - 1) a2 = 1 - V*K/2 + K^2
b0 = 1 + K/Q + K^2 b1 = 2*(K^2 - 1) b2 = 1 - K/Q + K^2
Definition at line 98 of file FilterParametricEqualizer.h.
FilterParametricEqualizer::FilterParametricEqualizer | ( | const Type & | type, |
const float64 & | sample_rate, | ||
const float64 & | frequency, | ||
const float64 & | resonance = 0.707106781187 , |
||
const float64 & | boost_dB = 0.0 |
||
) |
boost is in dB
Definition at line 45 of file FilterParametricEqualizer.cc.
References N_POLES, reset(), x_end_ptr_, x_history_, x_ptr_, y_end_ptr_, y_history_, and y_ptr_.
|
virtual |
Definition at line 80 of file FilterParametricEqualizer.cc.
References a_, b_, x_history_, and y_history_.
|
private |
AudioStream FilterParametricEqualizer::filter | ( | const AudioStream & | x | ) |
Definition at line 90 of file FilterParametricEqualizer.cc.
References Nsound::AudioStream::getNChannels(), and Nsound::AudioStream::getSampleRate().
Referenced by filter(), FilterParametricEqualizer_UnitTest(), and Nsound::DrumKickBass::play().
AudioStream FilterParametricEqualizer::filter | ( | const AudioStream & | x, |
const Buffer & | frequencies | ||
) |
Definition at line 106 of file FilterParametricEqualizer.cc.
References filter(), Nsound::AudioStream::getNChannels(), and Nsound::AudioStream::getSampleRate().
AudioStream FilterParametricEqualizer::filter | ( | const AudioStream & | x, |
const Buffer & | frequencies, | ||
const Buffer & | resonance | ||
) |
Definition at line 122 of file FilterParametricEqualizer.cc.
References filter(), Nsound::AudioStream::getNChannels(), and Nsound::AudioStream::getSampleRate().
AudioStream FilterParametricEqualizer::filter | ( | const AudioStream & | x, |
const Buffer & | frequencies, | ||
const Buffer & | resonance, | ||
const Buffer & | boost_dB | ||
) |
boost is in dB
Definition at line 141 of file FilterParametricEqualizer.cc.
References filter(), Nsound::AudioStream::getNChannels(), and Nsound::AudioStream::getSampleRate().
Definition at line 162 of file FilterParametricEqualizer.cc.
References filter(), Nsound::Buffer::getLength(), and reset().
Definition at line 180 of file FilterParametricEqualizer.cc.
References filter(), Nsound::Buffer::getLength(), and reset().
Buffer FilterParametricEqualizer::filter | ( | const Buffer & | x, |
const Buffer & | frequencies, | ||
const Buffer & | resonance | ||
) |
Definition at line 199 of file FilterParametricEqualizer.cc.
References filter(), Nsound::Buffer::getLength(), and reset().
Buffer FilterParametricEqualizer::filter | ( | const Buffer & | x, |
const Buffer & | frequencies, | ||
const Buffer & | resonance, | ||
const Buffer & | boost_dB | ||
) |
boost is in dB
Definition at line 222 of file FilterParametricEqualizer.cc.
References filter(), Nsound::Buffer::getLength(), and reset().
Implements Nsound::Filter.
Definition at line 250 of file FilterParametricEqualizer.cc.
References a_, b_, N_POLES, x_end_ptr_, x_history_, x_ptr_, y_end_ptr_, y_history_, and y_ptr_.
Implements Nsound::Filter.
Definition at line 313 of file FilterParametricEqualizer.cc.
References boost_, filter(), makeKernel(), and resonance_.
float64 FilterParametricEqualizer::filter | ( | const float64 & | x, |
const float64 & | frequency, | ||
const float64 & | resonance | ||
) |
boost is in dB
Definition at line 322 of file FilterParametricEqualizer.cc.
References boost_, filter(), and makeKernel().
float64 FilterParametricEqualizer::filter | ( | const float64 & | x, |
const float64 & | frequency, | ||
const float64 & | resonance, | ||
const float64 & | boost_dB | ||
) |
boost is in dB
Definition at line 334 of file FilterParametricEqualizer.cc.
References filter(), and makeKernel().
void FilterParametricEqualizer::makeKernel | ( | const float64 & | frequency, |
const float64 & | resonance, | ||
const float64 & | boost | ||
) |
Definition at line 347 of file FilterParametricEqualizer.cc.
References a_, b_, HIGH_SHELF, kernel_cache_, LOW_SHELF, M_PI, N_POLES, PEAKING, Nsound::Filter::sample_rate_, Nsound::Kernel::setA(), Nsound::Kernel::setB(), Nsound::Filter::two_pi_over_sample_rate_, and type_.
Referenced by filter(), and reset().
Definition at line 485 of file FilterParametricEqualizer.cc.
References Nsound::Plotter::axvline(), frequency_, N_POLES, Nsound::Filter::plot(), Nsound::Filter::sample_rate_, and Nsound::Plotter::title().
|
virtual |
Implements Nsound::Filter.
Definition at line 508 of file FilterParametricEqualizer.cc.
References boost_, frequency_, makeKernel(), N_POLES, resonance_, x_history_, x_ptr_, y_history_, and y_ptr_.
Referenced by filter(), and FilterParametricEqualizer().
|
private |
|
inlineinherited |
|
inherited |
Definition at line 76 of file Filter.cc.
References Nsound::Filter::filter(), Nsound::AudioStream::getNChannels(), Nsound::AudioStream::getSampleRate(), Nsound::Filter::is_realtime_, M_THROW, and Nsound::Filter::reset().
Definition at line 140 of file Filter.cc.
References Nsound::Buffer::begin(), Nsound::Buffer::end(), Nsound::Filter::filter(), Nsound::Buffer::getLength(), Nsound::Filter::is_realtime_, and Nsound::Filter::reset().
Definition at line 185 of file Filter.cc.
References Nsound::FFTransform::roundUp2(), and Nsound::Filter::sample_rate_.
Referenced by main(), Nsound::Filter::plot(), and Nsound::FilterIIR::savePlot().
Definition at line 210 of file Filter.cc.
References Nsound::FFTransform::fft(), Nsound::Filter::getImpulseResponse(), and Nsound::Filter::sample_rate_.
Referenced by Nsound::FilterBandPassIIR::FilterBandPassIIR(), FilterLeastSquaresFIR_UnitTest(), Nsound::FilterIIR::getRMS(), main(), Nsound::Filter::plot(), and Nsound::FilterIIR::savePlot().
Definition at line 225 of file Filter.cc.
References Nsound::Filter::filter(), Nsound::Filter::is_realtime_, and Nsound::Filter::reset().
Referenced by Nsound::Filter::getFrequencyResponse(), Nsound::FilterHighPassFIR::getImpulseResponse(), Nsound::FilterLowPassFIR::getImpulseResponse(), Nsound::FilterLeastSquaresFIR::getImpulseResponse(), Nsound::FilterIIR::getImpulseResponse(), and Nsound::Filter::getPhaseResponse().
|
inlinevirtualinherited |
Reimplemented in Nsound::FilterIIR, and Nsound::FilterTone.
Definition at line 96 of file Filter.h.
References Nsound::Filter::kernel_size_.
Referenced by Nsound::FilterBandPassIIR::FilterBandPassIIR(), Nsound::FilterBandPassFIR::plot(), Nsound::FilterBandPassIIR::plot(), and Nsound::FilterBandRejectIIR::plot().
|
inherited |
Definition at line 245 of file Filter.cc.
References Nsound::FFTransform::fft(), Nsound::Filter::getImpulseResponse(), Nsound::Buffer::getLength(), Nsound::Filter::sample_rate_, and Nsound::Buffer::subbuffer().
Referenced by Nsound::Filter::plot().
|
inlineinherited |
|
inherited |
Definition at line 262 of file Filter.cc.
References Nsound::Plotter::figure(), Nsound::Buffer::getdB(), Nsound::Filter::getFrequencyAxis(), Nsound::Filter::getFrequencyResponse(), Nsound::Buffer::getMax(), Nsound::Filter::getPhaseResponse(), Nsound::Plotter::plot(), Nsound::Plotter::subplot(), Nsound::Plotter::xlabel(), Nsound::Plotter::ylabel(), and Nsound::Plotter::ylim().
Referenced by main(), Nsound::FilterLowPassMoogVcf::plot(), Nsound::FilterPhaser::plot(), Nsound::FilterTone::plot(), Nsound::FilterHighPassIIR::plot(), Nsound::FilterCombLowPassFeedback::plot(), Nsound::FilterLowPassIIR::plot(), Nsound::FilterLowPassFIR::plot(), Nsound::FilterHighPassFIR::plot(), Nsound::FilterAllPass::plot(), Nsound::FilterBandPassVocoder::plot(), Nsound::FilterBandPassFIR::plot(), Nsound::FilterLeastSquaresFIR::plot(), Nsound::FilterFlanger::plot(), Nsound::FilterBandRejectFIR::plot(), Nsound::FilterBandPassIIR::plot(), Nsound::FilterBandRejectIIR::plot(), and plot().
|
protected |
Definition at line 196 of file FilterParametricEqualizer.h.
Referenced by makeKernel().
|
protected |
Definition at line 197 of file FilterParametricEqualizer.h.
|
protected |
Definition at line 198 of file FilterParametricEqualizer.h.
|
protected |
Definition at line 199 of file FilterParametricEqualizer.h.
|
protected |
Definition at line 201 of file FilterParametricEqualizer.h.
Referenced by filter(), makeKernel(), and ~FilterParametricEqualizer().
|
protected |
Definition at line 202 of file FilterParametricEqualizer.h.
Referenced by filter(), makeKernel(), and ~FilterParametricEqualizer().
|
protected |
Definition at line 204 of file FilterParametricEqualizer.h.
Referenced by filter(), FilterParametricEqualizer(), reset(), and ~FilterParametricEqualizer().
|
protected |
Definition at line 205 of file FilterParametricEqualizer.h.
Referenced by filter(), FilterParametricEqualizer(), and reset().
|
protected |
Definition at line 206 of file FilterParametricEqualizer.h.
Referenced by filter(), and FilterParametricEqualizer().
|
protected |
Definition at line 208 of file FilterParametricEqualizer.h.
Referenced by filter(), FilterParametricEqualizer(), reset(), and ~FilterParametricEqualizer().
|
protected |
Definition at line 209 of file FilterParametricEqualizer.h.
Referenced by filter(), FilterParametricEqualizer(), and reset().
|
protected |
Definition at line 210 of file FilterParametricEqualizer.h.
Referenced by filter(), and FilterParametricEqualizer().
|
protected |
Definition at line 212 of file FilterParametricEqualizer.h.
Referenced by makeKernel().
|
protectedinherited |
Definition at line 113 of file Filter.h.
Referenced by Nsound::FilterPhaser::filter(), Nsound::FilterCombLowPassFeedback::filter(), Nsound::FilterDelay::filter(), Nsound::FilterAllPass::FilterAllPass(), Nsound::FilterCombLowPassFeedback::FilterCombLowPassFeedback(), Nsound::FilterDelay::FilterDelay(), Nsound::FilterFlanger::FilterFlanger(), Nsound::FilterPhaser::FilterPhaser(), Nsound::FilterSlinky::FilterSlinky(), Nsound::Filter::getFrequencyAxis(), Nsound::Filter::getFrequencyResponse(), Nsound::Filter::getPhaseResponse(), Nsound::Filter::getSampleRate(), Nsound::FilterStageIIR::makeIIRKernelHelper(), Nsound::FilterHighPassFIR::makeKernel(), Nsound::FilterStageIIR::makeKernel(), Nsound::FilterBandPassVocoder::makeKernel(), Nsound::FilterLeastSquaresFIR::makeKernel(), makeKernel(), Nsound::FilterPhaser::operator=(), Nsound::FilterLeastSquaresFIR::operator=(), Nsound::FilterFlanger::operator=(), Nsound::FilterIIR::operator=(), Nsound::FilterLowPassMoogVcf::plot(), Nsound::FilterPhaser::plot(), Nsound::FilterTone::plot(), Nsound::FilterHighPassIIR::plot(), Nsound::FilterLowPassIIR::plot(), Nsound::FilterCombLowPassFeedback::plot(), Nsound::FilterLowPassFIR::plot(), Nsound::FilterHighPassFIR::plot(), Nsound::FilterAllPass::plot(), Nsound::FilterBandPassFIR::plot(), Nsound::FilterLeastSquaresFIR::plot(), Nsound::FilterFlanger::plot(), Nsound::FilterBandRejectFIR::plot(), Nsound::FilterBandRejectIIR::plot(), Nsound::FilterBandPassIIR::plot(), plot(), Nsound::FilterLowPassIIR::setCutoff(), and Nsound::FilterLeastSquaresFIR::setWindow().
|
protectedinherited |
Definition at line 114 of file Filter.h.
Referenced by Nsound::FilterTone::makeKernel(), Nsound::FilterLowPassFIR::makeKernel(), and makeKernel().
|
protectedinherited |
Definition at line 115 of file Filter.h.
Referenced by Nsound::FilterLowPassMoogVcf::_make_filter().
|
protectedinherited |
Definition at line 116 of file Filter.h.
Referenced by Nsound::FilterLowPassFIR::filter(), Nsound::FilterLeastSquaresFIR::filter(), Nsound::FilterBandPassFIR::FilterBandPassFIR(), Nsound::FilterBandPassIIR::FilterBandPassIIR(), Nsound::FilterBandRejectIIR::FilterBandRejectIIR(), Nsound::FilterHighPassIIR::FilterHighPassIIR(), Nsound::FilterLeastSquaresFIR::FilterLeastSquaresFIR(), Nsound::FilterLowPassFIR::FilterLowPassFIR(), Nsound::FilterLowPassIIR::FilterLowPassIIR(), Nsound::FilterLeastSquaresFIR::getKernel(), Nsound::Filter::getKernelSize(), Nsound::FilterHighPassFIR::makeKernel(), Nsound::FilterLowPassFIR::makeKernel(), Nsound::FilterBandRejectFIR::makeKernel(), Nsound::FilterLeastSquaresFIR::makeKernel(), Nsound::FilterLeastSquaresFIR::operator=(), Nsound::FilterLowPassFIR::plot(), Nsound::FilterHighPassFIR::plot(), Nsound::FilterLeastSquaresFIR::plot(), Nsound::FilterBandRejectFIR::plot(), Nsound::FilterLowPassFIR::reset(), Nsound::FilterHighPassFIR::reset(), Nsound::FilterLeastSquaresFIR::reset(), Nsound::FilterLeastSquaresFIR::setKernel(), Nsound::FilterLeastSquaresFIR::setWindow(), and Nsound::FilterHighPassFIR::spectraReversal_().
|
protectedinherited |
Definition at line 118 of file Filter.h.
Referenced by Nsound::Filter::filter(), Nsound::FilterBandRejectIIR::filter(), Nsound::FilterBandRejectFIR::filter(), Nsound::Filter::getImpulseResponse(), and Nsound::Filter::setRealtime().