Skip to content

AudioAPI reference

Class CaptureAudioDevice

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

An audio device that plays nothing aloud and records what would have been heard: the engine’s own mixer (MixerAudioDevice) rendering into an offline sink, one game step per Update (the game calls it once per update), so the same run always produces the same samples. Tests compare its Output (waves, durations, silences, amplitudes); the launcher’s –audio-capture FILE writes it as a WAV.

C#
public sealed class CaptureAudioDevice : MixerAudioDevice, IAudioDevice, IDisposable

Inheritance

object ← MixerAudioDevice ← CaptureAudioDevice

Implements

IAudioDevice, IDisposable

Inherited Members

MixerAudioDevice.LoadSound(string, AudioClip), MixerAudioDevice.LoadMusic(string, AudioClip, bool), MixerAudioDevice.LoadMusicStream(string, byte[], string, bool), MixerAudioDevice.Play(SoundHandle, float, float, float), MixerAudioDevice.PlayMusic(MusicHandle, float), MixerAudioDevice.StopMusic(), MixerAudioDevice.SetMusicVolume(float), MixerAudioDevice.PauseMusic(bool), MixerAudioDevice.Update(), MixerAudioDevice.Pump(), MixerAudioDevice.Dispose(), MixerAudioDevice.Engine, MixerAudioDevice.IsAvailable, MixerAudioDevice.MusicFormats, MixerAudioDevice.CurrentMusic, object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Remarks

It is the mixer every backend plays through, with the same voice limit, priorities and stealing, panning, resampling, looping, pause, music volume and decoding (WAV and OGG Vorbis music streams); only the device’s own latency and resampling to its hardware rate are left out. Sounds start at the first frame of the step that played them.

Constructors

CaptureAudioDevice(int, int)

Creates a capture device.

C#
public CaptureAudioDevice(int updateRate = 60, int sampleRate = 44100)

Parameters

updateRate int

Updates per second of the game (GameSettings.UpdateRate); each Update captures 1/updateRate seconds.

sampleRate int

Samples per second of the capture.

Exceptions

ArgumentOutOfRangeException

A rate is not positive.

Properties

Duration

Seconds captured so far.

C#
public double Duration { get; }

Property Value

double

IsAvailable

False: nothing reaches a speaker.

C#
public override bool IsAvailable { get; }

Property Value

bool

Output

Everything captured so far, as an interleaved stereo clip (samples clamped to -1..1).

C#
public AudioClip Output { get; }

Property Value

AudioClip

Played

The sounds played, in order: name, the second of the capture it started at, volume, pitch and pan.

C#
public List<(string Name, double Time, float Volume, float Pitch, float Pan)> Played { get; }

Property Value

List<(string Name, double Time, float Volume, float Pitch, float Pan)>

SampleRate

Samples per second of Output.

C#
public int SampleRate { get; }

Property Value

int

Methods

Play(SoundHandle, float, float, float)

Plays the sound and records it in Played.

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

Parameters

sound SoundHandle

volume float

pitch float

pan float

Pump()

Decodes streamed music ahead; the capture itself advances only with Update.

C#
public override void Pump()

Update()

Captures the next game step (1/updateRate seconds) of sound.

C#
public override void Update()