From 9bd77e54943d954291b5faef287ccca5dcebd7a4 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 17 Nov 2026 00:15:15 -0300 Subject: examples: micscope and spheres come home, as they were, building Both lived outside any repository, beside sketchbook, with manifests that pointed at ../01-drat-meout/lib/sketchbook, which no longer exists. They are copied into examples/micscope and examples/spheres (their sources, shaders, tests, test material and web icons; not their caches, builds, packages, state files or .gitignore, which the root's covers), their manifests depend on "../.." as the other examples do, and their READMEs link sketchbook there. Nothing else changed: both build against today's library and pass their own zig build test (micscope 62/62 steps, 11/11 tests, its transport, record, render and tuner scripts; spheres 75/75 steps, 3/3 tests, its play script). The originals are untouched. micscope's test/reference.flac (3.7 MiB, CC BY-SA 3.0, credited in its test/README.md) is the rendering reference its render script opens. The README lists both examples. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- examples/micscope/build.zig | 59 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 examples/micscope/build.zig (limited to 'examples/micscope/build.zig') diff --git a/examples/micscope/build.zig b/examples/micscope/build.zig new file mode 100644 index 0000000..0853cdc --- /dev/null +++ b/examples/micscope/build.zig @@ -0,0 +1,59 @@ +const std = @import("std"); +const sketchbook = @import("sketchbook"); + +pub fn build(b: *std.Build) void { + const target = b.standardTargetOptions(.{}); + const optimize = b.standardOptimizeOption(.{}); + const sb = sketchbook.init(b, .{ .target = target, .optimize = optimize }); + + // The shaders, as SPIR-V for the native host and WGSL for the web; their + // uniform blocks come from the Zig structs in src/layouts.zig. + const layouts = b.createModule(.{ .root_source_file = b.path("src/layouts.zig") }); + const shaders = sb.addShaders(.{ + .layouts = .{ .module = layouts, .types = &.{ "SpectrumParams", "WaveParams", "WaveView", "SpectrumView", "SpectrogramParams", "SpectrogramView", "TunerParams" } }, + .sources = &.{ + b.path("shaders/view.vert"), + b.path("shaders/waveform.comp"), + b.path("shaders/waveform.frag"), + b.path("shaders/spectrogram.comp"), + b.path("shaders/spectrogram.frag"), + b.path("shaders/spectrum.comp"), + b.path("shaders/spectrum.frag"), + b.path("shaders/tuner_difference.comp"), + b.path("shaders/tuner.comp"), + }, + }); + + const app = sb.app(.{ + .name = "micscope", + .root_source_file = b.path("src/main.zig"), + .imports = &.{ + .{ .name = "layouts", .module = layouts }, + .{ .name = "shaders", .module = shaders.module }, + }, + }); + const steps = app.addSteps(.{ + // Installable, and it opens offline (icons from web/icon.svg). + .web = .{ .pwa = .{ + .description = "Records the microphone, shows its waveform, spectrogram and spectrum, and tunes any instrument.", + .background = "#0b0c0f", + .theme = "#0b0c0f", + .icons = &.{ + .{ .source = b.path("web/icon-192.png"), .size = 192 }, + .{ .source = b.path("web/icon-512.png"), .size = 512 }, + }, + } }, + .scripts = &.{ b.path("test/transport.script"), b.path("test/record.script"), b.path("test/render.script"), b.path("test/tuner.script") }, + }); + + // GPU time per command while zooming, which recomputes every frame. + const profile = b.addRunArtifact(steps.exe); + profile.addArgs(&.{ "--headless", "--fresh", "--profile-gpu", "--script" }); + profile.addFileArg(b.path("test/profile.script")); + profile.addArg("--state"); + _ = profile.addOutputFileArg("profile.state"); + profile.setCwd(b.path(".")); + profile.has_side_effects = true; + profile.stdio = .inherit; + b.step("profile", "Print GPU time per command while zooming the reference").dependOn(&profile.step); +} -- cgit v1.3