• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ sample类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中sample的典型用法代码示例。如果您正苦于以下问题:C++ sample类的具体用法?C++ sample怎么用?C++ sample使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了sample类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例2: append

void sample :: append(const sample& s) {
	if (!assertWarning(rate() == s.rate(), "append failed: different rates") ||
		!assertWarning(channels() == s.channels(),
			"append failed: different channel counts"))
		return;
	audioSample* snd = new audioSample[audioSize() + s.audioSize()];
	memcpy(snd, data, bytes());
	memcpy(snd + audioSize(), s.data, s.bytes());
	delete[] data;
	data = snd;
	info.length += s.length();
} // append()
开发者ID:ruohoruotsi,项目名称:Riddim,代码行数:12,代码来源:sample.cpp


示例3: paste

void sample :: paste(const sample& clip, int start, bool replaceFlag) {
	if (!assertWarning(rate() == clip.rate(),"paste failed: different rates") ||
		!assertWarning(channels() == clip.channels(),
			"paste failed: different channel counts"))
		return;
	int limit = clip.length();
	if (start + limit > length())
		limit = length() - start;
	if (replaceFlag)
		memcpy(data+start*channels(), clip.data,
				limit * channels() * sizeof(audioSample));
	else
		for (int i = 0; i < limit * channels(); i++, start++)
			data[start] = audioLimit(clip.data[i] + data[start]);
} // paste()
开发者ID:ruohoruotsi,项目名称:Riddim,代码行数:15,代码来源:sample.cpp


示例4: diff

int sample :: diff(const sample& t) const {
	if (!assertWarning(rate() == t.rate(),"diff: sample rates") ||
		!assertWarning(length() == t.length(),"diff: different lengths") ||
		!assertWarning(channels() == t.channels(), "diff: channel counts"))
		return 1;
	int diffs = 0;
	for (int i=0; (i<audioSize()) && (diffs<10); i++)
		if (data[i] != t.data[i]) {
			if (parameters->debug("sample", "basic"))
				cerr << "Data differs at " << i << " of " << audioSize() <<endl;
			diffs++;
		}
	if (parameters->debug("sample", "basic") && !diffs)
		cerr << "No diffs" << endl;
	return diffs;
} // diffs()
开发者ID:ruohoruotsi,项目名称:Riddim,代码行数:16,代码来源:sample.cpp


示例5: transition

    sample transition(sample& init_sample) {
        this->sample_stepsize();

        this->seed(init_sample.cont_params());

        this->hamiltonian_.sample_p(this->z_, this->rand_int_);
        this->hamiltonian_.init(this->z_);

        ps_point z_init(this->z_);

        double H0 = this->hamiltonian_.H(this->z_);

        for (int i = 0; i < L_; ++i)
            this->integrator_.evolve(this->z_, this->hamiltonian_,
                                     this->epsilon_);

        double h = this->hamiltonian_.H(this->z_);
        if (boost::math::isnan(h)) h = std::numeric_limits<double>::infinity();

        double acceptProb = std::exp(H0 - h);

        if (acceptProb < 1 && this->rand_uniform_() > acceptProb)
            this->z_.ps_point::operator=(z_init);

        acceptProb = acceptProb > 1 ? 1 : acceptProb;

        return sample(this->z_.q, - this->hamiltonian_.V(this->z_), acceptProb);
    }
开发者ID:housian0724,项目名称:stan,代码行数:28,代码来源:base_static_hmc.hpp


示例6: distort

void distort(sample &buf, float amount) {
  if (amount>=0.99) amount = 0.99;

  float k=2*amount/(1-amount);

  for(unsigned int i=0; i<buf.get_length(); i++)
    {
      buf[i]=((1+k)*buf[i]/(1+k*fabs(buf[i])))*(1-amount);
    }
}
开发者ID:nebogeo,项目名称:jellyfish,代码行数:10,代码来源:modules.cpp


示例7: moving_distort

void moving_distort(sample &buf, const sample &amount)
{
  for(unsigned int i=0; i<buf.get_length(); i++)
    {
      float a =fabs(amount[i]);
      if (a>0.99) a = 0.99;
      float k=2*a/(1-a);

      buf[i]=((1+k)*buf[i]/(1+k*fabs(buf[i])))*(1-a);
    }
}
开发者ID:nebogeo,项目名称:jellyfish,代码行数:11,代码来源:modules.cpp


示例8: moving_hard_clip

void moving_hard_clip(sample &buf, const sample &level)
{
  for(unsigned int i=0; i<buf.get_length(); i++)
    {
      float l=fabs(level[i]);
      if (feq(l,0,0.0001)) l=0.0001;
      if (buf[i]>l) buf[i]=l;
      if (buf[i]<-l) buf[i]=-l;
      buf[i]*=1/l;
    }
}
开发者ID:nebogeo,项目名称:jellyfish,代码行数:11,代码来源:modules.cpp


