39 using namespace Nsound;
44 #define CERR_HEADER __FILE__ << ":" << __LINE__ << ": "
51 const float64 & cutoff_frequency_Hz)
59 frequency_1_Hz_(cutoff_frequency_Hz),
82 - 0.500 * std::cos((di + 0.5) * 2.0 *
M_PI / ks)
83 + 0.080 * std::cos((di + 0.5) * 4.0 *
M_PI / ks);
101 frequency_1_Hz_(0.0),
112 KernelCache::iterator itor =
lp_cache_.begin();
113 KernelCache::iterator end =
lp_cache_.end();
240 plot(
boolean show_fc,
boolean show_phase)
244 "Low Pass FIR Frequency Response\n"
245 "order = %d, fc = %0.1f Hz, sr = %0.1f Hz",
282 static_cast<uint32>(cutoff_frequency_Hz));
285 KernelCache::const_iterator itor =
lp_cache_.find(new_kernel);
310 if(cutoff_frequency_Hz < 0.10)
323 for(
float64 i = 0.0; i < ks; i += 1.0)
327 *b = std::sin(omega * x) / x * *w;
378 frequency_(frequency)
void plot(boolean show_fc=true, boolean show_phase=false)
FilterLowPassFIR(const float64 &sample_rate, uint32 kernel_size, const float64 &cutoff_frequency_Hz)
virtual ~FilterLowPassFIR()
void axvline(const float64 &x_pos=0.0, const std::string &kwargs="")
Draws a vertical line at x and spans ymin to ymax (ralitive).
void title(const std::string &title, const std::string &kwargs="")
Add a title to the plot at the top and centered.
bool operator<(const Kernel &rhs) const
uint32 getLength() const
Returns the number of samples in the Buffer.
Buffer getImpulseResponse(const uint32 n_samples=8192)
void makeKernel(const float64 &frequency1)
Base class for IIR Filters, defines the interface.
Axes subplot(const uint32 n_rows, const uint32 n_cols, const uint32 n, const std::string &kwargs="", Axes *sharex=NULL, Axes *sharey=NULL)
Creates a figure in a subplot, subplot(A, B, C, **kwargs)
iterator end()
Retruns the itreator at the end of the Buffer.
FloatVector::const_iterator const_iterator
iterator begin()
Retruns the itreator at the start of the Buffer.
void plot(boolean show_phase=false)
AudioStream filter(const AudioStream &x)
A Buffer for storing audio samples.
Kernel(const uint32 &frequency)
void setCutoff(const float64 &fc)
Sets the cut off frequency (Hz).
A class to store calculated kernels.
float64 two_pi_over_sample_rate_
AudioStream filter(const AudioStream &x)
Buffer getImpulseResponse()