#include <GameAudio.h>
Inherits SubsystemInterface.
Inherited by MilesAudioManager.
Public Member Functions | |
| AudioManager () | |
| virtual | ~AudioManager () |
| virtual void | init () |
| virtual void | postProcessLoad () |
| virtual void | reset () |
| virtual void | update () |
| virtual void | stopAudio (AudioAffect which)=0 |
| virtual void | pauseAudio (AudioAffect which)=0 |
| virtual void | resumeAudio (AudioAffect which)=0 |
| virtual void | pauseAmbient (Bool shouldPause)=0 |
| virtual void | loseFocus (void) |
| virtual void | regainFocus (void) |
| virtual AudioHandle | addAudioEvent (const AudioEventRTS *eventToAdd) |
| Add an audio event (event must be declared in an INI file) | |
| virtual void | removeAudioEvent (AudioHandle audioEvent) |
| Remove an audio event, stop for instance. | |
| virtual void | killAudioEventImmediately (AudioHandle audioEvent)=0 |
| virtual Bool | isValidAudioEvent (const AudioEventRTS *eventToCheck) const |
| validate that this piece of audio exists | |
| virtual Bool | isValidAudioEvent (AudioEventRTS *eventToCheck) const |
| validate that this piece of audio exists | |
| void | addTrackName (const AsciiString &trackName) |
| AsciiString | nextTrackName (const AsciiString ¤tTrack) |
| AsciiString | prevTrackName (const AsciiString ¤tTrack) |
| virtual void | nextMusicTrack (void)=0 |
| virtual void | prevMusicTrack (void)=0 |
| virtual Bool | isMusicPlaying (void) const =0 |
| virtual Bool | hasMusicTrackCompleted (const AsciiString &trackName, Int numberOfTimes) const =0 |
| virtual AsciiString | getMusicTrackName (void) const =0 |
| virtual void | setAudioEventEnabled (AsciiString eventToAffect, Bool enable) |
| virtual void | setAudioEventVolumeOverride (AsciiString eventToAffect, Real newVolume) |
| virtual void | removeAudioEvent (AsciiString eventToRemove) |
| virtual void | removeDisabledEvents () |
| virtual void | getInfoForAudioEvent (const AudioEventRTS *eventToFindAndFill) const |
| virtual Bool | isCurrentlyPlaying (AudioHandle handle) |
| virtual void | openDevice (void)=0 |
| virtual void | closeDevice (void)=0 |
| virtual void * | getDevice (void)=0 |
| virtual void | notifyOfAudioCompletion (UnsignedInt audioCompleted, UnsignedInt flags)=0 |
| virtual UnsignedInt | getProviderCount (void) const =0 |
| virtual AsciiString | getProviderName (UnsignedInt providerNum) const =0 |
| virtual UnsignedInt | getProviderIndex (AsciiString providerName) const =0 |
| virtual void | selectProvider (UnsignedInt providerNdx)=0 |
| virtual void | unselectProvider (void)=0 |
| virtual UnsignedInt | getSelectedProvider (void) const =0 |
| virtual void | setSpeakerType (UnsignedInt speakerType)=0 |
| virtual UnsignedInt | getSpeakerType (void)=0 |
| virtual UnsignedInt | translateSpeakerTypeToUnsignedInt (const AsciiString &speakerType) |
| virtual AsciiString | translateUnsignedIntToSpeakerType (UnsignedInt speakerType) |
| virtual UnsignedInt | getNum2DSamples (void) const =0 |
| virtual UnsignedInt | getNum3DSamples (void) const =0 |
| virtual UnsignedInt | getNumStreams (void) const =0 |
| virtual Bool | doesViolateLimit (AudioEventRTS *event) const =0 |
| virtual Bool | isPlayingLowerPriority (AudioEventRTS *event) const =0 |
| virtual Bool | isPlayingAlready (AudioEventRTS *event) const =0 |
| virtual Bool | isObjectPlayingVoice (UnsignedInt objID) const =0 |
| virtual void | adjustVolumeOfPlayingAudio (AsciiString eventName, Real newVolume)=0 |
| virtual void | removePlayingAudio (AsciiString eventName)=0 |
| virtual void | removeAllDisabledAudio ()=0 |
| virtual Bool | isOn (AudioAffect whichToGet) const |
| virtual void | setOn (Bool turnOn, AudioAffect whichToAffect) |
| virtual void | setVolume (Real volume, AudioAffect whichToAffect) |
| virtual Real | getVolume (AudioAffect whichToGet) |
| virtual void | set3DVolumeAdjustment (Real volumeAdjustment) |
| virtual Bool | has3DSensitiveStreamsPlaying (void) const =0 |
| virtual void * | getHandleForBink (void)=0 |
| virtual void | releaseHandleForBink (void)=0 |
| virtual void | friend_forcePlayAudioEventRTS (const AudioEventRTS *eventToPlay)=0 |
| virtual void | setListenerPosition (const Coord3D *newListenerPos, const Coord3D *newListenerOrientation) |
| virtual const Coord3D * | getListenerPosition (void) const |
| virtual AudioRequest * | allocateAudioRequest (Bool useAudioEvent) |
| virtual void | releaseAudioRequest (AudioRequest *requestToRelease) |
| virtual void | appendAudioRequest (AudioRequest *m_request) |
| virtual void | processRequestList (void) |
| virtual AudioEventInfo * | newAudioEventInfo (AsciiString newEventName) |
| virtual void | addAudioEventInfo (AudioEventInfo *newEventInfo) |
| virtual AudioEventInfo * | findAudioEventInfo (AsciiString eventName) const |
| const AudioSettings * | getAudioSettings (void) const |
| const MiscAudio * | getMiscAudio (void) const |
| virtual void | releaseAudioEventRTS (AudioEventRTS *eventToRelease) |
| AudioSettings * | friend_getAudioSettings (void) |
| MiscAudio * | friend_getMiscAudio (void) |
| const FieldParse * | getFieldParseTable (void) const |
| const AudioEventRTS * | getValidSilentAudioEvent () const |
| virtual void | setHardwareAccelerated (Bool accel) |
| virtual Bool | getHardwareAccelerated () |
| virtual void | setSpeakerSurround (Bool surround) |
| virtual Bool | getSpeakerSurround () |
| virtual void | refreshCachedVariables () |
| virtual void | setPreferredProvider (AsciiString providerNdx)=0 |
| virtual void | setPreferredSpeaker (AsciiString speakerType)=0 |
| virtual Real | getAudioLengthMS (const AudioEventRTS *event) |
| virtual Real | getFileLengthMS (AsciiString strToLoad) const =0 |
| virtual void | closeAnySamplesUsingFile (const void *fileToClose)=0 |
| virtual Bool | isMusicAlreadyLoaded (void) const |
| virtual Bool | isMusicPlayingFromCD (void) const |
| Bool | getDisallowSpeech (void) const |
| void | setDisallowSpeech (Bool disallowSpeech) |
| virtual void | findAllAudioEventsOfType (AudioType audioType, std::vector< AudioEventInfo * > &allEvents) |
| virtual const AudioEventInfoHash & | getAllAudioEvents () const |
| Real | getZoomVolume () const |
Public Member Functions inherited from SubsystemInterface | |
| SubsystemInterface () | |
| virtual | ~SubsystemInterface () |
| virtual void | draw (void) |
| void | UPDATE (void) |
| void | DRAW (void) |
| AsciiString | getName (void) |
| void | setName (AsciiString name) |
Protected Types | |
| enum | { NUM_VOLUME_TYPES = 4 } |
Protected Member Functions | |
| virtual Bool | isCurrentProviderHardwareAccelerated () |
| virtual Bool | isCurrentSpeakerTypeSurroundSound () |
| virtual Bool | shouldPlayLocally (const AudioEventRTS *audioEvent) |
| virtual void | setDeviceListenerPosition (void)=0 |
| virtual AudioHandle | allocateNewHandle (void) |
| virtual void | removeLevelSpecificAudioEventInfos (void) |
| void | removeAllAudioRequests (void) |
The life of audio.
When audio is requested to play, it is done so in the following manner: 1) An AudioEventRTS is created on the stack. 2) Its guts are copied from elsewhere (for instance, a ThingTemplate, or MiscAudio). 3) It is added to TheAudio via TheAudio->addAudioEvent(...)
The return value from addAudioEvent can be saved in case the sound needs to loop and/or be terminated at some point.
To reomve a playing sound, the call TheAudio->removeAudioEvent(...) is used. This will search the list of currently playing audio for the specified handle, and kill the attached sound. It will play a decay sound, if one is specified.
The important functions of TheAudio, are therefore GameAudio::addAudioEvent() GameAudio::removeAudioEvent() All other functions exist to support these two basic requirements.
In addition to the fundamental requirements, the audio has a fairly complicated sound management scheme. If all units were always allowed to sound off, the sound engine would be overwhelmed and would sound awful. Therefore, when an audio event is requested, it goes through a series of checks to determine if it is near enough to the camera, if it should be heard based on shroud, local player affiliation, etc. (The entire list of checks is contained in shouldPlayLocally()).
In addition, the world and unit audio are never allowed to exceed their footprint, as specified in the audio settings INI file. In order to accomodate this, the audio uses an audio cache. The audio cache will attempt to load a sample, assuming there is enough room. If there is not enough room, then it goes through and finds any samples that are lower priority, and kills them until enough room is present for the sample. If it cannot free enough room, nothing happens to the cache.
Although the audio is multithreaded, most of the operations are performed such that the worst case scenario for thread miscommunication is that the main thread misses an event for one frame. One specific case of this is the status of playing audio. Because audio is playing asynchronously, it can complete at any time. When most audio completes, it sets a flag on the event noting that it has completed. During the next update (from the main thread), anything with that flag set is moved to the stopped list, and then is cleaned up. (Basically, the audio uses a push model for its multithreadedness, which doesn't require thread safety such as mutexes or semaphores).
All in all, the best way to learn how the audio works is to track the lifetime of an event through the system. This will give a better understanding than all the documentation I could write.
-jkmcd -December 2002
Definition at line 134 of file GameAudio.h.
|
protected |
| Enumerator | |
|---|---|
| NUM_VOLUME_TYPES | |
Definition at line 358 of file GameAudio.h.
| AudioManager::AudioManager | ( | ) |
Definition at line 147 of file GameAudio.cpp.
|
virtual |
Definition at line 184 of file GameAudio.cpp.
|
virtual |
Add an audio event (event must be declared in an INI file)
Definition at line 414 of file GameAudio.cpp.
|
virtual |
Definition at line 857 of file GameAudio.cpp.
| void AudioManager::addTrackName | ( | const AsciiString & | trackName | ) |
Definition at line 527 of file GameAudio.cpp.
|
pure virtual |
Implemented in MilesAudioManager.
|
virtual |
Definition at line 802 of file GameAudio.cpp.
|
protectedvirtual |
Definition at line 1086 of file GameAudio.cpp.
|
virtual |
Definition at line 819 of file GameAudio.cpp.
|
pure virtual |
Implemented in MilesAudioManager.
|
pure virtual |
Implemented in MilesAudioManager.
|
pure virtual |
Implemented in MilesAudioManager.
|
virtual |
Definition at line 990 of file GameAudio.cpp.
|
virtual |
Definition at line 873 of file GameAudio.cpp.
|
pure virtual |
Implemented in MilesAudioManager.
| AudioSettings * AudioManager::friend_getAudioSettings | ( | void | ) |
Definition at line 913 of file GameAudio.cpp.
| MiscAudio * AudioManager::friend_getMiscAudio | ( | void | ) |
Definition at line 925 of file GameAudio.cpp.
|
inlinevirtual |
Definition at line 300 of file GameAudio.h.
|
virtual |
Definition at line 944 of file GameAudio.cpp.
| const AudioSettings * AudioManager::getAudioSettings | ( | void | ) | const |
Definition at line 907 of file GameAudio.cpp.
|
pure virtual |
Implemented in MilesAudioManager.
|
inline |
Definition at line 295 of file GameAudio.h.
| const FieldParse * AudioManager::getFieldParseTable | ( | void | ) | const |
Definition at line 931 of file GameAudio.cpp.
|
pure virtual |
Implemented in MilesAudioManager.
|
pure virtual |
Implemented in MilesAudioManager.
|
inlinevirtual |
Definition at line 275 of file GameAudio.h.
|
virtual |
Definition at line 399 of file GameAudio.cpp.
|
virtual |
Definition at line 796 of file GameAudio.cpp.
| const MiscAudio * AudioManager::getMiscAudio | ( | void | ) | const |
Definition at line 919 of file GameAudio.cpp.
|
pure virtual |
Implemented in MilesAudioManager.
|
pure virtual |
Implemented in MilesAudioManager.
|
pure virtual |
Implemented in MilesAudioManager.
|
pure virtual |
Implemented in MilesAudioManager.
|
pure virtual |
Implemented in MilesAudioManager.
|
pure virtual |
Implemented in MilesAudioManager.
|
pure virtual |
Implemented in MilesAudioManager.
|
pure virtual |
Implemented in MilesAudioManager.
|
inlinevirtual |
Definition at line 278 of file GameAudio.h.
|
pure virtual |
Implemented in MilesAudioManager.
|
inline |
Definition at line 272 of file GameAudio.h.
|
virtual |
Definition at line 758 of file GameAudio.cpp.
|
inline |
Definition at line 302 of file GameAudio.h.
|
pure virtual |
Implemented in MilesAudioManager.
|
pure virtual |
Implemented in MilesAudioManager.
|
virtual |
Implements SubsystemInterface.
Reimplemented in MilesAudioManager.
Definition at line 216 of file GameAudio.cpp.
|
virtual |
< Return whether the current audio is playing or not. NOTE NOTE NOTE !!DO NOT USE THIS IN FOR GAMELOGIC PURPOSES!! NOTE NOTE NOTE
Reimplemented in MilesAudioManager.
Definition at line 651 of file GameAudio.cpp.
|
protectedvirtual |
Definition at line 1002 of file GameAudio.cpp.
|
protectedvirtual |
Definition at line 1014 of file GameAudio.cpp.
|
virtual |
Definition at line 963 of file GameAudio.cpp.
|
pure virtual |
Implemented in MilesAudioManager.
|
inlinevirtual |
Definition at line 293 of file GameAudio.h.
|
pure virtual |
Implemented in MilesAudioManager.
|
virtual |
Definition at line 679 of file GameAudio.cpp.
|
pure virtual |
Implemented in MilesAudioManager.
|
pure virtual |
Implemented in MilesAudioManager.
|
virtual |
validate that this piece of audio exists
Definition at line 514 of file GameAudio.cpp.
|
virtual |
validate that this piece of audio exists
Definition at line 502 of file GameAudio.cpp.
|
pure virtual |
Implemented in MilesAudioManager.
|
virtual |
Definition at line 1103 of file GameAudio.cpp.
|
virtual |
Definition at line 843 of file GameAudio.cpp.
|
pure virtual |
Implemented in MilesAudioManager.
| AsciiString AudioManager::nextTrackName | ( | const AsciiString & | currentTrack | ) |
Definition at line 533 of file GameAudio.cpp.
|
pure virtual |
Implemented in MilesAudioManager.
|
pure virtual |
Implemented in MilesAudioManager.
|
pure virtual |
Implemented in MilesAudioManager.
|
pure virtual |
Implemented in MilesAudioManager.
|
virtual |
Reimplemented from SubsystemInterface.
Reimplemented in MilesAudioManager.
Definition at line 286 of file GameAudio.cpp.
|
pure virtual |
Implemented in MilesAudioManager.
| AsciiString AudioManager::prevTrackName | ( | const AsciiString & | currentTrack | ) |
Definition at line 557 of file GameAudio.cpp.
|
virtual |
Reimplemented in MilesAudioManager.
Definition at line 837 of file GameAudio.cpp.
|
virtual |
Definition at line 937 of file GameAudio.cpp.
|
virtual |
Definition at line 1118 of file GameAudio.cpp.
|
virtual |
Definition at line 1093 of file GameAudio.cpp.
|
virtual |
Definition at line 811 of file GameAudio.cpp.
|
pure virtual |
Implemented in MilesAudioManager.
|
protected |
Definition at line 826 of file GameAudio.cpp.
|
pure virtual |
Implemented in MilesAudioManager.
|
virtual |
Definition at line 639 of file GameAudio.cpp.
|
virtual |
Remove an audio event, stop for instance.
Definition at line 581 of file GameAudio.cpp.
|
virtual |
Definition at line 645 of file GameAudio.cpp.
|
protectedvirtual |
Definition at line 886 of file GameAudio.cpp.
|
pure virtual |
Implemented in MilesAudioManager.
|
virtual |
Implements SubsystemInterface.
Reimplemented in MilesAudioManager.
Definition at line 292 of file GameAudio.cpp.
|
pure virtual |
Implemented in MilesAudioManager.
|
pure virtual |
Implemented in MilesAudioManager.
|
virtual |
Definition at line 773 of file GameAudio.cpp.
|
virtual |
Definition at line 599 of file GameAudio.cpp.
|
virtual |
Definition at line 605 of file GameAudio.cpp.
|
protectedpure virtual |
Implemented in MilesAudioManager.
|
inline |
Definition at line 296 of file GameAudio.h.
|
inlinevirtual |
Reimplemented in MilesAudioManager.
Definition at line 274 of file GameAudio.h.
|
virtual |
Definition at line 789 of file GameAudio.cpp.
|
virtual |
Definition at line 694 of file GameAudio.cpp.
|
pure virtual |
Implemented in MilesAudioManager.
|
pure virtual |
Implemented in MilesAudioManager.
|
inlinevirtual |
Reimplemented in MilesAudioManager.
Definition at line 277 of file GameAudio.h.
|
pure virtual |
Implemented in MilesAudioManager.
|
virtual |
Definition at line 714 of file GameAudio.cpp.
|
protectedvirtual |
Definition at line 1020 of file GameAudio.cpp.
|
pure virtual |
Implemented in MilesAudioManager.
|
virtual |
Definition at line 657 of file GameAudio.cpp.
|
virtual |
Definition at line 669 of file GameAudio.cpp.
|
pure virtual |
Implemented in MilesAudioManager.
|
virtual |
Implements SubsystemInterface.
Reimplemented in MilesAudioManager.
Definition at line 313 of file GameAudio.cpp.
|
protected |
Definition at line 337 of file GameAudio.h.
|
protected |
Definition at line 335 of file GameAudio.h.
|
protected |
Definition at line 332 of file GameAudio.h.
|
protected |
Definition at line 326 of file GameAudio.h.
|
protected |
Definition at line 372 of file GameAudio.h.
|
protected |
Definition at line 367 of file GameAudio.h.
|
protected |
Definition at line 331 of file GameAudio.h.
|
protected |
Definition at line 330 of file GameAudio.h.
|
protected |
Definition at line 327 of file GameAudio.h.
|
protected |
Definition at line 328 of file GameAudio.h.
|
protected |
Definition at line 365 of file GameAudio.h.
|
protected |
Definition at line 369 of file GameAudio.h.
|
protected |
Definition at line 333 of file GameAudio.h.
|
protected |
Definition at line 339 of file GameAudio.h.
|
protected |
Definition at line 359 of file GameAudio.h.
|
protected |
Definition at line 344 of file GameAudio.h.
|
protected |
Definition at line 346 of file GameAudio.h.
|
protected |
Definition at line 345 of file GameAudio.h.
|
protected |
Definition at line 347 of file GameAudio.h.
|
protected |
Definition at line 356 of file GameAudio.h.
|
protected |
Definition at line 329 of file GameAudio.h.
|
protected |
Definition at line 364 of file GameAudio.h.
|
protected |
Definition at line 341 of file GameAudio.h.
|
protected |
Definition at line 363 of file GameAudio.h.
|
protected |
Definition at line 340 of file GameAudio.h.
|
protected |
Definition at line 362 of file GameAudio.h.
|
protected |
Definition at line 342 of file GameAudio.h.
|
protected |
Definition at line 368 of file GameAudio.h.
|
protected |
Definition at line 349 of file GameAudio.h.
|
protected |
Definition at line 351 of file GameAudio.h.
|
protected |
Definition at line 350 of file GameAudio.h.
|
protected |
Definition at line 352 of file GameAudio.h.
|
protected |
Definition at line 366 of file GameAudio.h.
|
protected |
Definition at line 353 of file GameAudio.h.
|
protected |
Definition at line 336 of file GameAudio.h.