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 ParentChanged; 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 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 ParentChanged; 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;

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

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

Play given sound. If the sound is spatial (TCastleSound.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.

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 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.