Skip to main content

Module audio

Module audio 

Source
Expand description

The audio device behind the core’s AudioCommands, used by the runner and by hosts that drive a Core themselves.

The core queues audio commands as data (Core::take_audio_commands); the runner hands them to Audio::apply after every input dispatch and every frame, and polls finished playbacks back into the core (Core::audio_ended) so tagged ones become sound events. Two things only the device can know go back the same way: a Stop that landed on a sound still playing (Core::audio_truncated) and a play the device refused (Core::audio_refused).

Backed by kira (cpal underneath) behind the audio cargo feature; with the feature off every command is dropped and the UI runs the same. The device opens lazily on the first play, so an app that never plays anything never starts an audio thread; a device that refuses to open logs once and drops every later command. Decoded sounds are cached per SoundId and dropped on Unload.

blip and wav_pcm16 synthesize a short WAV for examples and tests that want a sound without shipping one.

Structs§

Answered
What the device answered back on an Audio::apply: the two things only it can know. The core turns each into a warning on the node that asked.
Audio
The output device and the sounds playing on it. The runner owns one; a host driving a core itself makes one with Audio::new and calls Audio::apply and Audio::poll_ended on its own turns.

Functions§

blip
A short decaying sine of hz lasting ms, as a WAV file: a click for examples and tests. gain is 0 to 1.
wav_pcm16
Encodes mono float samples (-1..1) as a 16-bit PCM WAV file, ready for Core::add_sound.

Type Aliases§

Truncated
A Stop that landed on a sound still playing, and how far into the sound (seconds) it was; Core::audio_truncated turns it into a truncated-playback warning on the node.