Expand description
The mixer: everything playing, added up into one block of samples, in whole numbers, so the same script gives the same samples on every target.
- Volumes and balance are
u16s in 1/4096 (UNITYis full), the sum is ini32, and the result clamps toi16. - A rate is 16.16 (
RATE_ONEis as recorded). A sound’s own rate and this rate make one exact step, and frames between are linearly interpolated. Mixer::rendertakes no lock, allocates nothing, frees nothing, and does no decoder work or I/O, so a system’s audio callback can call it. All the memory is taken inMixer::new.- A voice is never stopped to make room for another: with every voice busy,
Mixer::playsaysFull. Which sound loses is the caller’s to decide, before it gets here.
A sound is decoded whole and held by the bank (Mixer::add_sound), and voices
name it by SoundId. A stream is a Source that has its frames ready; a
worker decodes ahead into a stream::feed, whose module says what the two
ends promise each other. queue is how another thread commands a mixer.
Modules§
- queue
- Commands from another thread: a fixed ring of plain data, one writer and one
reader, with no lock, no allocation and no
unsafe. - stream
- Streams: what a worker hands the mixer, and what a voice reads it through.
Structs§
- Config
- What a mixer is made with. All its memory comes from these.
- Full
- Every voice is busy, or the bank or the queue has no room. Nothing was stopped to make any.
- Mixer
- The mix (module docs).
- Params
- How a voice starts.
- Region
- Part of a source, in frames:
startup to, not including,end. It plays what comes before it once, then goes round it with no gap. - SoundId
- A sound of a mixer’s bank.
- Stream
Id - A stream waiting in a mixer to be played.
- VoiceId
- A playing sound. Once it has ended the id means nothing: an operation on it does nothing, even when its voice is playing something else by then.
Constants§
- RATE_
MAX - The fastest rate: what a block costs stays bounded.
- RATE_
MIN - The slowest rate: a voice always ends, or comes round, in a bounded time.
- RATE_
ONE - As recorded, in 16.16.
- UNITY
- Full volume, and an even balance, in 1/4096.
Type Aliases§
- Shared
Pcm - A sound many voices can hold.