本文整理汇总了C++中SoundInstance::Advance方法的典型用法代码示例。如果您正苦于以下问题:C++ SoundInstance::Advance方法的具体用法?C++ SoundInstance::Advance怎么用?C++ SoundInstance::Advance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoundInstance
的用法示例。
在下文中一共展示了SoundInstance::Advance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Advance
void SoundSystem::Advance()
{
if( !m_channels )
{
return;
}
float timeNow = GetHighResTime();
if( timeNow >= m_timeSync )
{
m_timeSync = timeNow + SOUNDSYSTEM_UPDATEPERIOD;
START_PROFILE("SoundSystem");
#ifndef TARGET_MSVC
((SoundLibrary2dSDL *)g_soundLibrary2d)->m_callbackLock.Lock();
#endif
//
// Resync with blueprints (changed by editor)
START_PROFILE("Propagate Blueprints" );
if( m_propagateBlueprints )
{
PropagateBlueprints();
}
END_PROFILE("Propagate Blueprints" );
//
// First pass : Recalculate all Perceived Sound Volumes
// Throw away sounds that have had their chance
// Build a list of instanceIDs for sorting
START_PROFILE("Allocate Sorted Array" );
static int sortedArraySize = 128;
static SoundInstanceId *sortedIds = NULL;
if( m_sounds.NumUsed() > sortedArraySize )
{
delete [] sortedIds;
sortedIds = NULL;
while( sortedArraySize < m_sounds.NumUsed() )
sortedArraySize *= 2;
}
if( !sortedIds )
{
sortedIds = new SoundInstanceId[ sortedArraySize ];
}
int numSortedIds = 0;
END_PROFILE("Allocate Sorted Array" );
START_PROFILE("Perceived Volumes" );
for( int i = 0; i < m_sounds.Size(); ++i )
{
if( m_sounds.ValidIndex(i) )
{
SoundInstance *instance = m_sounds[i];
if( !instance->IsPlaying() && !instance->m_loopType ) instance->m_restartAttempts--;
if( instance->m_restartAttempts < 0 )
{
ShutdownSound( instance );
}
else if( instance->m_positionType == SoundInstance::Type3DAttachedToObject &&
!instance->GetAttachedObject().IsValid() )
{
ShutdownSound( instance );
}
else
{
instance->CalculatePerceivedVolume();
sortedIds[numSortedIds] = instance->m_id;
numSortedIds++;
}
}
}
END_PROFILE("Perceived Volumes" );
//
// Sort sounds into perceived volume order
// NOTE : There are exactly numSortedId elements in sortedIds.
// NOTE : It isn't safe to assume numSortedIds == m_sounds.NumUsed()
START_PROFILE("Sort Samples" );
qsort( sortedIds, numSortedIds, sizeof(SoundInstanceId), SoundInstanceCompare );
END_PROFILE("Sort Samples" );
//
// Second pass : Recalculate all Sound Priorities starting with the nearest sounds
// Reduce priorities as more of the same sounds are played
BTree<float> existingInstances;
//
// Also look out for the highest priority new sound to swap in
START_PROFILE("Recalculate Priorities" );
//.........这里部分代码省略.........