| 1 |
{ |
| 2 |
Copyright 2010-2022 Michalis Kamburelis. |
| 3 |
|
| 4 |
This file is part of "Castle Game Engine". |
| 5 |
|
| 6 |
"Castle Game Engine" is free software; see the file COPYING.txt, |
| 7 |
included in this distribution, for details about the copyright. |
| 8 |
|
| 9 |
"Castle Game Engine" is distributed in the hope that it will be useful, |
| 10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 12 |
|
| 13 |
---------------------------------------------------------------------------- |
| 14 |
} |
| 15 |
|
| 16 |
{ Cross-platform, spatial sound playback engine (@link(SoundEngine) singleton). } |
| 17 |
unit CastleSoundEngine; |
| 18 |
|
| 19 |
{$I castleconf.inc} |
| 20 |
|
| 21 |
{$ifdef CASTLE_NINTENDO_SWITCH} |
| 22 |
// Nintendo Switch has different default backend |
| 23 |
{$else} |
| 24 |
{ Full-featured backend using OpenAL. } |
| 25 |
{$define CASTLE_SOUND_BACKEND_DEFAULT_OPENAL} |
| 26 |
{$endif} |
| 27 |
|
| 28 |
{$ifdef CASTLE_STRICT_CLI} |
| 29 |
{$error When CASTLE_STRICT_CLI is defined, you cannot link to this unit.} |
| 30 |
{$endif} |
| 31 |
|
| 32 |
{$ifndef FPC} |
| 33 |
{ Ignore the TSoundEngine.InternalBackend exposing private ancestor field. |
| 34 |
This makes this property not useful from C++ Builder |
| 35 |
( https://docwiki.embarcadero.com/RADStudio/Alexandria/en/W1045_Property_declaration_references_ancestor_private_%27%25s.%25s%27_(Delphi) ) |
| 36 |
but it is an internal property anyway, no code should use it. } |
| 37 |
{$warn PRIVATE_PROPACCESSOR off} |
| 38 |
{$endif} |
| 39 |
|
| 40 |
interface |
| 41 |
|
| 42 |
uses SysUtils, Classes, Math, Generics.Collections, DOM, |
| 43 |
CastleVectors, CastleTimeUtils, CastleClassUtils, CastleStringUtils, |
| 44 |
CastleSoundBase, CastleInternalSoundFile, CastleInternalAbstractSoundBackend, |
| 45 |
CastleXMLConfig; |
| 46 |
|
| 47 |
{$define read_interface} |
| 48 |
type |
| 49 |
{$I castlesoundengine_initial_types.inc} |
| 50 |
{$I castlesoundengine_internalsoundbuffer.inc} |
| 51 |
{$I castlesoundengine_internalsoundsource.inc} |
| 52 |
{$I castlesoundengine_sound.inc} |
| 53 |
{$I castlesoundengine_playingsound.inc} |
| 54 |
{$I castlesoundengine_allocator.inc} |
| 55 |
{$I castlesoundengine_playsoundparameters.inc} |
| 56 |
{$I castlesoundengine_engine.inc} |
| 57 |
{$I castlesoundengine_repoengine.inc} |
| 58 |
{$I castlesoundengine_loopingchannel.inc} |
| 59 |
{$I castlesoundengine_miscellaneous.inc} |
| 60 |
{$undef read_interface} |
| 61 |
|
| 62 |
implementation |
| 63 |
|
| 64 |
uses XMLRead, StrUtils, Generics.Defaults, |
| 65 |
CastleUtils, CastleLog, CastleInternalVorbisFile, CastleInternalDataURI, |
| 66 |
CastleParameters, CastleXmlUtils, CastleFilesUtils, CastleConfig, |
| 67 |
CastleUriUtils, CastleDownload, CastleMessaging, CastleApplicationProperties |
| 68 |
{$ifdef CASTLE_SOUND_BACKEND_DEFAULT_OPENAL}, CastleOpenALSoundBackend{$endif} |
| 69 |
, CastleComponentSerialize; |
| 70 |
|
| 71 |
{$define read_implementation} |
| 72 |
{$I castlesoundengine_miscellaneous.inc} // must be first, as defines some internal globals |
| 73 |
{$I castlesoundengine_internalsoundbuffer.inc} |
| 74 |
{$I castlesoundengine_internalsoundsource.inc} |
| 75 |
{$I castlesoundengine_sound.inc} |
| 76 |
{$I castlesoundengine_playingsound.inc} |
| 77 |
{$I castlesoundengine_allocator.inc} |
| 78 |
{$I castlesoundengine_playsoundparameters.inc} |
| 79 |
{$I castlesoundengine_engine.inc} |
| 80 |
{$I castlesoundengine_repoengine.inc} |
| 81 |
{$I castlesoundengine_loopingchannel.inc} |
| 82 |
{$undef read_implementation} |
| 83 |
|
| 84 |
initialization |
| 85 |
RegisterSerializableComponent(TCastleSound, 'Sound'); |
| 86 |
finalization |
| 87 |
FreeAndNil(FSoundEngine); |
| 88 |
end. |