Expand description
Recording the mix an audio world fills into its output buffer.
A recording is an OnAudioFill source ordered after every other one, so it
sees the samples the whole world contributed. The samples it keeps are the
ones the output stream would receive: the worldβs GlobalAudioGain scales the
sum and it clamps to the unit range, exactly as dispatch_audio_fill finishes a
fill.
The recorder learns the format from the first fill it sees rather than being
told one: an audio world publishes its rate only once a device is open, and
a world that opens none fills at the rate its sources were built for. A
recording stops at max_seconds of audio and keeps what it captured, so an
unattended recording cannot grow without bound. A finished recording is
written in the RecordingFormat its caller names: a RIFF/WAVE file of
the samples themselves, or the same samples in a lossless FLAC stream.
Re-exportsΒ§
use std::sync::Arc;πuse std::sync::Mutex;πuse unlit_ecs::sync;πuse unlit_ecs::Entity;πuse unlit_ecs::World;πuse unlit_ecs::bundle;πuse crate::audio::AudioChunk;πuse crate::audio::AudioFillOrder;πuse crate::audio::AudioFormat;πuse crate::audio::GlobalAudioGain;πuse crate::audio::OnAudioFill;π
StructsΒ§
- Recorded
Audio - The samples a finished recording captured.
- Recording
Handle - A recording in progress on a world.
- Recording
State π - What a recording has captured so far.
EnumsΒ§
- Recording
Error - Why a recording, or the format it is written in, was refused.
- Recording
Format - The file format a recording is written in.
ConstantsΒ§
- BITS_
PER_ πSAMPLE - How many bits one quantized sample takes, the resolution both encoders declare for the samples they hold.
FunctionsΒ§
- quantize π
- Quantize a sample into the 16-bit range both encoders write.
- start_
recording - Start recording everything
worldfills, for at mostmax_seconds. - write_
flac π - Write interleaved samples as a lossless FLAC stream.
- write_
wav π - Write interleaved samples as a 16-bit PCM RIFF/WAVE file.