Gondwana Game Engine Development (master) - 2.6.1
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 and web platforms using SkiaSharp for graphics and pluggable audio backends for desktop and browser targets.
Loading...
Searching...
No Matches
Gondwana.Audio.AudioResource Class Reference

Represents an audio resource that can be played, paused, resumed, sought, and disposed. Playback is supplied by the currently configured IAudioBackend. More...

Inheritance diagram for Gondwana.Audio.AudioResource:

Public Member Functions

void Play (bool fromStart=true)
 Starts playback of the resource.
void Pause ()
 Pauses playback if currently playing.
void Resume ()
 Resumes playback if currently paused.
void Seek (TimeSpan position)
 Seeks to the specified playback position.
void Stop ()
 Stops playback immediately.
void Dispose ()
 Disposes the audio resource and releases any underlying playback handle and temporary files. After disposal the instance must not be used.

Public Attributes

Func< Task >? PlaybackCompletedAsync
 Optional asynchronous callback invoked when non-looping playback completes.

Static Public Attributes

const float MinimumPlaybackSpeed = 0.25f
 Minimum allowed playback speed multiplier. Values below this are clamped.
const float MaximumPlaybackSpeed = 4.0f
 Maximum allowed playback speed multiplier. Values above this are clamped.

Properties

string Key [get]
 Gets the unique key associated with this audio resource.
byte?[] OriginalBytes [get]
 Gets the original byte array of the audio data, if available.
string? SourceFilePath [get]
 Original file path when the sound was loaded from disk. Null when loaded from an AssetsFile or URI.
AssetsFileIdentifier? AssetIdentifier [get]
 Asset identifier when the sound was loaded from an AssetsFile.
string? SourceExtension [get]
 Normalized file extension used by the configured backend.
string? SourceUri [get]
 Source URI when the resource was loaded by URI, primarily for browser playback.
string? TempFilePath [get]
 Gets the temporary file path used by a backend that requires file-based decoding, if any.
bool IsPaused [get]
 Gets a value indicating whether playback is currently paused.
bool IsPlaying [get]
 Gets a value indicating whether playback is currently active.
AudioPlaybackState State [get]
 Gets the current high-level playback state of the resource.
TimeSpan CurrentTime [get, set]
 Gets or sets the current playback position within the resource. Setting this property seeks to the specified position.
TimeSpan Duration [get]
 Gets the total duration of the resource, or TimeSpan.Zero when unknown.
bool IsLooping [get, set]
 Gets or sets whether playback loops continuously.
float Volume [get, set]
 Gets or sets output volume in the range 0.0 through 1.0.
float Pan [get, set]
 Gets or sets stereo pan from -1.0 (left) through 1.0 (right).
float PlaybackSpeed [get, set]
 Gets or sets playback speed. 1.0 is normal speed; supported values are clamped to 0.25 through 4.0.

Events

EventHandler? PlaybackCompleted
 Event raised when non-looping playback reaches the end of the resource.
EventHandler? Disposed
 Event raised when the resource is disposed.

Detailed Description

Represents an audio resource that can be played, paused, resumed, sought, and disposed. Playback is supplied by the currently configured IAudioBackend.

Definition at line 12 of file AudioResource.cs.

Member Function Documentation

◆ Dispose()

void Gondwana.Audio.AudioResource.Dispose ( )

Disposes the audio resource and releases any underlying playback handle and temporary files. After disposal the instance must not be used.

Definition at line 345 of file AudioResource.cs.

◆ Pause()

void Gondwana.Audio.AudioResource.Pause ( )

Pauses playback if currently playing.

◆ Play()

void Gondwana.Audio.AudioResource.Play ( bool fromStart = true)

Starts playback of the resource.

Parameters
fromStartIf true, playback begins from the start of the resource; otherwise resumes from the current position.

◆ Resume()

void Gondwana.Audio.AudioResource.Resume ( )

Resumes playback if currently paused.

◆ Seek()

void Gondwana.Audio.AudioResource.Seek ( TimeSpan position)

Seeks to the specified playback position.

Parameters
positionTarget playback position. Values outside the valid range are clamped by the backend.

◆ Stop()

void Gondwana.Audio.AudioResource.Stop ( )

Stops playback immediately.

Member Data Documentation

◆ MaximumPlaybackSpeed

const float Gondwana.Audio.AudioResource.MaximumPlaybackSpeed = 4.0f
static

