From c37f1b3b1374df2a2a434d16cd772a4bb00c567e Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 17 Nov 2026 00:19:38 -0300 Subject: micscope: on the scope module, its copy of the scope code gone micscope carried the code the scope module was lifted from: seven shaders byte for byte, its layouts but for a comment, and a private live view (Live, analyseLive, drawLive) that was Scope.push, scroll and spectrum. Now the live view is ss.live, a scope.Scope, pushed the microphone and drawn with the panel's world rects and the camera (Views.camera), every frame, clipped away while a recording stands in for it so its columns keep up as before; the tuner reads its history from ss.live.gpu.tape. The take panels run scope.kernels and scope.pipelines over the tape with scope.layouts' blocks, wavePass and spectrogramPass inlined at their one use; maxFreq, min_freq and floor_db are the scope's. src/layouts.zig keeps only the tuner's blocks, the build compiles only the tuner's two shaders, and the tuner names notes with scope.midi, scope.hz and scope.note_names. Takes, transport and tuner are as they were. 1003 lines out, 91 in. Tests: zig build test, 67/67 steps, 10/10 tests (the live history's own test went with it; the scope module tests the same). Pictures: the four scripts' 18 screenshots, captured before and after with the same scripts and compared pixel by pixel (two runs before differ by themselves wherever wall-clock playback or microphone timing shows: the playheads, how far the live view has filled). The one difference not of that kind is the live spectrum: micscope made every image at most 132 rows, so its 184-row spectrum was stretched from 132; the scope makes it at its size, so the live spectrum's lines come out crisp (at most 86 in a channel, inside its rect). The take spectra keep micscope's 132. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- examples/micscope/build.zig | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'examples/micscope/build.zig') diff --git a/examples/micscope/build.zig b/examples/micscope/build.zig index 0853cdc..2de639d 100644 --- a/examples/micscope/build.zig +++ b/examples/micscope/build.zig @@ -6,19 +6,13 @@ pub fn build(b: *std.Build) void { 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. + // The tuner's 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. + // The waveform, spectrogram and spectrum are the scope module's. 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" } }, + .layouts = .{ .module = layouts, .types = &.{"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"), }, @@ -30,6 +24,7 @@ pub fn build(b: *std.Build) void { .imports = &.{ .{ .name = "layouts", .module = layouts }, .{ .name = "shaders", .module = shaders.module }, + .{ .name = "scope", .module = sb.modules.scope }, }, }); const steps = app.addSteps(.{ -- cgit v1.3