Class TSoundAllocator
Unit
Declaration
type TSoundAllocator = class(TObject)
Description
Manager of allocated sounds.
For efficiency, the pool of available sound sources (things that are actually audible at a given time) is limited. This limit comes from the backend limits (like OpenAL or APIs underneath OpenAL), it may also come from sound hardware limitations, and in general you should not have too many playing sources, as mixing many sources is time-consuming. So you cannot simply allocate new sound source for each of 100 creatures you display in the game.
This class hides this limitation, by managing a pool of sound sources, and returning on demand the next unused sound source (or Nil
). It can prioritize sound sources, it can reuse sound sources that finished playing, it can interrupt a lower-priority sound when necessary to play a higher-priority sound.
This is automatically used by higher-level comfortable methods to play sounds like TSoundEngine.Play.
Hierarchy
- TObject
- TSoundAllocator
Overview
Fields
nested const DefaultMinAllocatedSources = 4; |
|
nested const DefaultMaxAllocatedSources = 16; |
Methods
constructor Create; |
|
destructor Destroy; override; |
Properties
property MinAllocatedSources: Cardinal
read FMinAllocatedSources write SetMinAllocatedSources
default DefaultMinAllocatedSources; |
|
property MaxAllocatedSources: Cardinal
read FMaxAllocatedSources write SetMaxAllocatedSources
default DefaultMaxAllocatedSources; |
|
property InternalAllocatedSources: TInternalSoundSourceList read FAllocatedSources; |
|
property IsContextOpenSuccess: boolean read FIsContextOpenSuccess; |
Description
Fields
nested const DefaultMinAllocatedSources = 4; |
|
This item has no description. |
nested const DefaultMaxAllocatedSources = 16; |
|
This item has no description. |
Methods
constructor Create; |
|
This item has no description. |
destructor Destroy; override; |
|
This item has no description. |
Properties
property MinAllocatedSources: Cardinal
read FMinAllocatedSources write SetMinAllocatedSources
default DefaultMinAllocatedSources; |
|
Minimum / maximum number of allocated sources. Always keep For the sake of speed, we always keep allocated at least At most MaxAllocatedSources sources may be simultaneously used (played). This prevents us from allocating too many sounds, which would be bad for speed (not to mention that it may be impossible under some backends, like OpenAL on Windows). When all MaxAllocatedSources sources are playing, the only way to play another sound is to use appropriately high |
property MaxAllocatedSources: Cardinal
read FMaxAllocatedSources write SetMaxAllocatedSources
default DefaultMaxAllocatedSources; |
|
This item has no description. |
property InternalAllocatedSources: TInternalSoundSourceList read FAllocatedSources; |
|
All allocated (not necessarily used) sources. Accessing this is useful only for debugging tasks, in normal circumstances this is internal. This is |
property IsContextOpenSuccess: boolean read FIsContextOpenSuccess; |
|
Do we have active sound rendering context. This is You should not need this property much. The whole CastleSoundEngine API works regardless if the context was successfully open or not. However, reading this is useful to display to user warning e.g. "Sound could not be initialized for some reason" (use TSoundEngine.Information to get the details). In case of OpenAL backend, this also implies that OpenAL library is loaded. |
Generated by PasDoc 0.16.0-snapshot.