summaryrefslogtreecommitdiff
path: root/test/render.script
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-17 06:05:00 -0300
committerGabriel Schneider <[email protected]>2026-11-17 12:15:01 -0300
commita4d1e3131499c17bd6f73e65154aa0c2b31c62b3 (patch)
tree087f71b9670da52c2bf92501aff402a2919b9975 /test/render.script
parentc300a059850115a87a34456dfd60ac97c4a09890 (diff)
downloadsketchbook-a4d1e3131499c17bd6f73e65154aa0c2b31c62b3.tar.gz
sketchbook-a4d1e3131499c17bd6f73e65154aa0c2b31c62b3.zip
examples/live: the sound, the out tape on the GPU per sample
`pub const audio_pull = 256`; each frame `draw` runs synth.comp over as many samples as keep the host's lead queued (`in.lead -| queued`, 8192 at most) and streams the block with f.audioBuffer, as spheres does. Time is a sample clock in Session: set from State's time at every jump (a seek, a step, a replay's start; the queue is dropped then, so the jump is heard at once), and free-running otherwise, so a paused replay keeps sounding its moment. When the out tape differs from the one the last block played, the block crosses from the old tape to the new over its length (`set crossfade false` turns that off, to hear what it saves). The blocks are read back for the scope (an oscilloscope and a spectrum along the bottom) and, after the console's `capture`, appended to the sketch's capture.f32 beside its save. The status line shows the lead. The tapes reach synth.comp in a storage buffer, uploaded per block: two tapes are 4 KiB, and SDL_GPU's Vulkan backend binds a uniform block 4 KiB at a time (MAX_UBO_SECTION_SIZE), so a 4128-byte Synth block read its count as 0 past the cut and the kernel wrote nothing, silently: the probe's first synth numbers timed that. Measured again (RTX 3050, Debug host, two runs): every synth dispatch 0.08-0.14 ms, 60 or 128 instructions, 256 or 1024 samples, fading or not, the empty pass's cost alone; the 4 KiB upload 0.07-0.08. Measured on SDL's dummy driver (nothing audible) from captures: out = 0.3 * sin(t * tau * 220): peak 0.3000, RMS 0.2121, fundamental 220.000 Hz; edited to 330 in one keystroke, 330.000 Hz. The largest sample-to-sample step across the edit: 0.0131 with the crossfade (a 330 Hz sine's own steepest step is 0.0130), 0.3725 without; into the first sound, 0.0011 and 0.2967. The survey's program: peak 0.50, RMS 0.16, its bass at 55.0 Hz. Test: live.script also expects the stream to receive the GPU's blocks, and compares screenshots above the scope. zig build test: 68 of 68 steps. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'test/render.script')
0 files changed, 0 insertions, 0 deletions