本文整理汇总了C++中setCoefficients函数的典型用法代码示例。如果您正苦于以下问题:C++ setCoefficients函数的具体用法?C++ setCoefficients怎么用?C++ setCoefficients使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setCoefficients函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tan
void IIRFilter::makeHighPass (const double sampleRate,
const double frequency) noexcept
{
const double n = tan (double_Pi * frequency / sampleRate);
const double nSquared = n * n;
const double c1 = 1.0 / (1.0 + std::sqrt (2.0) * n + nSquared);
setCoefficients (c1,
c1 * -2.0f,
c1,
1.0,
c1 * 2.0 * (nSquared - 1.0),
c1 * (1.0 - std::sqrt (2.0) * n + nSquared));
}
示例2: adjust_imag
void BiquadBase::setTwoPole (complex_t pole1, complex_t zero1,
complex_t pole2, complex_t zero2)
{
#if 0
pole1 = adjust_imag (pole1);
pole2 = adjust_imag (pole2);
zero1 = adjust_imag (zero1);
zero2 = adjust_imag (zero2);
#endif
const double a0 = 1;
double a1;
double a2;
if (pole1.imag() != 0)
{
assert (pole2 == std::conj (pole1));
a1 = -2 * pole1.real();
a2 = std::norm (pole1);
}
else
{
assert (pole2.imag() == 0);
a1 = -(pole1.real() + pole2.real());
a2 = pole1.real() * pole2.real();
}
const double b0 = 1;
double b1;
double b2;
if (zero1.imag() != 0)
{
assert (zero2 == std::conj (zero1));
b1 = -2 * zero1.real();
b2 = std::norm (zero1);
}
else
{
assert (zero2.imag() == 0);
b1 = -(zero1.real() + zero2.real());
b2 = zero1.real() * zero2.real();
}
setCoefficients (a0, a1, a2, b0, b1, b2);
}
示例3: pow
void Biquad4proc::setPeaking(double center_frequency, double sampling_frequency, double gainDb, double slope)
{
double w0 = 2 * M_PI * center_frequency / sampling_frequency;
double A = pow(10, gainDb/40);
double alpha = sin(w0)/2 * sqrt( (A + 1/A)*(1/slope - 1) + 2 );
double b0 = 1 + alpha*A;
double b1 = -2*cos(w0);
double b2 = 1 - alpha*A;
double a0 = 1 + alpha/A;
double a1 = -2*cos(w0);
double a2 = 1 - alpha/A;
setCoefficients(a0, a1, a2, b0, b1, b2);
}
示例4: setCoefficients
inline void OnePoleFilter::setPolePosition(float pos, bool normalize) {
float b0, a1;
a1 = -pos;
b0 = 1.0f;
/**Reasoning time:
The maximum gain of the filter is at dc or nyquist, introducing either a term of -1 or a term of 1.
The maximum gain of the filter occurs when the denominator is minimized. The denominator is minimized when a1 is negative. So:
max = 1/(1-|a1|)
We wish to normalize the filter with b0. This means we wish to set b0 = 1/max.
By the rules of fractions:
b0 = 1-|a1|.
*/
if(normalize) b0 = (float)(1.0-fabs(a1));
setCoefficients(b0, a1);
}
示例5: jassert
//==============================================================================
void IIRFilter::makeLowPass (const double sampleRate,
const double frequency) noexcept
{
jassert (sampleRate > 0);
const double n = 1.0 / tan (double_Pi * frequency / sampleRate);
const double nSquared = n * n;
const double c1 = 1.0 / (1.0 + std::sqrt (2.0) * n + nSquared);
setCoefficients (c1,
c1 * 2.0f,
c1,
1.0,
c1 * 2.0 * (1.0 - nSquared),
c1 * (1.0 - std::sqrt (2.0) * n + nSquared));
}
示例6: cos
void AllPass::setup (double sampleRate,
double phaseFrequency,
double q)
{
double w0 = 2 * doublePi * phaseFrequency / sampleRate;
double cs = cos (w0);
double sn = sin (w0);
double AL = sn / ( 2 * q );
double b0 = 1 - AL;
double b1 = -2 * cs;
double b2 = 1 + AL;
double a0 = 1 + AL;
double a1 = -2 * cs;
double a2 = 1 - AL;
setCoefficients (a0, a1, a2, b0, b1, b2);
}
示例7: cos
void BiquadFilter::makeHighPass (const double sampleRate,
const double frequency,
const double Q) noexcept
{
const double oneOverCurrentSampleRate = 1.0 / sampleRate;
float w0 = (float) (2.0f * float_Pi * frequency * oneOverCurrentSampleRate);
float cos_w0 = cos (w0);
float sin_w0 = sin (w0);
float alpha = sin_w0 / (2.0f * (float) Q);
setCoefficients ((1.0f + cos_w0) * 0.5f,
-(1.0f + cos_w0),
(1.0f + cos_w0) * 0.5f,
(1.0f + alpha),
-2.0f * cos_w0,
(1.0f - alpha));
}
示例8: pow
void HighShelf::setup (double sampleRate,
double cutoffFrequency,
double gainDb,
double shelfSlope)
{
double A = pow (10, gainDb/40);
double w0 = 2 * doublePi * cutoffFrequency / sampleRate;
double cs = cos (w0);
double sn = sin (w0);
double AL = sn / 2 * ::std::sqrt ((A + 1/A) * (1/shelfSlope - 1) + 2);
double sq = 2 * sqrt(A) * AL;
double b0 = A*( (A+1) - (A-1)*cs + sq );
double b1 = -2*A*( (A-1) - (A+1)*cs );
double b2 = A*( (A+1) - (A-1)*cs - sq );
double a0 = (A+1) + (A-1)*cs + sq;
double a1 = 2*( (A-1) + (A+1)*cs );
double a2 = (A+1) + (A-1)*cs - sq;
setCoefficients (a0, a1, a2, b0, b1, b2);
}
示例9: adjust_imag
void BiquadBase::setOnePole (complex_t pole, complex_t zero)
{
#if 0
pole = adjust_imag (pole);
zero = adjust_imag (zero);
#else
assert (pole.imag() == 0);
assert (zero.imag() == 0);
#endif
const double a0 = 1;
const double a1 = -pole.real();
const double a2 = 0;
const double b0 = -zero.real();
const double b1 = 1;
const double b2 = 0;
setCoefficients (a0, a1, a2, b0, b1, b2);
}
示例10: powf
void Biquad::setHighShelf(int32_t steps, float center_frequency, float sampling_frequency, float gainDb, float slope, float overallGainDb)
{
float w0 = 2 * (float) M_PI * center_frequency / sampling_frequency;
float A = powf(10, gainDb/40);
float alpha = sinf(w0)/2 * sqrtf( (A + 1/A)*(1/slope - 1) + 2 );
float b0 = A*( (A+1) + (A-1)*cosf(w0) + 2*sqrtf(A)*alpha );
float b1 = -2*A*( (A-1) + (A+1)*cosf(w0) );
float b2 = A*( (A+1) + (A-1)*cosf(w0) - 2*sqrtf(A)*alpha );
float a0 = (A+1) - (A-1)*cosf(w0) + 2*sqrtf(A)*alpha ;
float a1 = 2*( (A-1) - (A+1)*cosf(w0) );
float a2 = (A+1) - (A-1)*cosf(w0) - 2*sqrtf(A)*alpha ;
float overallGain = powf(10, overallGainDb / 20);
b0 *= overallGain;
b1 *= overallGain;
b2 *= overallGain;
setCoefficients(steps, a0, a1, a2, b0, b1, b2);
}
示例11: jlimit
void BiquadFilter::makeBandPass(const double sampleRate,
const double frequency,
const double Q) noexcept
{
const double qFactor = jlimit (0.00001, 1000.0, Q);
const double oneOverCurrentSampleRate = 1.0 / sampleRate;
float w0 = (float) (2.0f * float_Pi * frequency * oneOverCurrentSampleRate);
float cos_w0 = cos (w0);
float sin_w0 = sin (w0);
float alpha = sin_w0 / (2.0f * (float) qFactor);
// float alpha = sin_w0 * sinh( (log(2.0)/2.0) * bandwidth * w0/sin_w0 );
setCoefficients (alpha,
0.0f,
-alpha,
1.0f + alpha,
-2.0f * cos_w0,
1.0f - alpha);
}
示例12: pow
void Biquad::setHighShelf(int32_t steps, double center_frequency, double sampling_frequency, double gainDb, double slope, double overallGainDb)
{
double w0 = 2 * M_PI * center_frequency / sampling_frequency;
double A = pow(10, gainDb/40);
double alpha = sin(w0)/2 * sqrt( (A + 1/A)*(1/slope - 1) + 2 );
double b0 = A*( (A+1) + (A-1)*cos(w0) + 2*sqrt(A)*alpha );
double b1 = -2*A*( (A-1) + (A+1)*cos(w0) );
double b2 = A*( (A+1) + (A-1)*cos(w0) - 2*sqrt(A)*alpha );
double a0 = (A+1) - (A-1)*cos(w0) + 2*sqrt(A)*alpha ;
double a1 = 2*( (A-1) - (A+1)*cos(w0) );
double a2 = (A+1) - (A-1)*cos(w0) - 2*sqrt(A)*alpha ;
double overallGain = pow(10, overallGainDb / 20);
b0 *= overallGain;
b1 *= overallGain;
b2 *= overallGain;
setCoefficients(steps, a0, a1, a2, b0, b1, b2);
}
示例13: startIt
void ParametersInterpreter<NMSmodelT>::setSubjectParameters(const std::vector<double>& x) {
unsigned count = 0;
for (typename ParametersMap::const_iterator it(parameters_.begin()); it != parameters_.end(); ++it) {
unsigned noCoefficients = it->second.size;
std::vector<double>::const_iterator startIt(x.begin() + count);
std::vector<double>::const_iterator endIt(x.begin() + count + noCoefficients);
std::vector<double> groupedCoefficients(startIt, endIt);
std::vector<double> coefficients;
getCoefficients(it->first, coefficients);
distributeValues(it->second.muscleGroups, coefficients, groupedCoefficients);
setCoefficients(it->first, coefficients);
count += noCoefficients;
}
}
示例14: setCoefficients
void BiquadBase::setIdentity ()
{
setCoefficients (1, 0, 0, 1, 0, 0);
}
示例15: setCoefficients
void BiquadBase::applyScale (double scale)
{
setCoefficients(m_a0, m_a1, m_a2, m_b0 * scale, m_b1 * scale, m_b2 * scale);
}