本文整理汇总了C++中MLSignal::setConstant方法的典型用法代码示例。如果您正苦于以下问题:C++ MLSignal::setConstant方法的具体用法?C++ MLSignal::setConstant怎么用?C++ MLSignal::setConstant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MLSignal
的用法示例。
在下文中一共展示了MLSignal::setConstant方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: calcCoeffs
void MLProcBiquad::calcCoeffs(const int frames)
{
static MLSymbol modeSym("mode");
int mode = (int)getParam(modeSym);
const MLSignal& frequency = getInput(2);
const MLSignal& q = getInput(3);
int coeffFrames;
float twoPiOverSr = kMLTwoPi*getContextInvSampleRate();
bool paramSignalsAreConstant = frequency.isConstant() && q.isConstant();
if (paramSignalsAreConstant)
{
coeffFrames = 1;
}
else
{
coeffFrames = frames;
}
// set proper constant state for coefficient signals
mA0.setConstant(paramSignalsAreConstant);
mA1.setConstant(paramSignalsAreConstant);
mA2.setConstant(paramSignalsAreConstant);
mB1.setConstant(paramSignalsAreConstant);
mB2.setConstant(paramSignalsAreConstant);
float a0, a1, a2, b0, b1, b2;
float qm1, omega, alpha, sinOmega, cosOmega;
float highLimit = getContextSampleRate() * 0.33f;
// generate coefficient signals
// TODO SSE
for(int n=0; n<coeffFrames; ++n)
{
qm1 = 1.f/(q[n] + 0.05f);
omega = clamp(frequency[n], kLowFrequencyLimit, highLimit) * twoPiOverSr;
sinOmega = fsin1(omega);
cosOmega = fcos1(omega);
alpha = sinOmega * 0.5f * qm1;
b0 = 1.f/(1.f + alpha);
switch (mode)
{
default:
case kLowpass:
a0 = ((1.f - cosOmega) * 0.5f) * b0;
a1 = (1.f - cosOmega);
a2 = a0;
b1 = (-2.f * cosOmega);
b2 = (1.f - alpha);
break;
case kHighpass:
a0 = ((1.f + cosOmega) * 0.5f);
a1 = -(1.f + cosOmega);
a2 = a0;
b1 = (-2.f * cosOmega);
b2 = (1.f - alpha);
break;
case kBandpass:
a0 = alpha;
a1 = 0.f;
a2 = -alpha;
b1 = -2.f * cosOmega;
b2 = (1.f - alpha);
break;
case kNotch:
a0 = 1;
a1 = -2.f * cosOmega;
a2 = 1;
b1 = -2.f * cosOmega;
b2 = (1.f - alpha);
break;
}
mA0[n] = a0*b0;
mA1[n] = a1*b0;
mA2[n] = a2*b0;
mB1[n] = b1*b0;
mB2[n] = b2*b0;
}
}