39 using namespace Nsound;
44 #define CERR_HEADER __FILE__ << ":" << __LINE__ << ": "
50 const float64 & frequency_Hz_low,
51 const float64 & frequency_Hz_high)
54 frequency_2_Hz_(frequency_Hz_high),
65 FilterBandRejectFIR::KernelCache::iterator itor =
68 FilterBandRejectFIR::KernelCache::iterator end =
111 for(
uint32 channel = 0; channel < n_channels; ++channel)
123 const Buffer & frequencies_Hz_low,
124 const Buffer & frequencies_Hz_high)
132 for(
uint32 channel = 0; channel < n_channels; ++channel)
137 frequencies_Hz_high);
181 const Buffer & frequencies_Hz_low,
182 const Buffer & frequencies_Hz_high)
193 for(
uint32 i = 0; i < x_samples; ++i)
197 frequencies_Hz_low [i % n_low_freqs],
198 frequencies_Hz_high[i % n_high_freqs]);
222 const float64 & frequencies_Hz_low,
223 const float64 & frequencies_Hz_high)
225 makeKernel(frequencies_Hz_low, frequencies_Hz_high);
241 static_cast<uint32>(low_frequency),
242 static_cast<uint32>(high_frequency));
246 FilterBandRejectFIR::KernelCache::const_iterator itor =
259 if(low_frequency < 0.10 && high_frequency >= 0.10)
270 else if(low_frequency >= 0.10 && high_frequency < 0.10)
281 else if(low_frequency <= 0.10 && high_frequency < 0.10)
284 new_kernel.
b_[0] = 1.0;
288 new_kernel.
b_[i] = 0.00000;
308 new_kernel.
b_[i] +=
b_[i];
321 plot(
boolean show_fc,
boolean show_phase)
325 "Band Reject FIR Frequency Response\n"
326 "order = %d, fl = %0.1f Hz, fl = %0.1f Hz, sr = %0.1f Hz",
float64 getSampleRate() const
Returns the sample rate of the stream.
void axvline(const float64 &x_pos=0.0, const std::string &kwargs="")
Draws a vertical line at x and spans ymin to ymax (ralitive).
AudioStream filter(const AudioStream &x)
void title(const std::string &title, const std::string &kwargs="")
Add a title to the plot at the top and centered.
A class to store calculated kernels.
Kernel(const uint32 &f1, const uint32 &f2)
void makeKernel(const float64 &frequency_Hz_low, const float64 &frequency_Hz_high)
uint32 getLength() const
Returns the number of samples in the Buffer.
void makeKernel(const float64 &frequency1)
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.
void makeKernel(const float64 &frequency)
uint32 getNChannels(void) const
Returns the number of audio channels in the stream.
FloatVector::const_iterator const_iterator
void plot(boolean show_fc=true, boolean show_phase=false)
iterator begin()
Retruns the itreator at the start of the Buffer.
void plot(boolean show_phase=false)
AudioStream filter(const AudioStream &x)
float64 getFrequencyLow() const
KernelCache kernel_cache_
float64 getFrequencyHigh() const
virtual ~FilterBandRejectFIR()
A Buffer for storing audio samples.
bool operator<(const Kernel &rhs) const
FilterBandRejectFIR(const float64 &sample_rate, uint32 kernel_size, const float64 &frequency_Hz_low, const float64 &frequency_Hz_high)
AudioStream filter(const AudioStream &x)