本文整理汇总了C++中sample::get_length方法的典型用法代码示例。如果您正苦于以下问题:C++ sample::get_length方法的具体用法?C++ sample::get_length怎么用?C++ sample::get_length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sample
的用法示例。
在下文中一共展示了sample::get_length方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
示例2: 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;
}
}
示例3: 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;
}
}
示例4: 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);
}
}
示例5: 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;
}
}