summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-17 00:05:36 -0300
committerGabriel Schneider <[email protected]>2026-11-17 12:15:01 -0300
commitfe0cee90f9bd4caa60b907e502aec4cc0daa4b60 (patch)
treec5e66a261a13a137ebef4c355d7c2b559efff3bd /README.md
parentaabb92d26f6b46cd4c482e0e2cbc8e9e9751db0d (diff)
downloadsketchbook-fe0cee90f9bd4caa60b907e502aec4cc0daa4b60.tar.gz
sketchbook-fe0cee90f9bd4caa60b907e502aec4cc0daa4b60.zip
audio: the voice mix plays at true volume below a knee and is limited only above it
Every mixed sample went through x/(1 + |x|), so one voice at 0.5 played at 0.33, bent. The mix now passes through untouched up to 0.75 (-2.5 dBFS) and above it follows knee + (1 - knee)·u/(1 + u), u the excess over the room left (the old curve is its knee-0 case): same value and slope at the knee, rising, tending to 1. A clip normalised to full scale only has its peaks bent (1 plays at 0.875); two at full scale sum to 0.958. Per sample, no state, no lookahead, on the frame thread as before. A unit test checks the curve: identity to the bit below the knee (every 997th float, both signs), rising and at most 1 from the knee to infinity (every float near the knee), odd, slope 1 at the knee; `zig build test-audio` runs the mixer's tests alone. The README says what the mixer does, and that SDL clips the total of the voice mix and the streams. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'README.md')
-rw-r--r--README.md7
1 files changed, 7 insertions, 0 deletions
diff --git a/README.md b/README.md
index 1400f2a..f9ad615 100644
--- a/README.md
+++ b/README.md
@@ -434,6 +434,13 @@ while declared, and the next frame's `input.microphone` holds what it heard
`host.samples(audio)` gives a loaded sound's samples, mono at
`input.sample_rate`.
+The host sums the voices and limits the sum, sample by sample: below
+0.75 (-2.5 dBFS) it plays at true volume, to the bit; above, it bends
+smoothly (same value and slope at 0.75) toward 1 and never past it, so a
+full-scale peak plays at 0.875 and any number of loud voices stays
+bounded. Streams are not limited: SDL adds each, as pushed, to the voice
+mix and clips the total at ±1.
+
Sounds decode with single-file C libraries in `vendor/` (dr_wav, dr_flac,
stb_vorbis): WAV, FLAC and Ogg Vorbis, chosen by content.