From 896855648c3371ede3c672bbfa75175fa3a1e42e Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 17 Nov 2026 00:09:10 -0300 Subject: sk.sfxr: the sfxr sound-effect generator, from 02-dont-rat-me-out 02-dont-rat-me-out's synth.zig, a pure and deterministic port of DrPetter's sfxr, moves into the library as src/sketch/sfxr.zig, exposed as sk.sfxr: render(params, rate, out) gives a coin, blip, laser or explosion as samples for host.newSound. Its knobs count in samples at 44.1 kHz, so the one change is the rate: every length (envelope, arpeggio, repeat, phaser offset, period) grows by rate/44.1 kHz and every per-sample step (slides, duty sweep, vibrato, filter coefficients and their ramps) shrinks by it, to first order for the slides and filters; at 44.1 kHz each factor is 1 and the samples are the original's to the bit. Two spellings change without changing a sample: the phaser buffer is @splat (Zig 0.17 has no ** on arrays) and the phaser delay is clamped before it is converted, so a long sweep cannot overflow it. Test: four parameter sets that between them turn every knob render the lengths and Wyhash of the samples the original rendered at 44.1 kHz (run once, outside the repo), and at 48 kHz a sound as long within 1 %. test/voices.zig makes its blip with sfxr in draw, at in.sample_rate, and is the README's example: a blip in six lines. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- build.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'build.zig') diff --git a/build.zig b/build.zig index d2176d9..857cf4a 100644 --- a/build.zig +++ b/build.zig @@ -92,8 +92,9 @@ 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); - const test_audio = b.step("test-audio", "Test the voice mixer (reconciling, limiting, pitch, groups) and a made sound played as a voice"); + const test_audio = b.step("test-audio", "Test sound: the voice mixer (reconciling, limiting, pitch, groups), sfxr, and a made sound played as a voice"); test_audio.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = host, .filters = &.{ "voice", "mixer" } })).step); + test_audio.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = b.createModule(.{ .root_source_file = b.path("src/sketch/root.zig"), .target = target, .optimize = optimize, .imports = sketch_imports }), .filters = &.{"sfxr"} })).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); -- cgit v1.3