本文整理汇总了C++中sample::zero方法的典型用法代码示例。如果您正苦于以下问题:C++ sample::zero方法的具体用法?C++ sample::zero怎么用?C++ sample::zero使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sample
的用法示例。
在下文中一共展示了sample::zero方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: process
void simple_envelope::process(unsigned int buf_size, sample &in, sample &CV, bool smooth)
{
// a bit of a crap filter to smooth clicks
static float SMOOTH = 0.999;
static float ONEMINUS_SMOOTH = 1-SMOOTH;
float one_over_decay=1/m_decay;
float temp=0;
if (m_t==-1000)
{
in.zero();
CV.zero();
m_current=0;
return;
}
for (unsigned int n=0; n<buf_size; n++)
{
// if we are in the delay (before really being triggered)
if (m_t<0)
{
in[n]*=m_current;
CV[n]=m_current;
}
else // in the envelope
{
// if we are in the envelope...
if (m_t<m_decay)
{
// in the decay
temp=(1-m_t*one_over_decay)*m_volume;
if (!feq(temp,m_current,0.01) && smooth)
{
// only filter if necc
temp=(temp*ONEMINUS_SMOOTH+m_current*SMOOTH);
}
in[n]*=temp;
CV[n]=temp;
m_current=temp;
}
else
{
in[n]*=0;
CV[n]=0;
m_current=0;
// we've run off the end
m_t=-1000;
}
}
m_t+=m_sample_time;
}
}