本文整理汇总了C++中AudioBuffer::convert_channels方法的典型用法代码示例。如果您正苦于以下问题:C++ AudioBuffer::convert_channels方法的具体用法?C++ AudioBuffer::convert_channels怎么用?C++ AudioBuffer::convert_channels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AudioBuffer
的用法示例。
在下文中一共展示了AudioBuffer::convert_channels方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convert
void AudioBuffer::convert(const AudioSpec &_new_spec)
{
if(_new_spec == m_spec) {
return;
}
AudioSpec new_spec = _new_spec;
AudioBuffer dest[2];
unsigned bufidx = 0;
AudioBuffer *source = this;
if(source->rate() != new_spec.rate) {
#if HAVE_LIBSAMPLERATE
if(source->format() != AUDIO_FORMAT_F32) {
dest[1].set_spec({AUDIO_FORMAT_F32, source->channels(), source->rate()});
source->convert_format(dest[1], source->frames());
source = &dest[1];
}
dest[0].set_spec({source->format(), source->channels(), new_spec.rate});
source->convert_rate(dest[0], source->frames(), nullptr);
source = &dest[0];
bufidx = 1;
#else
new_spec.rate = source->rate();
#endif
}
if(source->channels() != new_spec.channels) {
dest[bufidx].set_spec({source->format(),new_spec.channels,source->rate()});
source->convert_channels(dest[bufidx], source->frames());
source = &dest[bufidx];
bufidx = (bufidx + 1) % 2;
}
if(source->format() != new_spec.format) {
dest[bufidx].set_spec({new_spec.format,source->channels(),source->rate()});
source->convert_format(dest[bufidx], source->frames());
source = &dest[bufidx];
}
if(new_spec != m_spec) {
m_data = source->m_data;
m_spec = new_spec;
}
}