Class TSound
Unit
Declaration
type TSound = class(TObject)
Description
Sound source that can be immediately played.
Hierarchy
- TObject
- TSound
Overview
Methods
![]() |
constructor Create(const SoundEngineBackend: TSoundEngineBackend); |
![]() |
destructor Destroy; override; |
![]() |
procedure Release; virtual; |
![]() |
function PlayingOrPaused: boolean; |
![]() |
procedure KeepPlaying; |
Properties
![]() |
property Used: boolean read FUsed default false; |
![]() |
property Importance: Integer read FImportance default 0; |
![]() |
property UserData: TObject read FUserData write FUserData; |
![]() |
property OnRelease: TSoundEvent read FOnRelease write FOnRelease; |
![]() |
property Position: TVector3 read FPosition write SetPosition; |
![]() |
property Velocity: TVector3 read FVelocity write SetVelocity; |
![]() |
property Looping: boolean read FLooping write SetLooping; |
![]() |
property Relative: boolean read FRelative write SetRelative; |
![]() |
property Gain: Single read FGain write SetGain; |
![]() |
property MinGain: Single read FMinGain write SetMinGain; |
![]() |
property MaxGain: Single read FMaxGain write SetMaxGain; |
![]() |
property Buffer: TSoundBuffer read FBuffer write SetBuffer; |
![]() |
property Pitch: Single read FPitch write SetPitch; |
![]() |
property RolloffFactor: Single read FRolloffFactor write SetRolloffFactor; |
![]() |
property ReferenceDistance: Single read FReferenceDistance write SetReferenceDistance; |
![]() |
property MaxDistance: Single read FMaxDistance write SetMaxDistance; |
![]() |
property Offset: Single read GetOffset write SetOffset; |
Description
Methods
![]() |
constructor Create(const SoundEngineBackend: TSoundEngineBackend); |
|
Create sound. This allocates sound source using the sound backend (like OpenAL source). Exceptions raised
| |
![]() |
destructor Destroy; override; |
![]() |
procedure Release; virtual; |
|
Stops playing the source, sets Used to You can call this if you want to stop playing the sound. This will also immediately set Used property to You can call this only when Used = | |
![]() |
function PlayingOrPaused: boolean; |
|
Is the sound playing or paused. This is almost always | |
![]() |
procedure KeepPlaying; |
|
Make sure that the sound keeps playing, in case it stopped playing. This is an alternative approach to play a sound many times, like in a loop, but without using the Looping property. The idea is that you leave Looping set to Note that you still (as always when using TSound) must observe the TSound.OnRelease. When it's called, it means that the sound engine (TSoundEngine) decided that this sound should be used for other purposes (there's also a very small chance that the sound engine "caught" the sound as unused, in a short time when it stopped playing but you didn't yet call this method). In such case, you must stop doing anything with this TSound instance (including calling this method, Note that calling this method is better than observing TSound.OnRelease, to start playing a new sound when the previous one stopped. That's because TSound.OnRelease may be called with some small delay after the sound actually stopped, and it may be noticeable (e.g. in case of using this for a short rhytmic sound, like footsteps). | |
Properties
![]() |
property Used: boolean read FUsed default false; |
|
Do we play something. Sources that are not Used are still allocated on the sound backend (like OpenAL), and will be used when we will need them. | |
![]() |
property Importance: Integer read FImportance default 0; |
|
The priority of keeping this source, relevant only when Used. Higher | |
![]() |
property UserData: TObject read FUserData write FUserData; |
|
Any data comfortable to keep here by the caller of TSoundAllocator.AllocateSound. It should be initialized after calling TSoundAllocator.AllocateSound, and should be finalized in OnRelease. | |
![]() |
property OnRelease: TSoundEvent read FOnRelease write FOnRelease; |
|
Called when this sound will no longer be used. This may happen because it simply finished playing, or when there are more demanding sounds (see Importance and to keep MaxAllocatedSources) and we must use this sound source for something else. When this event occurs, you should forget (e.g. set to It's guaranteed that when this will be called, Used will be Note that we do not guarantee that sources that stopped playing will be immediately reported to | |
![]() |
property Position: TVector3 read FPosition write SetPosition; |
![]() |
property Velocity: TVector3 read FVelocity write SetVelocity; |
![]() |
property Looping: boolean read FLooping write SetLooping; |
![]() |
property Relative: boolean read FRelative write SetRelative; |
![]() |
property Gain: Single read FGain write SetGain; |
![]() |
property MinGain: Single read FMinGain write SetMinGain; |
![]() |
property MaxGain: Single read FMaxGain write SetMaxGain; |
![]() |
property Buffer: TSoundBuffer read FBuffer write SetBuffer; |
![]() |
property Pitch: Single read FPitch write SetPitch; |
![]() |
property RolloffFactor: Single read FRolloffFactor write SetRolloffFactor; |
![]() |
property ReferenceDistance: Single read FReferenceDistance write SetReferenceDistance; |
![]() |
property MaxDistance: Single read FMaxDistance write SetMaxDistance; |
![]() |
property Offset: Single read GetOffset write SetOffset; |
|
Playback time of this sound, expressed in seconds. This value will loop back to zero for looping sound sources. Setting this to something larger than the sound buffer duration is ignored. This offset refers to the sound like it had a Pitch equal 1.0 (when the sound is not slowed down or sped up). So this offset will vary from 0 to the sound buffer duration, regardless of the current Pitch value. The actual seconds passed since the sound started playing may be different, if you will change the Pitch to something else than 1.0. Setting this on a not-yet playing sound source (this is done by TSoundEngine.PlaySound) causes the sound to start playing from that offset. | |
Generated by PasDoc 0.16.0.
