![]() |
Gondwana Game Engine
Gondwana is a cross-platform 2.5D game and rendering engine written in C#/.NET 8. It provides fine-grained control over rendering, timing, and scene composition, with built-in support for parallax, z-ordering, pixel overhang, collision detection, and particle effects. Gondwana targets desktop, mobile, and web platforms using SkiaSharp for graphics and NAudio for sound.
|
Manages the lifecycle of audio resources, providing loading, retrieval, cloning, and disposal functionality. More...
Public Member Functions | |
| AudioResource | LoadFromFile (string key, string filePath, float volume=1.0f, float pan=0.0f) |
| Loads an audio resource from a file on disk. | |
| AudioResource | LoadFromStream (string key, Stream input, string fileExt, float volume=1.0f, float pan=0.0f) |
| Loads an audio resource from a stream. | |
| List< AudioResource > | LoadFromEngineResourceFile (AssetsFile resourceFile, float defaultVolume=1.0f, float defaultPan=0.0f) |
| Loads all audio resources from an AssetsFile. | |
| AudioResource? | Clone (string key, string? newKey=null, float? volume=null, float? pan=null) |
| Creates a copy of an existing audio resource with a new key and optionally different settings. | |
| void | Unload (string key) |
| Unloads a sound resource by its key, disposing of it and removing it from the manager. | |
| void | Clear () |
| Clears all sound resources, disposing of each one. | |
| bool | TryGet (string key, out AudioResource? resource) |
| Attempts to retrieve an audio resource by its key. | |
| AudioResource? | Get (string key) |
| Retrieves an audio resource by its key. | |
| bool | Contains (string key) |
| Determines whether the manager contains an audio resource with the specified key. | |
| IEnumerable< string > | GetAllKeys () |
| Gets all keys of audio resources currently managed by this instance. | |
| Dictionary< string, AudioResource > | GetAll () |
| Gets all audio resources currently managed by this instance as a dictionary. | |
| void | Dispose () |
| Releases all resources used by the AudioResourceManager. | |
Properties | |
| static AudioResourceManager | Instance [get] |
| Singleton instance of the AudioResourceManager. | |
Events | |
| EventHandler<(string Key, AudioResource Resource)>? | SoundDisposed |
| Event that is raised when a sound resource is disposed. | |
Manages the lifecycle of audio resources, providing loading, retrieval, cloning, and disposal functionality.
This class implements the singleton pattern to ensure a single instance manages all audio resources throughout the application. It supports loading audio from files, streams, and asset files, and tracks all loaded resources in a thread-safe manner.
| void Gondwana.Audio.AudioResourceManager.Clear | ( | ) |
Clears all sound resources, disposing of each one.
| AudioResource? Gondwana.Audio.AudioResourceManager.Clone | ( | string | key, |
| string? | newKey = null, | ||
| float? | volume = null, | ||
| float? | pan = null ) |
Creates a copy of an existing audio resource with a new key and optionally different settings.
Cloning requires the original resource to have its raw byte data available. If the new key already exists or the original resource cannot be found, the method returns null.
| key | The key of the existing audio resource to clone. |
| newKey | The key for the cloned resource. If null, a unique key will be generated automatically. |
| volume | The volume level for the cloned resource. If null, uses the original resource's volume. |
| pan | The stereo pan position for the cloned resource. If null, uses the original resource's pan. |
null.| bool Gondwana.Audio.AudioResourceManager.Contains | ( | string | key | ) |
Determines whether the manager contains an audio resource with the specified key.
| key | The key to check for existence. |
true if the manager contains an audio resource with the specified key; otherwise, false.| void Gondwana.Audio.AudioResourceManager.Dispose | ( | ) |
Releases all resources used by the AudioResourceManager.
This method clears all managed audio resources, disposing of each one. After disposal, the manager should not be used further.
| AudioResource? Gondwana.Audio.AudioResourceManager.Get | ( | string | key | ) |
Retrieves an audio resource by its key.
| key | The unique identifier of the audio resource to retrieve. |
null.| Dictionary< string, AudioResource > Gondwana.Audio.AudioResourceManager.GetAll | ( | ) |
Gets all audio resources currently managed by this instance as a dictionary.
| IEnumerable< string > Gondwana.Audio.AudioResourceManager.GetAllKeys | ( | ) |
Gets all keys of audio resources currently managed by this instance.
| List< AudioResource > Gondwana.Audio.AudioResourceManager.LoadFromEngineResourceFile | ( | AssetsFile | resourceFile, |
| float | defaultVolume = 1::0f, | ||
| float | defaultPan = 0::0f ) |
Loads all audio resources from an AssetsFile.
This method iterates through all audio entries in the asset file and loads them into the manager. Resources that are already loaded will be skipped. Failed loads are logged but do not prevent other resources from being loaded.
| resourceFile | The AssetsFile containing audio resources. |
| defaultVolume | The default volume level for all loaded audio resources, ranging from 0.0 to 1.0. Defaults to 1.0. |
| defaultPan | The default stereo pan position for all loaded audio resources, ranging from -1.0 to 1.0. Defaults to 0.0. |
| AudioResource Gondwana.Audio.AudioResourceManager.LoadFromFile | ( | string | key, |
| string | filePath, | ||
| float | volume = 1::0f, | ||
| float | pan = 0::0f ) |
Loads an audio resource from a file on disk.
If a resource with the same key already exists, it will be disposed and replaced with the new resource. The audio file format is determined by the file extension.
| key | A unique identifier for the audio resource. |
| filePath | The path to the audio file on disk. |
| volume | The initial volume level for the audio resource, ranging from 0.0 (silent) to 1.0 (full volume). Defaults to 1.0. |
| pan | The initial stereo pan position, ranging from -1.0 (full left) to 1.0 (full right). Defaults to 0.0 (center). |
| AudioResource Gondwana.Audio.AudioResourceManager.LoadFromStream | ( | string | key, |
| Stream | input, | ||
| string | fileExt, | ||
| float | volume = 1::0f, | ||
| float | pan = 0::0f ) |
Loads an audio resource from a stream.
If a resource with the same key already exists, it will be disposed and replaced with the new resource. The audio format is determined by the specified file extension.
| key | A unique identifier for the audio resource. |
| input | The stream containing the audio data. |
| fileExt | The file extension indicating the audio format (e.g., ".wav", ".mp3"). |
| volume | The initial volume level for the audio resource, ranging from 0.0 (silent) to 1.0 (full volume). Defaults to 1.0. |
| pan | The initial stereo pan position, ranging from -1.0 (full left) to 1.0 (full right). Defaults to 0.0 (center). |
| bool Gondwana.Audio.AudioResourceManager.TryGet | ( | string | key, |
| out AudioResource? | resource ) |
Attempts to retrieve an audio resource by its key.
| key | The unique identifier of the audio resource to retrieve. |
| resource | When this method returns, contains the AudioResource associated with the specified key, if the key is found; otherwise, null. |
true if the audio resource was found; otherwise, false.| void Gondwana.Audio.AudioResourceManager.Unload | ( | string | key | ) |
Unloads a sound resource by its key, disposing of it and removing it from the manager.
| key | Unique identifier for AudioResource. |
|
staticget |
Singleton instance of the AudioResourceManager.
| EventHandler<(string Key, AudioResource Resource)>? Gondwana.Audio.AudioResourceManager.SoundDisposed |
Event that is raised when a sound resource is disposed.