39 using namespace Nsound;
54 frequency_(frequency),
55 resonance_(resonance),
96 for(
uint32 channel = 0; channel < n_channels; ++channel)
98 y[channel] =
filter(x[channel]);
112 for(
uint32 channel = 0; channel < n_channels; ++channel)
114 y[channel] =
filter(x[channel], frequencies);
124 const Buffer & frequencies,
131 for(
uint32 channel = 0; channel < n_channels; ++channel)
133 y[channel] =
filter(x[channel], frequencies, resonance);
143 const Buffer & frequencies,
151 for(
uint32 channel = 0; channel < n_channels; ++channel)
153 y[channel] =
filter(x[channel], frequencies, resonance, boost);
170 for(
uint32 n = 0; n < n_samples; ++n)
189 for(
uint32 n = 0; n < n_samples; ++n)
191 y <<
filter(x[n], frequencies[n % n_freqs]);
201 const Buffer & frequencies,
212 for(
uint32 n = 0; n < n_samples; ++n)
214 y <<
filter(x[n], frequencies[n % n_freqs], resonance[n % n_rezzies]);
224 const Buffer & frequencies,
237 for(
uint32 n = 0; n < n_samples; ++n)
240 frequencies[n % n_freqs],
241 resonance[n % n_rezzies],
242 boost[n % n_boosts]);
353 static_cast<int32>(std::fabs(frequency)),
354 static_cast<int32>(resonance * 1e3),
355 static_cast<int32>(boost * 1e3));
370 memset(
b_, 0,
sizeof(
float64) * N_POLES);
391 float64 vkdq = boost * K / resonance;
393 b_[0] = 1.0 + vkdq + KK;
394 b_[1] = 2.0 * (KK - 1.0);
395 b_[2] = 1.0 - vkdq + KK;
397 a_[0] = 1.0 + K / resonance + KK;
399 a_[2] = 1.0 - K / resonance + KK;
421 float64 sqvk = sqrt(2.0 * boost) * K;
424 b_[0] = 1.0 + sqvk + vkk;
425 b_[1] = 2.0 * (vkk - 1.0);
426 b_[2] = 1.0 - sqvk + vkk;
428 a_[0] = 1.0 + K / resonance + KK;
429 a_[1] = 2.0 * (KK - 1.0);
430 a_[2] = 1.0 - K / resonance + KK;
452 float64 sq = sqrt(2.0 * boost);
454 b_[0] = 1.0 + sq * K + vkk;
455 b_[1] = -2.0 * (vkk - 1.0);
456 b_[2] = 1.0 - sq * K + vkk;
458 a_[0] = 1.0 + K / resonance + KK;
459 a_[1] = -2.0 * (KK - 1.0);
460 a_[2] = 1.0 - K / resonance + KK;
485 plot(
boolean show_fc,
boolean show_phase)
497 "Parametric Equalizing Frequency Response\n"
498 "order = %.0f, f = %0.1f Hz, sr = %0.1f Hz",
499 static_cast<float64>(
N_POLES - 1),
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
float64 getSampleRate() const
Returns the sample rate of the stream.
void plot(boolean show_fc=true, boolean show_phase=false)
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.
void setB(const float64 *b)
Copy getBLength() values from the array a into the Kernel. Use setLength() to set the number of value...
static const uint64 N_POLES
uint32 getLength() const
Returns the number of samples in the Buffer.
Base class for IIR Filters, defines the interface.
AudioStream filter(const AudioStream &x)
uint32 getNChannels(void) const
Returns the number of audio channels in the stream.
unsigned long long uint64
void plot(boolean show_phase=false)
virtual ~FilterParametricEqualizer()
void makeKernel(const float64 &frequency, const float64 &resonance, const float64 &boost)
A Buffer for storing audio samples.
KernelCache kernel_cache_
float64 two_pi_over_sample_rate_
void setA(const float64 *a)
Copy getALength() values from the array a into the Kernel. Use setLength() to set the number of value...