本文整理汇总了C++中FAudioDeviceManager::GetSoundBufferForResourceID方法的典型用法代码示例。如果您正苦于以下问题:C++ FAudioDeviceManager::GetSoundBufferForResourceID方法的具体用法?C++ FAudioDeviceManager::GetSoundBufferForResourceID怎么用?C++ FAudioDeviceManager::GetSoundBufferForResourceID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FAudioDeviceManager
的用法示例。
在下文中一共展示了FAudioDeviceManager::GetSoundBufferForResourceID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Init
/**
* Static function used to create a buffer.
*
* @param InWave USoundWave to use as template and wave source
* @param AudioDevice audio device to attach created buffer to
* @return FXAudio2SoundBuffer pointer if buffer creation succeeded, NULL otherwise
*/
FXAudio2SoundBuffer* FXAudio2SoundBuffer::Init( FAudioDevice* AudioDevice, USoundWave* Wave, bool bForceRealTime )
{
// Can't create a buffer without any source data
if( Wave == NULL || Wave->NumChannels == 0 )
{
return( NULL );
}
FAudioDeviceManager* AudioDeviceManager = GEngine->GetAudioDeviceManager();
FXAudio2Device* XAudio2Device = ( FXAudio2Device* )AudioDevice;
FXAudio2SoundBuffer* Buffer = NULL;
// Allow the precache to happen if necessary
EDecompressionType DecompressionType = Wave->DecompressionType;
if (bForceRealTime && DecompressionType != DTYPE_Setup && DecompressionType != DTYPE_Streaming)
{
DecompressionType = DTYPE_RealTime;
}
switch( DecompressionType )
{
case DTYPE_Setup:
// Has circumvented precache mechanism - precache now
AudioDevice->Precache(Wave, true, false);
// if it didn't change, we will recurse forever
check(Wave->DecompressionType != DTYPE_Setup);
// Recall this function with new decompression type
return( Init( AudioDevice, Wave, bForceRealTime ) );
case DTYPE_Preview:
// Find the existing buffer if any
if( Wave->ResourceID )
{
Buffer = (FXAudio2SoundBuffer*)AudioDeviceManager->GetSoundBufferForResourceID(Wave->ResourceID);
}
// Override with any new PCM data even if some already exists.
if( Wave->RawPCMData )
{
// Upload the preview PCM data to it
Buffer = CreatePreviewBuffer( XAudio2Device, Wave, Buffer );
}
break;
case DTYPE_Procedural:
// Always create a new buffer for streaming procedural data
Buffer = CreateProceduralBuffer( XAudio2Device, Wave );
break;
case DTYPE_RealTime:
// Always create a new buffer for streaming ogg vorbis data
Buffer = CreateQueuedBuffer( XAudio2Device, Wave );
break;
case DTYPE_Native:
case DTYPE_Xenon:
// Upload entire wav to XAudio2
if( Wave->ResourceID )
{
Buffer = (FXAudio2SoundBuffer*)AudioDeviceManager->GetSoundBufferForResourceID(Wave->ResourceID);
}
if( Buffer == NULL )
{
Buffer = CreateNativeBuffer( XAudio2Device, Wave );
}
break;
case DTYPE_Streaming:
// Always create a new buffer for streaming sounds
Buffer = CreateStreamingBuffer( XAudio2Device, Wave );
break;
case DTYPE_Invalid:
default:
// Invalid will be set if the wave cannot be played
break;
}
return( Buffer );
}