Skip to main content

Module record

Module record 

Source
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Β§

RecordedAudio
The samples a finished recording captured.
RecordingHandle
A recording in progress on a world.
RecordingState πŸ”’
What a recording has captured so far.

EnumsΒ§

RecordingError
Why a recording, or the format it is written in, was refused.
RecordingFormat
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 world fills, for at most max_seconds.
write_flac πŸ”’
Write interleaved samples as a lossless FLAC stream.
write_wav πŸ”’
Write interleaved samples as a 16-bit PCM RIFF/WAVE file.