diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-17 00:07:07 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-17 12:15:01 -0300 |
| commit | cddefdd6e5c7fb632088d504d2ed96368fa44e0f (patch) | |
| tree | 3ae5bf53be2f5dc5746c9d3ece5e90786c3637b6 /build.zig | |
| parent | fe0cee90f9bd4caa60b907e502aec4cc0daa4b60 (diff) | |
| download | sketchbook-cddefdd6e5c7fb632088d504d2ed96368fa44e0f.tar.gz sketchbook-cddefdd6e5c7fb632088d504d2ed96368fa44e0f.zip | |
host.newSound: samples a sketch made become a sound, played by voices
A sketch that synthesised a one-shot had to stream it (and keep a replay
from re-firing it by hand) or encode a WAV for decodeSound. host.newSound
(samples) copies mono samples at in.sample_rate into the host and gives an
Audio like a loaded one, so the one-shot is a voice: reconciled by key and
serial, mixed, faded and limited by the host. It is kept for the life of
the host like every sound, and .none if a sample is not finite. The
vtable entry is C callconv (pointer and length), as anything new in
abi.zig is, for a second host; the web host keeps the copy for samples()
(its voices are silent).
Tests: a unit test that the sound is a copy and that NaN and infinity are
refused; test/voices.zig makes a 1000-sample blip in setup and declares it
under a serial space bumps, and test/voices.script checks it sounds once,
stays silent through a recording of it played, stepped and seeked, and
sounds again for a new serial. For that, expect-audio KEY also passes
when voice KEY was mixed since it was last asked, and expect-no-audio KEY
says it was not. zig build test-audio runs the script too.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -92,7 +92,8 @@ pub fn build(b: *Build) void { b.step("test-sessions", "Test the sessions database: frames, keyframes, marks, clips").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = host, .filters = &.{"session"} })).step); b.step("test-presentation", "Test presentation feedback, pacing and trace snapshots").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = host, .filters = &.{"presentation"} })).step); - b.step("test-audio", "Test the voice mixer: reconciling, limiting, pitch and groups").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = host, .filters = &.{ "voice", "mixer" } })).step); + const test_audio = b.step("test-audio", "Test the voice mixer (reconciling, limiting, pitch, groups) and a made sound played as a voice"); + test_audio.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = host, .filters = &.{ "voice", "mixer" } })).step); const setup_tests = b.step("test-setup", "Test resource setup lifecycle and arguments"); for ([_]*Build.Module{ host, b.createModule(.{ .root_source_file = b.path("src/sketch/root.zig"), .target = target, .optimize = optimize, .imports = sketch_imports }) }) |module| setup_tests.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = module, .filters = &.{"setup"} })).step); @@ -245,6 +246,12 @@ pub fn build(b: *Build) void { // `Host.textSize` against the text drawn (test/text.zig). const text = sb.app(.{ .name = "text", .root_source_file = b.path("test/text.zig") }); test_step.dependOn(&text.addScript(text.addExecutable(), b.path("test/text.script"), .{}).step); + // A sound the sketch made, as a voice: once per serial, not again on a + // replay (test/voices.zig). + const voices = sb.app(.{ .name = "voices", .root_source_file = b.path("test/voices.zig") }); + const voices_script = voices.addScript(voices.addExecutable(), b.path("test/voices.script"), .{}); + test_step.dependOn(&voices_script.step); + test_audio.dependOn(&voices_script.step); // The anim module's player on its test scenes: a live one with a // custom object between vector objects, and a compiled one, which is // also exported, at half size. |
