Skip to content

AudioAPI reference

Interface IAudioDevice

Namespace: MicroEngine.Audio
Assembly: MicroEngine.Audio.dll
Guide: Audio

Backend audio device. Implementations must tolerate missing hardware by becoming silent.

C#
public interface IAudioDevice

Properties

CurrentMusic

The music started last and not stopped, or null.

C#
MusicHandle? CurrentMusic { get; }

Property Value

MusicHandle?

IsAvailable

Whether sound actually reaches a speaker. False for a silent device (no hardware, headless, muted host).

C#
bool IsAvailable { get; }

Property Value

bool

Methods

LoadMusic(string, AudioClip, bool)

Uploads decoded music and returns its handle.

C#
MusicHandle LoadMusic(string name, AudioClip clip, bool loop = true)

Parameters

name string

Name reported by Name.

clip AudioClip

The music samples.

loop bool

Whether the music restarts when it reaches its end.

Returns

MusicHandle

LoadMusicStream(string, byte[], string, bool)

Streams compressed music (e.g. “ogg”, “mp3”, “wav”) that the device decodes itself.

C#
MusicHandle LoadMusicStream(string name, byte[] encoded, string format, bool loop = true)

Parameters

name string

encoded byte[]

format string

loop bool

Returns

MusicHandle

Remarks

Formats depend on the device: the SDL device streams wav and ogg; the raylib device also decodes mp3.

LoadSound(string, AudioClip)

Uploads a sound effect and returns its handle.

C#
SoundHandle LoadSound(string name, AudioClip clip)

Parameters

name string

clip AudioClip

Returns

SoundHandle

PauseMusic(bool)

Pauses (true) or resumes (false) the current music.

C#
void PauseMusic(bool paused)

Parameters

paused bool

Play(SoundHandle, float, float, float)

Plays a sound effect once, mixed with any sounds already playing.

C#
void Play(SoundHandle sound, float volume = 1, float pitch = 1, float pan = 0.5)

Parameters

sound SoundHandle

A handle from LoadSound.

volume float

Volume, 0..1.

pitch float

Playback speed factor; 1 is the original pitch.

pan float

Stereo position, 0 (left) to 1 (right); 0.5 is centred.

PlayMusic(MusicHandle, float)

Starts music from the beginning, replacing the music that was playing.

C#
void PlayMusic(MusicHandle music, float volume = 1)

Parameters

music MusicHandle

volume float

SetMusicVolume(float)

Sets the volume of the current music, 0..1.

C#
void SetMusicVolume(float volume)

Parameters

volume float

StopMusic()

Stops the music immediately.

C#
void StopMusic()

Update()

Called once per frame so streaming music keeps playing.

C#
void Update()