Class TCastleSoundSource

Unit

Declaration

type TCastleSoundSource = class(TCastleBehavior)

Description

Behavior to play spatial sounds, that automatically follow the parent TCastleTransform transformation. Multiple such behaviors may be attached to a single TCastleTransform (if you need to play multiple looping sounds, or want to have multiple playback settings like different Volume control).

Hierarchy

Overview

Methods

Protected procedure ParentAfterAttach; override;
Protected procedure ParentBeforeDetach; override;
Protected procedure Notification(AComponent: TComponent; Operation: TOperation); override;
Public constructor Create(AOwner: TComponent); override;
Public destructor Destroy; override;
Public procedure Update(const SecondsPassed: Single; var RemoveMe: TRemoveType); override;
Public function PropertySections(const PropertyName: String): TPropertySections; override;
Public procedure Play(const ASound: TCastleSound); overload;
Public procedure Play(const PlayingSound: TCastlePlayingSoundSource); overload;

Properties

Published property Sound: TCastleSound read FSound write SetSound;
Published property SoundPlaying: Boolean read FSoundPlaying write SetSoundPlaying default true;
Published property Spatial: Boolean read FSpatial write SetSpatial default true;
Published property Volume: Single read FVolume write SetVolume default 1.0;
Published property Pitch: Single read FPitch write SetPitch default 1.0;

Description

Methods

Protected procedure ParentAfterAttach; override;

This item has no description. Showing description inherited from TCastleBehavior.ParentAfterAttach.

Called after Parent changed, e.g. at the end of TCastleTransform.AddBehavior.

Protected procedure ParentBeforeDetach; override;

This item has no description. Showing description inherited from TCastleBehavior.ParentBeforeDetach.

Called before Parent changed, e.g. at the beginning of TCastleTransform.RemoveBehavior.

This is also called at the destruction of behavior (more precisely from BeforeDestruction now). Even in this case, we guarantee that Parent is still valid during this call, and not in half-destroyed state. Before the actual destructor of TCastleBehavior we do BeforeParentDetach and BeforeWorldDetach and set Parent to Nil.

Protected procedure Notification(AComponent: TComponent; Operation: TOperation); override;

This item has no description.

Public constructor Create(AOwner: TComponent); override;

This item has no description.

Public destructor Destroy; override;

This item has no description.

Public procedure Update(const SecondsPassed: Single; var RemoveMe: TRemoveType); override;

This item has no description. Showing description inherited from TCastleBehavior.Update.

Continuously occuring event, for various tasks.

Public function PropertySections(const PropertyName: String): TPropertySections; override;

This item has no description. Showing description inherited from TCastleComponent.PropertySections.

Section where to show property in the editor.

Public procedure Play(const ASound: TCastleSound); overload;

Play given sound once (not looping). If the sound source is spatial (TCastleSoundSource.Spatial), it's 3D position will reflect the Parent (TCastleTransform) position.

Public procedure Play(const PlayingSound: TCastlePlayingSoundSource); overload;

Play given sound. If the sound source is spatial (TCastleSoundSource.Spatial), it's 3D position will reflect the Parent (TCastleTransform) position.

Set TCastlePlayingSound.Sound before passing it to this method. Otherwise, if TCastlePlayingSound.Sound is left Nil, nothing will be played.

Use the TCastlePlayingSound properties to provide additional information about the sound playback. E.g. assign TCastlePlayingSound.Loop TCastlePlayingSound.OnStop or control sound afterwards by TCastlePlayingSound.Stop, TCastlePlayingSound.Offset.

Consider using TCastlePlayingSound.FreeOnStop if you don't want to manage the lifetime of the TCastlePlayingSound instance.

Properties

Published property Sound: TCastleSound read FSound write SetSound;

Sound to play, always looping. Control playback of it using SoundPlaying.

Note that this is not the only sound possible to play using this TCastleSoundSource. You can play any other TCastleSound or TCastlePlayingSoundSource instance (looping or not looping) by calling Play method.

Published property SoundPlaying: Boolean read FSoundPlaying write SetSoundPlaying default true;

Is the Sound currently playing. Setting it to False and back to True will restart playing sound from the beginning.

Published property Spatial: Boolean read FSpatial write SetSpatial default true;

Is the sound playback spatialized. Affects sounds played by assigning Sound or calling Play here.

Spatial sounds are louder/more silent depending on their 3D distance to listener (this means a distance from TCastleTransform origin to the camera within the TCastleViewport). And their relative position to the listener in 3D is reflected by making them louder/more silent in the proper (e.g. left or right) speaker.

Note that some sound backends (like OpenAL) can only spatialize mono sounds, and play stereo sounds always as non-spatialized.

Published property Volume: Single read FVolume write SetVolume default 1.0;

Volume (how loud the playing sound is).

The effective sound volume is a multiplication of TCastleSound.Volume, TCastlePlayingSound.Volume and TCastleSoundSource.Volume. It is also affected by spatial calculations (if the sound is played with TCastleSoundSource.Spatial = True) and finally by a master SoundEngine.Volume.

Any value > 0 is allowed.

Published property Pitch: Single read FPitch write SetPitch default 1.0;

Sound playing speed.

The effective sound pitch is a multiplication of TCastleSound.Pitch, TCastlePlayingSound.Pitch and TCastleSoundSource.Pitch.

Any value > 0 is allowed.


Generated by PasDoc 0.16.0-snapshot.