AudioAPI reference
Interface IAudioDevice
Namespace: MicroEngine.Audio
Assembly: MicroEngine.Audio.dll
Guide: Audio
Backend audio device. Implementations must tolerate missing hardware by becoming silent.
public interface IAudioDeviceProperties
CurrentMusic
The music started last and not stopped, or null.
MusicHandle? CurrentMusic { get; }Property Value
IsAvailable
Whether sound actually reaches a speaker. False for a silent device (no hardware, headless, muted host).
bool IsAvailable { get; }Property Value
Methods
LoadMusic(string, AudioClip, bool)
Uploads decoded music and returns its handle.
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
LoadMusicStream(string, byte[], string, bool)
Streams compressed music (e.g. “ogg”, “mp3”, “wav”) that the device decodes itself.
MusicHandle LoadMusicStream(string name, byte[] encoded, string format, bool loop = true)Parameters
name string
encoded byte[]
format string
loop bool
Returns
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.
SoundHandle LoadSound(string name, AudioClip clip)Parameters
name string
clip AudioClip
Returns
PauseMusic(bool)
Pauses (true) or resumes (false) the current music.
void PauseMusic(bool paused)Parameters
paused bool
Play(SoundHandle, float, float, float)
Plays a sound effect once, mixed with any sounds already playing.
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.
void PlayMusic(MusicHandle music, float volume = 1)Parameters
music MusicHandle
volume float
SetMusicVolume(float)
Sets the volume of the current music, 0..1.
void SetMusicVolume(float volume)Parameters
volume float
StopMusic()
Stops the music immediately.
void StopMusic()Update()
Called once per frame so streaming music keeps playing.
void Update()