Nsound
0.9.4
|
#include <Nsound/FilterIIR.h>
Public Member Functions | |
FilterIIR (const float64 &sample_rate, uint32 n_poles) | |
FilterIIR (const FilterIIR ©) | |
virtual | ~FilterIIR () |
Buffer | designFrequencyResponse (const Buffer &frequency_response, const float64 &max_error=0.01, const int32 max_iterations=1000) |
Designs a filter kernel using a genetic algorithm that trys to match the provided frequency response. More... | |
Buffer | designImpulseResponse (const Buffer &impulse_response, const float64 &max_error=0.01, const int32 max_iterations=1000) |
Designs a filter kernel using a genetic algorithm that trys to match the provided impulse response. More... | |
AudioStream | filter (const AudioStream &x) |
AudioStream | filter (const AudioStream &x, const Buffer &frequencies) |
Buffer | filter (const Buffer &x) |
Buffer | filter (const Buffer &x, const Buffer &frequencies) |
float64 | filter (const float64 &x) |
float64 | filter (const float64 &x, const float64 &frequency) |
uint32 | getKernelSize () const |
Buffer | getImpulseResponse (const uint32 n_samples=8192) |
FilterIIR & | operator= (const FilterIIR &rhs) |
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 | getPhaseResponse () |
float64 | getSampleRate () const |
void | plot (boolean show_phase=false) |
Protected Types | |
enum | SignalType { FREQUENCY_RESSPONSE = 0, IMPULSE_RESPONSE } |
Protected Member Functions | |
Buffer | designKernel (const Buffer &response, const float64 &max_rms_error, const int32 max_iterations, const SignalType type) |
Designs a filter kernel that trys to match the provide frequency response. More... | |
float64 | getRMS (const Kernel &kernel, const Buffer &response, const SignalType type) |
void | savePlot (const Kernel &k, const Buffer &response, uint32 n, const float64 &error) |
Protected Attributes | |
uint32 | n_poles_ |
Kernel * | kernel_ |
float64 * | x_history_ |
float64 * | x_ptr_ |
float64 * | x_end_ptr_ |
float64 * | y_history_ |
float64 * | y_ptr_ |
float64 * | y_end_ptr_ |
RngTausworthe * | rng_ |
float64 | sample_rate_ |
float64 | two_pi_over_sample_rate_ |
float64 | sample_time_ |
uint32 | kernel_size_ |
bool | is_realtime_ |
Friends | |
std::ostream & | operator<< (std::ostream &out, const FilterIIR &rhs) |
Prints the coeffents. More... | |
WARNING: This is Experimental, you should not use this class as it may not be working or will change in future releases of Nsound.
Definition at line 52 of file FilterIIR.h.
|
protected |
Definition at line 59 of file FilterIIR.cc.
References kernel_, n_poles_, reset(), rng_, x_end_ptr_, x_history_, x_ptr_, y_end_ptr_, y_history_, and y_ptr_.
FilterIIR::FilterIIR | ( | const FilterIIR & | copy | ) |
Definition at line 91 of file FilterIIR.cc.
References n_poles_, reset(), rng_, x_history_, and y_history_.
|
virtual |
Buffer FilterIIR::designFrequencyResponse | ( | const Buffer & | frequency_response, |
const float64 & | max_error = 0.01 , |
||
const int32 | max_iterations = 1000 |
||
) |
Designs a filter kernel using a genetic algorithm that trys to match the provided frequency response.
Designs a filter kernel that trys to match the provide frequency response. The method uses a genetic algorithm to arrive at a fit solution and retuns the error per generation. The error signal is nice to plot to get an idea of how quickly the solution was found.
Definition at line 127 of file FilterIIR.cc.
References designKernel(), and FREQUENCY_RESSPONSE.
Referenced by main().
Buffer FilterIIR::designImpulseResponse | ( | const Buffer & | impulse_response, |
const float64 & | max_error = 0.01 , |
||
const int32 | max_iterations = 1000 |
||
) |
Designs a filter kernel using a genetic algorithm that trys to match the provided impulse response.
Designs a filter kernel that trys to match the provide impulse response The method uses a genetic algorithm to arrive at a fit solution and retuns the error per generation. The error signal is nice to plot to get an idea of how quickly the solution was found.
Definition at line 141 of file FilterIIR.cc.
References designKernel(), and IMPULSE_RESPONSE.
|
inline |
Definition at line 89 of file FilterIIR.h.
References Nsound::Filter::filter().
Referenced by filter().
|
inline |
Implements Nsound::Filter.
Definition at line 609 of file FilterIIR.cc.
References Nsound::Kernel::getA(), Nsound::Kernel::getB(), kernel_, n_poles_, x_end_ptr_, x_history_, x_ptr_, y_end_ptr_, y_history_, and y_ptr_.
|
inlinevirtual |
Definition at line 114 of file FilterIIR.h.
References Nsound::Filter::getImpulseResponse(), and reset().
Referenced by getRMS().
Definition at line 683 of file FilterIIR.cc.
References kernel_, n_poles_, rng_, Nsound::Filter::sample_rate_, x_history_, and y_history_.
|
virtual |
Implements Nsound::Filter.
Definition at line 724 of file FilterIIR.cc.
References n_poles_, x_history_, x_ptr_, y_history_, and y_ptr_.
Referenced by FilterIIR(), getImpulseResponse(), getRMS(), and savePlot().
|
protected |
Designs a filter kernel that trys to match the provide frequency response.
This method is VERY EXPERMENTAL! Use at your own risk!
Designs a filter kernel that trys to match the provide frequency response. The method uses a genetic algorithm to arrive at a fit solution and retuns the error per generation. The error signal is nice to plot to get an idea of how quickly the solution was found.
Definition at line 249 of file FilterIIR.cc.
References Nsound::Kernel::ga_interleave(), Nsound::Kernel::ga_swap_ab(), Nsound::RngTausworthe::get(), Nsound::Kernel::getA(), Nsound::Kernel::getB(), Nsound::Buffer::getLength(), getRMS(), Nsound::Kernel::getSum(), kernel_, M_ASSERT_VALUE, n_poles_, PRINT_LINE, Nsound::Kernel::randomize(), rng_, Nsound::Kernel::setA(), and Nsound::Kernel::setB().
Referenced by designFrequencyResponse(), and designImpulseResponse().
|
protected |
Definition at line 211 of file FilterIIR.cc.
References FREQUENCY_RESSPONSE, Nsound::Filter::getFrequencyResponse(), getImpulseResponse(), Nsound::Buffer::getLength(), Nsound::Buffer::getSum(), kernel_, and reset().
Referenced by designKernel().
|
protected |
Definition at line 735 of file FilterIIR.cc.
References Nsound::Plotter::figure(), Nsound::Filter::getFrequencyAxis(), Nsound::Filter::getFrequencyResponse(), Nsound::Buffer::getLength(), Nsound::Buffer::getMax(), kernel_, Nsound::Plotter::plot(), reset(), Nsound::Plotter::text(), Nsound::Plotter::title(), Nsound::Plotter::xlabel(), Nsound::Plotter::xlim(), Nsound::Plotter::ylabel(), and Nsound::Plotter::ylim().
|
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 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(), getRMS(), main(), Nsound::Filter::plot(), and savePlot().
|
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 Nsound::FilterParametricEqualizer::plot().
|
friend |
Prints the coeffents.
|
protected |
Definition at line 164 of file FilterIIR.h.
Referenced by designKernel(), filter(), FilterIIR(), getKernelSize(), operator=(), and reset().
|
protected |
Definition at line 166 of file FilterIIR.h.
Referenced by designKernel(), filter(), FilterIIR(), getRMS(), Nsound::operator<<(), operator=(), savePlot(), and ~FilterIIR().
|
protected |
Definition at line 168 of file FilterIIR.h.
Referenced by filter(), FilterIIR(), operator=(), reset(), and ~FilterIIR().
|
protected |
Definition at line 169 of file FilterIIR.h.
Referenced by filter(), FilterIIR(), and reset().
|
protected |
Definition at line 170 of file FilterIIR.h.
Referenced by filter(), and FilterIIR().
|
protected |
Definition at line 172 of file FilterIIR.h.
Referenced by filter(), FilterIIR(), operator=(), reset(), and ~FilterIIR().
|
protected |
Definition at line 173 of file FilterIIR.h.
Referenced by filter(), FilterIIR(), and reset().
|
protected |
Definition at line 174 of file FilterIIR.h.
Referenced by filter(), and FilterIIR().
|
protected |
Definition at line 176 of file FilterIIR.h.
Referenced by designKernel(), FilterIIR(), operator=(), and ~FilterIIR().
|
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(), Nsound::FilterParametricEqualizer::makeKernel(), Nsound::FilterPhaser::operator=(), Nsound::FilterLeastSquaresFIR::operator=(), Nsound::FilterFlanger::operator=(), 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(), Nsound::FilterParametricEqualizer::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 Nsound::FilterParametricEqualizer::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().