当前位置: 首页>>代码示例>>C++>>正文


C++ sample::zero方法代码示例

本文整理汇总了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;
    }
}
开发者ID:nebogeo,项目名称:jellyfish,代码行数:54,代码来源:modules.cpp


注:本文中的sample::zero方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。