Game Development Reference
In-Depth Information
// Function called in-game to play a sound. Returns a
// SoundInstance for the game to use.
SoundInstance * SoundSystem::playSound( SoundEvent * event,
Params & params,
unsigned int owner_id )
{
if ( SnapShot::isAllowedCategory( event->m_category ) )
{
SoundInstance * inst = SoundEngine::play( event,
params,
owner_id );
return inst;
}
return null;
}
Listing 11.1. Modifications to a play sound function to support debugging.
After the audio update has occurred for each frame, we can start to construct
our data buffer to be sent over to the GUI tool. This buffer must contain the
updated information on the game's audio state to keep the GUI tool up to date.
Listing 11.2 shows a sample update function for the game to update the GUI tool.
The update function fills in a large buffer, which is sent over to the GUI tool.
// Function called once per frame to update UI tool.
void SnapShot::updateGUITool()
{
Buffer * buf;
CreateBufferToSendToGUITool(buf);
SoundInstance *inst = SoundEngine::getFirstActiveInstance();
for ( ;inst; inst = inst->getNextActiveInstance() )
{
// Add all information about an active SoundInstance
// to the update buffer.
buff->addSoundInstance(inst->getEvent()->getName(),
inst->getWaveFilename(),
inst->getVolume(),
inst->getPitch(),
inst->getEvent()->getCategories(),
inst->getDSPChain(),
inst->getAnyVariableBindings() );
}
// Add the names of loaded sound packs and their memory
// footprint to the update buffer.
SoundPack *pack = SoundEngine::getFirstLoadedPack();
for ( ;pack; pack = pack->getNextLoadedPack() )
{
buff->addPackInfo(pack->getName(),pack->getSize());
}
// Add our sound categories and their volume settings
Search WWH ::




Custom Search