Maximum allowed playback speed multiplier. Values above this are clamped.

Definition at line 23 of file AudioResource.cs.

◆ MinimumPlaybackSpeed

const float Gondwana.Audio.AudioResource.MinimumPlaybackSpeed = 0.25f
static

Minimum allowed playback speed multiplier. Values below this are clamped.

1.0 is normal speed; values <1 slow playback, >1 speed up playback.

Definition at line 18 of file AudioResource.cs.

◆ PlaybackCompletedAsync

Func<Task>? Gondwana.Audio.AudioResource.PlaybackCompletedAsync

Optional asynchronous callback invoked when non-looping playback completes.

Definition at line 48 of file AudioResource.cs.

Property Documentation

◆ AssetIdentifier

AssetsFileIdentifier? Gondwana.Audio.AudioResource.AssetIdentifier
get

Asset identifier when the sound was loaded from an AssetsFile.

Definition at line 107 of file AudioResource.cs.

◆ CurrentTime

TimeSpan Gondwana.Audio.AudioResource.CurrentTime
getset

Gets or sets the current playback position within the resource. Setting this property seeks to the specified position.

Definition at line 146 of file AudioResource.cs.

◆ Duration

TimeSpan Gondwana.Audio.AudioResource.Duration
get

Gets the total duration of the resource, or TimeSpan.Zero when unknown.

Definition at line 156 of file AudioResource.cs.

◆ IsLooping

bool Gondwana.Audio.AudioResource.IsLooping
getset

Gets or sets whether playback loops continuously.

Definition at line 159 of file AudioResource.cs.

◆ IsPaused

bool Gondwana.Audio.AudioResource.IsPaused
get

Gets a value indicating whether playback is currently paused.

Definition at line 127 of file AudioResource.cs.

◆ IsPlaying

bool Gondwana.Audio.AudioResource.IsPlaying
get

Gets a value indicating whether playback is currently active.

Definition at line 133 of file AudioResource.cs.

◆ Key

string Gondwana.Audio.AudioResource.Key
get

Gets the unique key associated with this audio resource.

Definition at line 93 of file AudioResource.cs.

◆ OriginalBytes

byte? [] Gondwana.Audio.AudioResource.OriginalBytes
get

Gets the original byte array of the audio data, if available.

Definition at line 97 of file AudioResource.cs.

◆ Pan

float Gondwana.Audio.AudioResource.Pan
getset

Gets or sets stereo pan from -1.0 (left) through 1.0 (right).

Definition at line 184 of file AudioResource.cs.

◆ PlaybackSpeed

float Gondwana.Audio.AudioResource.PlaybackSpeed
getset

Gets or sets playback speed. 1.0 is normal speed; supported values are clamped to 0.25 through 4.0.

Definition at line 199 of file AudioResource.cs.

◆ SourceExtension

string? Gondwana.Audio.AudioResource.SourceExtension
get

Normalized file extension used by the configured backend.

Definition at line 111 of file AudioResource.cs.

◆ SourceFilePath

string? Gondwana.Audio.AudioResource.SourceFilePath
get

Original file path when the sound was loaded from disk. Null when loaded from an AssetsFile or URI.

Definition at line 103 of file AudioResource.cs.

◆ SourceUri

string? Gondwana.Audio.AudioResource.SourceUri
get

Source URI when the resource was loaded by URI, primarily for browser playback.

Definition at line 115 of file AudioResource.cs.

◆ State

AudioPlaybackState Gondwana.Audio.AudioResource.State
get

Gets the current high-level playback state of the resource.

Definition at line 139 of file AudioResource.cs.

◆ TempFilePath

string? Gondwana.Audio.AudioResource.TempFilePath
get

Gets the temporary file path used by a backend that requires file-based decoding, if any.

Definition at line 121 of file AudioResource.cs.

◆ Volume

float Gondwana.Audio.AudioResource.Volume
getset

Gets or sets output volume in the range 0.0 through 1.0.

Definition at line 171 of file AudioResource.cs.

Event Documentation

◆ Disposed

EventHandler? Gondwana.Audio.AudioResource.Disposed

Event raised when the resource is disposed.

Definition at line 53 of file AudioResource.cs.

◆ PlaybackCompleted

EventHandler? Gondwana.Audio.AudioResource.PlaybackCompleted

Event raised when non-looping playback reaches the end of the resource.

Definition at line 43 of file AudioResource.cs.