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.
public sealed class CaptureAudioDevice : MixerAudioDevice, IAudioDevice, IDisposableInheritance
object ← MixerAudioDevice ← CaptureAudioDevice
Implements
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.
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
A rate is not positive.
Properties
Duration
Seconds captured so far.
public double Duration { get; }Property Value
IsAvailable
False: nothing reaches a speaker.
public override bool IsAvailable { get; }Property Value
Output
Everything captured so far, as an interleaved stereo clip (samples clamped to -1..1).
public AudioClip Output { get; }Property Value
Played
The sounds played, in order: name, the second of the capture it started at, volume, pitch and pan.
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.
public int SampleRate { get; }Property Value
Methods
Play(SoundHandle, float, float, float)
Plays the sound and records it in Played.
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.
public override void Pump()Update()
Captures the next game step (1/updateRate seconds) of sound.
public override void Update()