本文整理汇总了C++中AudioBuffer::get方法的典型用法代码示例。如果您正苦于以下问题:C++ AudioBuffer::get方法的具体用法?C++ AudioBuffer::get怎么用?C++ AudioBuffer::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AudioBuffer
的用法示例。
在下文中一共展示了AudioBuffer::get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: info
virtual IAudioBuffer *get(unsigned long pos, unsigned int length) noexcept{
sptr<IAudioInfo> info(getInfo());
AudioBuffer *ret = new AudioBuffer(info->getChannels(), length, pos, info->getSamplerate());
unsigned int validInputs = 0;
if(NumInputs() > 0){
for(int i = 0; i < NumInputs(); i++){
if(!InputOk(i)) continue;
validInputs++;
auto tmp = getFromSlot(i, pos, length);
for(unsigned int j = 0; j < length; j++){
sptr<ISample> smp1(ret->get(j));
auto smp2 = getSampleFromBuffer(j, tmp);
*smp1 += *smp2;
ret->set(*smp1, j);
}
}
for(unsigned int j = 0; j < length; j++){
sptr<ISample> smp(ret->get(j));
if(validInputs > 0) *smp /= (float)validInputs;
ret->set(*smp, j);
}
}
return ret;
};
示例2: measure
void Performance::measure(unsigned long length, unsigned int buflen){
if(NumInputs() == 0){
std::cout << "invalid or no Input" << std::endl;
return;
}
double val = 0;
std::chrono::high_resolution_clock::time_point t1 = std::chrono::high_resolution_clock::now();
for(unsigned int i = 0; i < length; i += buflen){
if(i + buflen > length) buflen -= i + buflen - length;
AudioBuffer tmp = getFromSlot(i, buflen, 0);
for(unsigned int j = 0; j < buflen; j++){
val += tmp.get(j).get(0);
}
}
std::chrono::high_resolution_clock::time_point t2 = std::chrono::high_resolution_clock::now();
auto time = std::chrono::duration_cast<std::chrono::microseconds>(t2 - t1).count();
std::cout << "Buffer size: " << buflen << ", total Samples: " << length << ", ";
std::cout << "Time used: " << time << "us, " << time / 1000000 << "s, Final value: " << val << std::endl;
return;
}