示例9: hard_clip

void hard_clip(sample &buf, float level)
{
  if (feq(level,0,0.0001)) level==0.0001;

  for(unsigned int i=0; i<buf.get_length(); i++)
    {
      if (buf[i]>level) buf[i]=level;
      if (buf[i]<-level) buf[i]=-level;
      buf[i]*=1/level;
    }
}
开发者ID:nebogeo,项目名称:jellyfish,代码行数:11,代码来源:modules.cpp


示例10: test_sample_is_empty

void test_sample_is_empty(const sample &sam, bool is_empty)
{
    assert(sam.empty() == is_empty);
    cout << " Testing empty() of: " << sam;
    if(is_empty){
        cout << " is true";
    } else {
        cout << " is false";
    }
    cout << endl;
    
}
开发者ID:ragnarula1,项目名称:cppcw,代码行数:12,代码来源:unit_tests.cpp


示例11: switch

        void connection::notify_listeners(const sample& sample)
        {
            switch(sample.getType())
            {
            case sample_type::new_frame:
                notify_listeners_about_new_frame();
                break;

            case sample_type::allocation:
                notify_listeners_about_allocation(sample);
                break;
            }
        }
开发者ID:madrenegade,项目名称:PGameStudio,代码行数:13,代码来源:connection.cpp


示例12: crush

void crush(sample &buf, float freq, float bits) {
  float step = pow((float)0.5,(float)bits);
  float phasor = 1;
  float last = 0;

  for(unsigned int i=0; i<buf.get_length(); i++) {
      phasor = phasor + freq;
      if (phasor >= 1.0) {
          phasor = phasor - 1.0;
          last = step * floor( buf[i]/step + 0.5 );
	}
      buf[i] = last;
    }
}
开发者ID:nebogeo,项目名称:jellyfish,代码行数:14,代码来源:modules.cpp


示例13:

sample operator-(sample a, sample b)
{
    return sample{a.value() - b.value()};
}
开发者ID:atakan196,项目名称:code,代码行数:4,代码来源:sample.cpp


示例14: value

sample sample::operator*(sample other) const
{
    sample result;
    result.value_ = value() * other.value(); // can't overflow
    return result;
}
开发者ID:atakan196,项目名称:code,代码行数:6,代码来源:sample.cpp


示例15: test_sample_size

//Sample Tests
void test_sample_size(const sample &sam, uint size)
{
    vector<double> data(sam.get_data());
    assert(data.size() == size);
    cout << " Testing size() of: " << sam << " is " << size << "(" << data.size() << ")" << endl;
}
开发者ID:ragnarula1,项目名称:cppcw,代码行数:7,代码来源:unit_tests.cpp


示例16: interpolate

sample interpolate(sample a, sample weight, sample b)
{
    return sample{(1 - weight.value()) * a.value() + weight.value() * b.value()};
}
开发者ID:atakan196,项目名称:code,代码行数:4,代码来源:sample.cpp


示例17: test_sample_max

void test_sample_max(const sample &sam, double max)
{
    double epsilon = 0.0001;
    assert(abs(sam.maximum() - max) < epsilon);
    cout << " Testing maximum() of: " << sam << " is " << max << "(" << sam.maximum() << ")" << endl;
}
开发者ID:ragnarula1,项目名称:cppcw,代码行数:6,代码来源:unit_tests.cpp


示例18: to_byte

static color32::byte to_byte(sample s) noexcept
{
    return static_cast<color32::byte>(color32::BYTE_MAX * s.value());
}
开发者ID:1726184339,项目名称:code,代码行数:4,代码来源:color.cpp


示例19: transition

 sample transition(sample& init_sample) {
   this->seed(init_sample.cont_params(), init_sample.disc_params());
   return sample(this->_z.q, this->_z.r, - this->_hamiltonian.V(this->_z), 0);
 }
开发者ID:danstowell,项目名称:stan,代码行数:4,代码来源:base_hmc_test.cpp


示例20: test_sample_midrange

void test_sample_midrange(const sample &sam, double midrange)
{
    double epsilon = 0.0001;
    assert(abs(sam.midrange() - midrange) < epsilon);
    cout << " Testing midrange() of: " << sam << " is " << midrange << "(" << sam.midrange() << ")" << endl;
}
开发者ID:ragnarula1,项目名称:cppcw,代码行数:6,代码来源:unit_tests.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ sapi_module_struct类代码示例发布时间:2022-05-31
下一篇:
C++ safe_ptr类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap