本文整理汇总了C++中SampleBuffer::size方法的典型用法代码示例。如果您正苦于以下问题:C++ SampleBuffer::size方法的具体用法?C++ SampleBuffer::size怎么用?C++ SampleBuffer::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SampleBuffer
的用法示例。
在下文中一共展示了SampleBuffer::size方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void DSP::Filter::Gain::processSamples(SampleBuffer& samples) {
for(int i = 0; i < samples.size(); ++i) {
auto scaled = static_cast<int64_t>(samples[i]) * m_gain;
samples[i] = saturate<int16_t>(scaled >> 16);
}
}
示例2: swapBuffers
void SingularSampleBuffer::swapBuffers(SampleBuffer& secondaryBuffer) {
DEBUG_ASSERT_CLASS_INVARIANT_SingularSampleBuffer;
DEBUG_ASSERT(m_primaryBuffer.size() == secondaryBuffer.size());
// SampleUtil::copy() requires that the source and destination
// memory regions are disjunct. Double-buffering is necessary
// to satisfy this precondition.
SampleUtil::copy(
secondaryBuffer.data(),
m_primaryBuffer.data(m_headOffset),
getSize());
m_primaryBuffer.swap(secondaryBuffer);
// shift offsets
m_tailOffset -= m_headOffset;
m_headOffset = 0;
DEBUG_ASSERT_CLASS_INVARIANT_SingularSampleBuffer;
}
示例3: MusicHook
void SoundEngine::MusicHook(void* userdata, Uint8* stream, int len)
{
bool* musicFinishedPtr = reinterpret_cast<bool*>(userdata);
if (!*musicFinishedPtr)
{
SampleBuffer buffer;
Uint32 ret = musicDecoder.Decode(buffer, len);
if (ret == SOUND_DECODE_COMPLETED) {
musicDecoder.Close();
*musicFinishedPtr = true;
} else if (ret == SOUND_DECODE_ERROR) {
logger->error("Sound: Error during music decoding, stopping playback of current track.\n");
*musicFinishedPtr = true;
return;
}
memcpy(stream, &buffer[0], buffer.size());
}
}