| 1 |
{%MainUnit castlesoundengine.pas} |
| 2 |
{ |
| 3 |
Copyright 2010-2021 Michalis Kamburelis. |
| 4 |
|
| 5 |
This file is part of "Castle Game Engine". |
| 6 |
|
| 7 |
"Castle Game Engine" is free software; see the file COPYING.txt, |
| 8 |
included in this distribution, for details about the copyright. |
| 9 |
|
| 10 |
"Castle Game Engine" is distributed in the hope that it will be useful, |
| 11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 13 |
|
| 14 |
---------------------------------------------------------------------------- |
| 15 |
} |
| 16 |
|
| 17 |
{$ifdef read_interface} |
| 18 |
|
| 19 |
//type // allow type declaration to continue |
| 20 |
|
| 21 |
{ Parameters to use when playing sound, see @link(TSoundEngine.PlaySound). |
| 22 |
|
| 23 |
@exclude Deprecated now, as @link(TSoundEngine.PlaySound) is deprecated. |
| 24 |
Playback properties are now in @link(TCastleSound), |
| 25 |
and some more in @link(TCastlePlayingSound). } |
| 26 |
TPlaySoundParameters = class |
| 27 |
strict private |
| 28 |
FPriority: Single; |
| 29 |
procedure SetPriority(const Value: Single); |
| 30 |
public |
| 31 |
Buffer: TInternalSoundBuffer; |
| 32 |
Spatial, Loop: Boolean; |
| 33 |
|
| 34 |
{ How loud is the sound. By default 1.0. } |
| 35 |
Volume: Single; |
| 36 |
|
| 37 |
{ MinGain and MaxGain determine how volume can change because of spatialization |
| 38 |
(where the sound may get quieter / louder as you get further / closer to it). |
| 39 |
By default MinGain is 0.0, MaxGain is 1.0. } |
| 40 |
MinGain: Single platform { this feature is only available with OpenAL sound backend }; |
| 41 |
MaxGain: Single platform { this feature is only available with OpenAL sound backend }; |
| 42 |
|
| 43 |
{ The position of sound in 3D space. |
| 44 |
Used only if @link(Spatial) = @true. } |
| 45 |
Position: TVector3; |
| 46 |
{ Pitch allows to play the sound faster. By default it is 1.0. } |
| 47 |
Pitch: Single; |
| 48 |
{ See @link(TCastleSound.ReferenceDistance), by default 1. } |
| 49 |
ReferenceDistance: Single; |
| 50 |
{ See @link(TCastleSound.MaxDistance), by default 10000. } |
| 51 |
MaxDistance: Single; |
| 52 |
{ Offset is a position in time of the sound. } |
| 53 |
Offset: Single; |
| 54 |
|
| 55 |
{ See TCastleSound.Priority for range and meaning. } |
| 56 |
property Priority: Single read FPriority write SetPriority {$ifdef FPC}default 0.5{$endif}; |
| 57 |
|
| 58 |
constructor Create; |
| 59 |
end; |
| 60 |
|
| 61 |
TSoundParameters = TPlaySoundParameters deprecated 'use TPlaySoundParameters'; |
| 62 |
|
| 63 |
{$endif read_interface} |
| 64 |
|
| 65 |
{$ifdef read_implementation} |
| 66 |
|
| 67 |
{ TPlaySoundParameters ----------------------------------------------------------- } |
| 68 |
|
| 69 |
constructor TPlaySoundParameters.Create; |
| 70 |
begin |
| 71 |
inherited; |
| 72 |
FPriority := 0.5; |
| 73 |
Volume := 1; |
| 74 |
{$warnings off} // using unportable symbols knowingly |
| 75 |
MaxGain := 1; |
| 76 |
{$warnings on} |
| 77 |
Pitch := 1; |
| 78 |
ReferenceDistance := TCastleSound.DefaultReferenceDistance; |
| 79 |
MaxDistance := TCastleSound.DefaultMaxDistance; |
| 80 |
end; |
| 81 |
|
| 82 |
procedure TPlaySoundParameters.SetPriority(const Value: Single); |
| 83 |
begin |
| 84 |
if not Between(Value, 0.0, 1.0) then |
| 85 |
begin |
| 86 |
WritelnWarning('Sound priority must be within 0..1 range, but is %f', [Value]); |
| 87 |
FPriority := Clamped(Value, 0.0, 1.0); |
| 88 |
end else |
| 89 |
FPriority := Value; |
| 90 |
end; |
| 91 |
|
| 92 |
{$endif read_implementation} |