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


C++ sample类代码示例

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


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


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