本文整理汇总了C++中setNormalizedCoefficients函数的典型用法代码示例。如果您正苦于以下问题:C++ setNormalizedCoefficients函数的具体用法?C++ setNormalizedCoefficients怎么用?C++ setNormalizedCoefficients使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setNormalizedCoefficients函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: pow
void Biquad::setHighShelfParams(double frequency, double dbGain)
{
// Clip frequencies to between 0 and 1, inclusive.
frequency = std::max(0.0, std::min(frequency, 1.0));
double A = pow(10.0, dbGain / 40);
if (frequency == 1) {
// The z-transform is 1.
setNormalizedCoefficients(1, 0, 0,
1, 0, 0);
} else if (frequency > 0) {
double w0 = piDouble * frequency;
double S = 1; // filter slope (1 is max value)
double alpha = 0.5 * sin(w0) * sqrt((A + 1 / A) * (1 / S - 1) + 2);
double k = cos(w0);
double k2 = 2 * sqrt(A) * alpha;
double aPlusOne = A + 1;
double aMinusOne = A - 1;
double b0 = A * (aPlusOne + aMinusOne * k + k2);
double b1 = -2 * A * (aMinusOne + aPlusOne * k);
double b2 = A * (aPlusOne + aMinusOne * k - k2);
double a0 = aPlusOne - aMinusOne * k + k2;
double a1 = 2 * (aMinusOne - aPlusOne * k);
double a2 = aPlusOne - aMinusOne * k - k2;
setNormalizedCoefficients(b0, b1, b2, a0, a1, a2);
} else {
// When frequency = 0, the filter is just a gain, A^2.
setNormalizedCoefficients(A * A, 0, 0,
1, 0, 0);
}
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_external_chromium_org_third_party_WebKit,代码行数:34,代码来源:Biquad.cpp
示例2: sin
void Biquad::setNotchParams(double frequency, double Q)
{
// Clip frequencies to between 0 and 1, inclusive.
frequency = std::max(0.0, std::min(frequency, 1.0));
// Don't let Q go negative, which causes an unstable filter.
Q = std::max(0.0, Q);
if (frequency > 0 && frequency < 1) {
if (Q > 0) {
double w0 = piDouble * frequency;
double alpha = sin(w0) / (2 * Q);
double k = cos(w0);
double b0 = 1;
double b1 = -2 * k;
double b2 = 1;
double a0 = 1 + alpha;
double a1 = -2 * k;
double a2 = 1 - alpha;
setNormalizedCoefficients(b0, b1, b2, a0, a1, a2);
} else {
// When Q = 0, the above formulas have problems. If we look at
// the z-transform, we can see that the limit as Q->0 is 0, so
// set the filter that way.
setNormalizedCoefficients(0, 0, 0,
1, 0, 0);
}
} else {
// When frequency is 0 or 1, the z-transform is 1.
setNormalizedCoefficients(1, 0, 0,
1, 0, 0);
}
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_external_chromium_org_third_party_WebKit,代码行数:35,代码来源:Biquad.cpp
示例3: setNormalizedCoefficients
void Biquad::setLowpassParams(double cutoff, double resonance)
{
// Limit cutoff to 0 to 1.
cutoff = std::max(0.0, std::min(cutoff, 1.0));
if (cutoff == 1) {
// When cutoff is 1, the z-transform is 1.
setNormalizedCoefficients(1, 0, 0,
1, 0, 0);
} else if (cutoff > 0) {
// Compute biquad coefficients for lowpass filter
resonance = std::max(0.0, resonance); // can't go negative
double g = pow(10.0, 0.05 * resonance);
double d = sqrt((4 - sqrt(16 - 16 / (g * g))) / 2);
double theta = piDouble * cutoff;
double sn = 0.5 * d * sin(theta);
double beta = 0.5 * (1 - sn) / (1 + sn);
double gamma = (0.5 + beta) * cos(theta);
double alpha = 0.25 * (0.5 + beta - gamma);
double b0 = 2 * alpha;
double b1 = 2 * 2 * alpha;
double b2 = 2 * alpha;
double a1 = 2 * -gamma;
double a2 = 2 * beta;
setNormalizedCoefficients(b0, b1, b2, 1, a1, a2);
} else {
// When cutoff is zero, nothing gets through the filter, so set
// coefficients up correctly.
setNormalizedCoefficients(0, 0, 0,
1, 0, 0);
}
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_external_chromium_org_third_party_WebKit,代码行数:35,代码来源:Biquad.cpp
示例4: setNormalizedCoefficients
void Biquad::setLowpassParams(double cutoff, double resonance) {
// Limit cutoff to 0 to 1.
cutoff = std::max(0.0, std::min(cutoff, 1.0));
if (cutoff == 1) {
// When cutoff is 1, the z-transform is 1.
setNormalizedCoefficients(1, 0, 0, 1, 0, 0);
} else if (cutoff > 0) {
// Compute biquad coefficients for lowpass filter
resonance = std::max(0.0, resonance); // can't go negative
double g = pow(10.0, -0.05 * resonance);
double w0 = M_PI * cutoff;
double cos_w0 = cos(w0);
double alpha = 0.5 * sin(w0) * g;
double b1 = 1.0 - cos_w0;
double b0 = 0.5 * b1;
double b2 = b0;
double a0 = 1.0 + alpha;
double a1 = -2.0 * cos_w0;
double a2 = 1.0 - alpha;
setNormalizedCoefficients(b0, b1, b2, a0, a1, a2);
} else {
// When cutoff is zero, nothing gets through the filter, so set
// coefficients up correctly.
setNormalizedCoefficients(0, 0, 0, 1, 0, 0);
}
}
开发者ID:jasonLaster,项目名称:gecko-dev,代码行数:29,代码来源:Biquad.cpp
示例5: setNormalizedCoefficients
Biquad::Biquad()
{
// Initialize as pass-thru (straight-wire, no filter effect)
setNormalizedCoefficients(1, 0, 0, 1, 0, 0);
reset(); // clear filter memory
}
开发者ID:LaiPhil,项目名称:gecko-dev,代码行数:7,代码来源:Biquad.cpp
示例6: OS
Biquad::Biquad()
{
#if OS(DARWIN)
// Allocate two samples more for filter history
m_inputBuffer.allocate(kBufferSize + 2);
m_outputBuffer.allocate(kBufferSize + 2);
#endif
// Initialize as pass-thru (straight-wire, no filter effect)
setNormalizedCoefficients(1, 0, 0, 1, 0, 0);
reset(); // clear filter memory
}
开发者ID:meshula,项目名称:LabSound,代码行数:13,代码来源:Biquad.cpp
示例7: abs
void Biquad::setZeroPolePairs(const Complex& zero, const Complex& pole) {
double b0 = 1;
double b1 = -2 * zero.real();
double zeroMag = abs(zero);
double b2 = zeroMag * zeroMag;
double a1 = -2 * pole.real();
double poleMag = abs(pole);
double a2 = poleMag * poleMag;
setNormalizedCoefficients(b0, b1, b2, 1, a1, a2);
}
开发者ID:jasonLaster,项目名称:gecko-dev,代码行数:13,代码来源:Biquad.cpp
示例8: sin
void Biquad::setBandpassParams(double frequency, double Q)
{
double w0 = piDouble * frequency;
double alpha = sin(w0) / (2 * Q);
double k = cos(w0);
double b0 = alpha;
double b1 = 0;
double b2 = -alpha;
double a0 = 1 + alpha;
double a1 = -2 * k;
double a2 = 1 - alpha;
setNormalizedCoefficients(b0, b1, b2, a0, a1, a2);
}
开发者ID:sysrqb,项目名称:chromium-src,代码行数:16,代码来源:Biquad.cpp
示例9: OS
Biquad::Biquad()
{
#if OS(DARWIN)
// Allocate two samples more for filter history
m_inputBuffer.allocate(kBufferSize + 2);
m_outputBuffer.allocate(kBufferSize + 2);
#endif
#if USE(WEBAUDIO_IPP)
int bufferSize;
ippsIIRGetStateSize64f_BiQuad_32f(1, &bufferSize);
m_ippInternalBuffer = ippsMalloc_8u(bufferSize);
#endif // USE(WEBAUDIO_IPP)
// Initialize as pass-thru (straight-wire, no filter effect)
setNormalizedCoefficients(1, 0, 0, 1, 0, 0);
reset(); // clear filter memory
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_external_chromium_org_third_party_WebKit,代码行数:19,代码来源:Biquad.cpp
示例10: pow
void Biquad::setHighShelfParams(double frequency, double dbGain)
{
double w0 = piDouble * frequency;
double A = pow(10.0, dbGain / 40);
double S = 1; // filter slope (1 is max value)
double alpha = 0.5 * sin(w0) * sqrt((A + 1 / A) * (1 / S - 1) + 2);
double k = cos(w0);
double k2 = 2 * sqrt(A) * alpha;
double aPlusOne = A + 1;
double aMinusOne = A - 1;
double b0 = A * (aPlusOne + aMinusOne * k + k2);
double b1 = -2 * A * (aMinusOne + aPlusOne * k);
double b2 = A * (aPlusOne + aMinusOne * k - k2);
double a0 = aPlusOne - aMinusOne * k + k2;
double a1 = 2 * (aMinusOne - aPlusOne * k);
double a2 = aPlusOne - aMinusOne * k - k2;
setNormalizedCoefficients(b0, b1, b2, a0, a1, a2);
}
开发者ID:sysrqb,项目名称:chromium-src,代码行数:23,代码来源:Biquad.cpp
注:本文中的setNormalizedCoefficients函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论