December Adventure (2023)
git clone
Log | Files | Refs | README

commit 87fc7a22648d1d466917127094794335601b543f
parent 6dc7404279585ddabf176692c091e7fbb04dd1ae
Author: Eamon Caddigan <>
Date:   Sat, 30 Dec 2023 20:52:31 -0800

Work in progress on my audio device notes

Diffstat: | 32++++++++++++++------------------
1 file changed, 14 insertions(+), 18 deletions(-)

diff --git a/ b/ @@ -71,23 +71,19 @@ specifying the length thereof. SDL is probably responsible for allocating and freeing those buffers, which means that uxn just needs to fill that thing with audio sample data. How does it do that? First (and this bit surprises me), uxn is handling the -polyphony. +polyphony; `SOUND_TIMER` has a value of (256 / 44100 * 1000) ~5.80, which is the -duration in ms of a 256 sample buffer. Could `duration` be expressed in -ms? I'm still super confused how it's used. I tried writing a callback to -stop playback after the duration is up, but that's not happening. I didn't -have very much time to hack tonight (but I still wrote _some_ code). - -The only thing I've actually figured out: the new S value in the ADSR -envelope is the *volume* of the sustain period. A and D are attack and decay -duration as before. I need to figure out how to stop a note before I can -observe an R. This is all evident in `env_advance` now that I know to look -for it. - -I know that I can use the Screen device as a crude timer, but I'm really -hoping there's a more fine-grained method of setting note duration, which is -why I'm trying to wrap my head on what this `duration` port **actually -does**. - -## To Be Continued +duration in ms of a 256 sample buffer. `duration` is also expressed in ms, +but this 5.8 ms `SOUND_TIMER` limits the resolution of playback. + +### The ADSR + +The S value of the ADSR envelope now specifies a fraction of the peak A/D +volume that is maintained during the sustain phase. + +A, D, and R are multiplied by 64 (in `note_on`), and then (in `env_on`) they +are inverted and multiplied by `SOUND_TIMER` (5.8 ms) / `AUDIO_BUFSIZE` +(256 samples). + +The attack stage can be skipped (with an initial A of 0) but decay can't.