本文整理汇总了C++中SoundData::GetSamples方法的典型用法代码示例。如果您正苦于以下问题:C++ SoundData::GetSamples方法的具体用法?C++ SoundData::GetSamples怎么用?C++ SoundData::GetSamples使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoundData
的用法示例。
在下文中一共展示了SoundData::GetSamples方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadResource
ErrorType SoundSource::LoadResource(const String &name,
const SoundData &soundData, SoundCollection *collection)
{
// Check for existing sound with matching checksum
Checksum checksum(soundData.GetSamples().GetData(),
soundData.GetSamples().GetElementCount());
Bind(collection, collection->GetIDByChecksum(checksum));
if (-1 < mID)
return kErrorNone;
// No sound was found, generate new buffer
UInt openALID;
alGenBuffers(1, &openALID);
if (!openALID)
return Error::Throw(kErrorOpenALGenBuffersFailure,
String("[%s(\"%s\", %p)]", FastFunctionName,
name.GetCString(), &soundData));
SoundResource soundResource;
soundResource.SetName(name);
soundResource.SetChecksum(checksum);
soundResource.GetProperties()->SetFormat(soundData.GetProperties().GetFormat());
soundResource.GetProperties()->SetFrequency(soundData.GetProperties().GetFrequency());
soundResource.GetProperties()->SetSampleCount(soundData.GetProperties().GetSampleCount());
soundResource.SetOpenALBufferID(openALID);
soundResource.SetActive(true);
mID = collection->AddResource(soundResource, this);
mCollection = collection;
{
alBufferData(GetResource().GetOpenALBufferID(),
GetResource().GetProperties().GetFormat(),
soundData.GetSamples().GetData(),
soundData.GetSamples().GetElementCount(),
GetResource().GetProperties().GetFrequency());
ALint alErr = alGetError();
switch (alErr)
{
case AL_OUT_OF_MEMORY:
Unbind();
return Error::Throw(kErrorOutOfMemory,
String("[%s(\"%s\", %p)]", FastFunctionName,
name.GetCString(), &soundData));
case AL_INVALID_ENUM:
case AL_INVALID_VALUE:
Unbind();
return Error::Throw(kErrorInvalidValue,
String("[%s(\"%s\", %p)]", FastFunctionName,
name.GetCString(), &soundData));
}
}
return kErrorNone;
}