本文整理汇总了C++中SoundInstance::BeginRelease方法的典型用法代码示例。如果您正苦于以下问题:C++ SoundInstance::BeginRelease方法的具体用法?C++ SoundInstance::BeginRelease怎么用?C++ SoundInstance::BeginRelease使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoundInstance
的用法示例。
在下文中一共展示了SoundInstance::BeginRelease方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StopAllSounds
void SoundSystem::StopAllSounds( SoundObjectId _id, char *_eventName )
{
for( int i = 0; i < m_sounds.Size(); ++i )
{
if( m_sounds.ValidIndex(i) )
{
SoundInstance *instance = m_sounds[i];
if( instance->m_objId == _id )
{
if( !_eventName || stricmp(instance->m_eventName, _eventName) == 0 )
{
if( instance->IsPlaying() )
{
instance->BeginRelease(true);
}
else
{
ShutdownSound( instance );
}
}
}
}
}
}
示例2: SoundLibraryMainCallback
bool SoundSystem::SoundLibraryMainCallback( unsigned int _channel, signed short *_data,
unsigned int _numSamples, int *_silenceRemaining )
{
if( !g_soundSystem ) return false;
SoundInstanceId soundId = g_soundSystem->m_channels[_channel];
SoundInstance *instance = g_soundSystem->GetSoundInstance( soundId );
bool stereo = g_soundSystem->IsMusicChannel(_channel);
if( instance && instance->m_soundSampleHandle )
{
//
// Fill the space with sample data
float relFreq = g_soundLibrary3d->GetChannelRelFreq(_channel);
int numSamplesWritten = instance->m_soundSampleHandle->Read( _data, _numSamples, stereo, relFreq);
if( numSamplesWritten < _numSamples )
{
signed short *loopStart = _data + numSamplesWritten;
unsigned int numSamplesRemaining = _numSamples - numSamplesWritten;
if( instance->m_loopType == SoundInstance::Looped ||
instance->m_loopType == SoundInstance::LoopedADSR )
{
while( numSamplesRemaining > 0 )
{
bool looped = instance->AdvanceLoop();
if( looped )
{
unsigned int numWritten = instance->m_soundSampleHandle->Read( loopStart, numSamplesRemaining, stereo , relFreq);
loopStart += numWritten;
numSamplesRemaining -= numWritten;
}
else
{
g_soundLibrary3d->WriteSilence( loopStart, numSamplesRemaining );
numSamplesRemaining = 0;
}
}
}
else if( instance->m_loopType == SoundInstance::SinglePlay)
{
if( numSamplesWritten > 0 )
{
// The sound just came to an end, so write a whole buffers worth of silence
g_soundLibrary3d->WriteSilence( loopStart, numSamplesRemaining );
*_silenceRemaining = g_soundLibrary3d->GetChannelBufSize(_channel) - numSamplesRemaining;
}
else
{
// The sound came to an end and now we are writing silence
g_soundLibrary3d->WriteSilence( loopStart, numSamplesRemaining );
*_silenceRemaining -= numSamplesRemaining;
if( *_silenceRemaining <= 0 )
{
instance->BeginRelease(false);
}
}
}
}
return true;
}
else
{
g_soundLibrary3d->WriteSilence( _data, _numSamples );
return false;
}
}