summaryrefslogtreecommitdiff
path: root/examples
Commit message (Collapse)AuthorAge
* examples/live: square units, x and y from the centre in half the heightGabriel Schneider28 hours
| | | | | | | | | | | | | | | | | picture.frag gives the tape x and y in half the target's height, 0 at its centre and y up (`y` -1 to 1, `x` -1.78 to 1.78 on 16:9), so a circle is round on any window, half resolution included. Lang.builtins and the README's table say so; the README's program draws its ring about the centre (`r = sqrt(x * x + y * y)`, the ring's radius and width doubled into the new unit). Test: test/live.script replaces the text (`%`, `c`) with a disc of radius 0.5, `step(x * x + y * y, 0.25)`, and reads its edge 180 pixels from the centre across and up: white at 170, black at 190, each way. zig build test: 85 of 85 steps. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
* examples/live: drag a number, the program following as it movesGabriel Schneider28 hours
| | | | | | | | | | | | | | | | | | | | | | | | | The left button pressed on a number token (the grammar's `number` node at the byte under the pointer, found with the module's parse) starts a drag kept in State: the literal's bytes, the value, its precision. Each pointer move rewrites the literal through the editor's `replace`: a step for every 4 pixels right of where it was pressed (left, down), the step from the literal's own precision (`220` by ones, `0.25` by hundredths), printed with as many decimals. The first rewrite is a step to undo and the rest join it, so one `u` takes the whole drag back. The text changes, so the program is compiled and heard as it moves. A literal with an exponent is not dragged (marked ponytail). `update` finds the byte under the pointer as `code` lays the text out: a character is 10 by 22 pixels, measured once (the code face at 1.25, natively: ten M are 100) and now a constant both use, where `code` asked the host each frame. Test: test/live.script presses 220, drags 40 pixels right (230), back to 12 left of the press (217), lets go and undoes the drag in one step (220). zig build test: 85 of 85 steps. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
* examples/live: hear this, the expression a node walk leaves the selection onGabriel Schneider28 hours
| | | | | | | | | | | | | | | | | | | | | | | | | | | | After Alt-o, Alt-i, Alt-n or Alt-p (helix's node walks, run in the editor on the module's parse) the primary range is read back and the text compiled again with it as a probe: Lang.compile takes the bytes of a selection and compiles the smallest expression holding them into a third tape, `Program.probe`. The compiler learns each expression's bytes as it parses (`spanned`: a number, a name used, a call, parentheses, a unary minus, each binary operation, a whole line), keeping the smallest that holds the probe: no table of spans. A name used is the line that defines it, so a walk onto `kick` hears kick. State keeps the probe's tape (`probe`, empty when there is none). While it is set, `draw` hears it as `out` (through the crossfade, as any change) and sees it as the picture, grey unless it is a colour. Any other key empties it, so Escape or an edit goes back to the program. It is in State, so a replay probes where the session did. Test: Lang.zig, a probe on an argument, a number, a cursor on one of its digits, a name used, a line's name, a selection Alt-o grew to, and between two lines (none); test/live.script, Alt-o twice from the 2 of 220 (`220`, then `tau * 220`), then Escape. Lang.compile takes the probe as a second argument; the other calls pass null. zig build test: 85 of 85 steps, 8 of 8 tests. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
* examples/live: the language's grammar, its colours and a new line's indentGabriel Schneider28 hours
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | grammar/grammar.js is the language as src/Lang.zig parses it, for tree-sitter (24 lines): lines of `name = expression` parted by newlines, `+ -` below `* /` below unary `-`, calls, parentheses, numbers (Lang's digits, point and `e`), names, `#` comments as extras. `tree-sitter generate` (tree-sitter 0.26.9; ABI 14, the CLI's without a tree-sitter.json) wrote grammar/src/parser.c (918 lines) and its tree_sitter/ headers, committed: the build compiles them into the sketch as a static library and never runs the generator. The `Language` is handed to the editor at run time (`tree_sitter_live`, queries/highlights.scm and queries/indents.scm embedded). The parse is a module's `Syntax`, kept between calls so Alt-i goes back the way Alt-o came, handed to every key, forgotten at a jump (in `draw`, `in.jumped`) and started again by a reload (the tree a reload leaves is leaked: marked ponytail). `code` colours each run of bytes by `Syntax.colors` in pardes's own theme (orchard, the first): a defined name as a keyword, a called builtin as a string, numbers and comments as theirs, the rest in the theme's ink. indents.scm gives a new line no indent outside an open call or parenthesis: pardes's plain indent is a level more after `)`, so every line of this language that ends in a call pushed the next one in. The library now reads a handed-in language's indent query (pardes, its own change). Test: test/grammar.zig parses with the grammar and compiles with Lang.zig 22 texts: the survey's program and two others both take; eleven broken lines both refuse (an unclosed or extra parenthesis, a missing operand or `=`, two numbers, `1.2.3`, a stray `$`); eight both parse but only Lang.zig refuses, as only it knows names, builtins, arities and where a colour may stand (a name used before it is defined or defined twice, a builtin redefined or called with too few arguments, an unknown call, a colour outside the color line, a name called). Lang.zig's survey is public for it. zig build test: 85 of 85 steps. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
* examples/live: the editor's text drawn, its ranges, caret and modeGabriel Schneider28 hours
| | | | | | | | | | | | | | | | | | | One function, `code`, draws what the editor holds over the picture on a dark band: its lines, every range under its bytes (the primary stronger than the rest), a caret at each range's head that says the mode (a block in normal and select mode, a bar in insert mode, the primary's brighter), and the mode's name (NOR, INS, SEL) in the corner before the replay's state and the time; the problem as before, a red mark under its byte and its words under the text. One face at one size, so a byte of this ASCII language is a column of a fixed advance: marked ponytail as the place sketchbook's paragraph call (spans, any byte's place) takes. zig build test: 81 of 81 steps, 6 of 6 tests (test/live.script's screenshots compare the picture, and the sought moment's code band with the live one's). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
* examples/live: pardes's editor in State, typed with helix's keysGabriel Schneider28 hours
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The plain buffer of part 1 gives way to pardes's text pane as a library (`pardes-editor`, src/lib_editor.zig there): `Editor(.{ .text = 4096, .undo = 16 KiB, .registers = 1024, .selections = 64 })`, a value of plain data, 39,264 bytes of a State of 43,480. The package takes pardes by path (`../../../02-pardes-code`, the checkout beside sketchbook's) with `.editor = true` and its smallest tree-sitter set; sketchbook is spelled `../../../sketchbook` as pardes spells it, since a package is told by its path's spelling and sketchbook's build.zig cannot be two modules. `update` turns events into keys: printables from `text` events only, specials (Escape, Return, Backspace, Tab, arrows, Home, End, pages, Delete) and ctrl or alt chords (helix's `A-I` an upper-case letter) from `key_down`, a chord's letter dropped if it also comes as text. Each call into the editor thaws the value into a static 128 KiB buffer reset for the call (`update` may not allocate from the host; a key at 4 KiB of text took 29 KiB of it). The text is compiled when the editor's `revision` moves. Measured (a scratch bench through `update`, the survey's program, 646 bytes, a key typed into its middle, 400 times): a typed key, edit and compile, 59.5 us best and 78.8 mean in Debug, 7.4 and 7.8 in ReleaseFast; a motion 6.4 and 0.3. The package's cold `zig build lib` went from 3.1 s to 6.6 s, its first build under `--watch -fincremental` from 4.0 to 5.9 s, and an edit of main.zig rebuilt under it from 0.062-0.067 s to 0.067-0.092 s. Test: test/live.script types through helix now (`i`, the text, Escape, `gl`, `h`, `rx` for the edit, `l` `d` to break the line, `u` to mend it) and still replays to equal text, tapes and screenshots, its seeks moved to the marks' new times. zig build test: 81 of 81 steps, 6 of 6 tests. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
* examples/live: the README, the language on one pageGabriel Schneider28 hours
| | | | | | | | | | | | | | examples/live/README.md: what the sketch is, how to run it (keys, the console's replay verbs, capture, crossfade, the test and probe steps), the language (its grammar and every builtin a line, from Lang.builtins), the capacities, what it cannot say (no state between samples or frames: no filters, feedback or reverb; the price of computing each sample alone on the GPU and of exact replays) and how it works, with the probe's numbers. Its example program parses (out 22 instructions, color 38). The sketchbook README lists the example. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
* examples/live: the scripted proof, a session played back and soughtGabriel Schneider28 hours
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | test/live.script now ends with the run's own session replayed: `play session 0` from its start, then `seek` to the two moments marked as they happened (the gradient just typed, and the end after an edit, a broken line and its mend). At each, the State equals the mark leaf by leaf (`expect-snapshot`: the text, both tapes, the problem, the time), and at the first the screenshot equals the live one over the text and the picture (0,0 1000x600, without the scope and the status line). `stop` then goes on live from that moment: the typed program, before its edit. What a script could not do: a `record` clip ends at the first mark (Console.zig's `save` stops it), so the clip cannot be marked while it is made: the session is replayed instead. A mark is State before its frame's tick, so its time is the printed time less a frame, and `seek MS` lands on the last frame at or before MS: the script seeks 5 ms past each mark's time (272 and 488). The sound at a jump: `want` counted the queue the clear is about to drop, so a seek starved the device for a frame; now it counts from empty. And the block after a jump crosses from the old tape at where the device was (the clock less what was queued) to the tape at the new time (Synth.old_start). Not measured: a capture records every block made, including the tail the jump drops, so it cannot show what was heard across a seek. zig build test: 68 of 68 steps, 6 of 6 tests. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
* examples/live: the sound, the out tape on the GPU per sampleGabriel Schneider28 hours
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `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
* examples/live: the picture, typed over itselfGabriel Schneider28 hours
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The sketch: State holds the text (a plain 4 KiB buffer, typed characters appended, backspace deleting the last, return a newline: marked ponytail, the place pardes's editor takes in part 2), the last good out and color tapes, the problem and the time, summed from recorded ticks. `update` compiles the text at every keystroke; a program that parses replaces the tapes and clears the problem, one that does not sets the problem and changes nothing else, so the last good picture stays. `draw` runs picture.frag over the color tape into an image the size of the canvas, 1280x720, or half of it when the tape is longer than 64 instructions (the probe: 128 took 2.7 ms at full size, 0.85 at half), and scales it up. The text is drawn over it on a dark band with the library's text calls (the code face at 1.25, a column a fixed advance), the caret at the end, the problem as a red mark under its byte and its words under the text, and live/recording/replay/paused with the time in a corner. Test: test/live.script, the start of the scripted proof: a tone typed (its eight instructions asserted), a gradient (hsv over x and y, four), an edit (y to x: three, the picture different), a broken line (the problem at byte 52, the tape and the picture the same) and its mend. zig build test: 56 of 56 steps, 6 of 6 tests. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
* examples/live: the language, text in, a tape and a problem outGabriel Schneider28 hours
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Lang.compile reads lines of `name = expression` over t, x and y (+ - * /, unary minus, parentheses, numbers, # comments) and returns either a Program, the out and color tapes, or a Problem: a byte of the text and words. The builtins are one table, `builtins` (call, op, arity, value, doc): the survey's sin, cos, exp, log, pow, sqrt, abs, floor, fract, min, max, clamp, mix, step, smoothstep, atan2, noise, saw, sqr, tri, seq, hsv, rgb, tau and pi, and the inputs t, x, y. A name is defined once, before it is used; builtins cannot be renamed; hsv and rgb are colours, so only the whole color line can be one. Each tape is emitted from its line's root, depth first, each term once, so it holds only what the line reaches; t, x and y are a term each however often named, and a negative number is a number. seq's values go in registers side by side: as emitted when they are fresh numbers, else copied. noise's missing arguments are 0. Nothing is allocated: the compiler is a struct on the stack, 512 terms, 128 names, 32 levels of nesting, 17 arguments (seq's 16 values), 128 instructions a tape, about 28 KiB in all; past any of them is a problem in words ("the out line needs more than 128 instructions", at the line). vm.glsl's smoothstep is written out: GLSL leaves lo > hi undefined, and the survey's ring is smoothstep(0.03, 0, ...). Tests: a tone instruction by instruction; the survey's 20-line program (out 54 instructions, color 46, neither holding the other's terms, every operand an earlier register); every builtin; precedence, comments and numbers; 24 problems, each with its byte and words; each capacity, met and passed. zig build test: 6 of 6. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
* examples/live: the interpreter of a tape, and its probeGabriel Schneider28 hours
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Demo 1's route: a program becomes a flat tape of at most 128 instructions (src/Lang.zig: the ops, the instruction, the tape and the two uniform blocks that carry it; build.zig writes Lang.Op out as ops.glsl, so the op numbers have one definition), and ONE interpreter, shaders/vm.glsl, runs it per pixel (picture.frag) and per sample (synth.comp, crossing from the tape it replaces over the first `fade` samples). Instruction i writes register i; the tape is pushed as uniforms. The probe measures it before anything else is built: `zig build probe` plays made-up tapes (every instruction reaching the last, a noise in ten) under --profile-gpu. RTX 3050 (driver 620.70.06), Debug host, means of 601 frames, three runs agreeing within 0.07 ms: picture, empty tape 720p 0.14-0.23 1080p 0.19-0.28 (a pass's cost) picture, 60 720p 1.38-1.45 1080p 2.89-2.96 picture, 128 720p 2.71-2.81 1080p 5.86-5.95 picture, 128 at 640x360 0.85-0.94 The budget, under 2 ms at 1280x720: 60 instructions meet it, 128 do not. The cheap fixes, on 128 at 720p: the tape in a storage buffer 2.97-3.03 (worse); the registers as an array of 16 (kept in registers, indexing turned into selects) 5.82-5.93 (twice as slow); the 128-array with only 16 slots used 2.11-2.34 (cache footprint: a register allocator would buy about a sixth); half resolution 0.85-0.94. So the sketch will draw a tape longer than 64 instructions at half resolution, scaled up. The variants are kept outside the tree. The synth's numbers taken here were of a kernel that wrote nothing (its uniform block was past SDL's 4 KiB): the sound's change measures it again. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
* Merge the sketch's file tree and the manual's second slideGabriel Schneider28 hours
|\ | | | | | | | | | | | | Verb tables, state as files, fs verbs in every sketch binary; with the opcode-table slide of examples/manual.zig. No conflicts; zig build test: 180/180 steps, 144/144 tests. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
| * examples: manual's second slide, ADD's row 80 /0 ib becomes SUB's 80 /5 ibGabriel Schneider28 hours
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The manual example is a talk in two slides now: Figure 2-1 as before, then, once it clears, page 132 of the SDM's Vol. 2 (ADD) fades in with its opcode table taken out; the table is written back row by row (the column rules drawn down, then each row with the rule above it); the camera goes to 80 /0 ib ADD r/m8, imm8 as the rest greys; its opcode cell is tinted; closer in, the 0 after the slash morphs into the 5 of SUB's row from page 1400 while 80, / and ib hold still; then the rest of the row follows (ADD into SUB, Add into Subtract, to into from, imm8 and r/m8. sliding to their places) and the page around it becomes page 1400; at the end ADD's row comes back over SUB's, what differs is marked, and a line says why (one opcode byte, the ModR/M reg field picks the operation). Seven steps; the talk is 66 s exported. The pages and rows are checked against the PDF (pdftotext): ADD is page 132, SUB page 1400, and the rows' word boxes and the page's own rule shapes give the rectangles, in points, turned into the page's units by one function. Page 1400 stands 20 units higher, so its row (182-197 pt) lies on ADD's (167-182). The page draws a table's text row by row, left to right, and its rules after all of its text, so a row part writes in reading order. The column rules run the whole table, so their centres all fall in one row (83 /0 ib, at 265 pt): a band a point high through 265 takes the seven of them first, and nothing else. Each row is cut in the same eight pieces on both pages (the digit, the rest of the opcode, the instruction, the three short columns, the description word by word) and each piece morphs into its own: a morph pairs shapes by index, so the whole row (44 shapes into 51) would send every glyph after Add across the row. test/manual.script goes on through slide 2 with pixel checks (the table gone and back, the cell's tint, a step back to the exact picture before the digit's morph, the marks at the end) and checks three more exported frames of it, the same in both exports. The bench now times pages 132 and 1400 too (2118 and 2040 shapes: parse 10.0 and 10.3 ms, CPU draw 2.8, GPU record 1.2, in budget). The README's examples list and the manual's paragraphs say so, and how a table's column rules are taken. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
| |
| \
*-. | Merge one State in one file, GPU sound at the host's lead, and PDF pages as ↵Gabriel Schneider28 hours
|\ \| | | | | | | | | | | | | | | | | | | | | | | | | objects The Store's deletion with shared-page keyframes and the 64 MiB cap; f.audioBuffer and in.lead with spheres on them; the embedded-SVG image, Typst's root, part, and the manual example. No conflicts; zig build test: 179/179 steps, 140/140 tests; spheres 75/75, micscope 67/67. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
| | * examples: manual, Figure 2-1 of the Intel SDM comes alive, as a talkGabriel Schneider28 hours
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | examples/manual.zig is a live scene with pauses, played by the stock player: page 31 of the SDM's Vol. 2 (Typst's import of the PDF, every glyph a shape) fades in on paper beside a title; the camera closes on Figure 2-1, the instruction format, while the rest of the page greys and its footnotes go; each field (Prefixes, Opcode, ModR/M, SIB, Displacement, Immediate) is tinted and glows in turn; 83 C0 01, add eax, 1, is written below; each byte flies into its field as the fields it has none for fade; C0 morphs down the arrow into the ModR/M byte's boxes as 11000000, which splits into 11, 000 and 000 over Mod, Reg and R/M, each with what it says (direct, /0 ADD, EAX); and the camera goes back to the page, filled in. Twelve steps, 18 s played straight. The labels, the ModR/M boxes, the figure and its footnotes are parts of the page, by rectangles in the page's units read off pdftotext -bbox (points to units: (pt - 306) * 4/3, (pt - 396) * 4/3) and checked with the guides; each tint is the s.rect of its label's rectangle. The bits are parts of a Typst object, cut by character (0.6 em of DejaVu Sans Mono at 14 pt). The PDF is never committed. build.zig's -Dmanual names it, by default ~/01-resources/intel-devref-ii.pdf; when the file is not there the scene is one line saying how to build with it. zig build manual plays it in a window. test/manual.script, run by zig build test (and test-manual) only when the file is there, steps through the talk with pixel checks (the paper, a tint where it should be and not where it should not, a step back) and exports it twice at 10 fps, the same frames both times. zig build bench also times the manual's page (its one #image source, when the build has the PDF), with a budget of its own for a drawing of over 1000 shapes: parse under 25 ms, CPU draw under 10, GPU record under 4, at 1280x720. Measured: 6.4, 1.9 and 0.77 ms on a quiet run; 14.8, 3.5 and 1.4 at load average 34; once 28.6 ms to parse, at that load, which failed it (the simple objects' 1 ms is as sensitive: 0.87 ms then). The manual's simple objects are not benched: a two-glyph 83 fitted to the whole canvas takes 1.1-1.2 ms on the CPU. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
| * | spheres: its sound streamed from the GPU's block, at the host's leadGabriel Schneider28 hours
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The synth block goes to the speakers with f.audioBuffer, made to keep in.lead queued; in_flight, discard and lead_seconds are gone, and a chord's jump is the stream's clear alone (nothing is on its way back to drop). The block is still read back, a frame later, for the scope. The sound is the same: with the block fixed at 800 samples a frame, the play script and a script that plays every chord key (seven jumps) push the same samples before and after, to the bit (849600 and 1164007 of them), the new one a frame sooner. A change leaves for the device in 19 to 27 ms on average (three one-minute runs on a loaded machine) instead of 96 (dummy driver, 60 Hz, SDL's 1024-sample pulls). The empty Store declaration the brief mentioned is not in this sketch (main.zig says "No Store"); nothing was touched there. Tests: zig build test, 75/75 steps, 3/3 tests (its play script now also expects the stream fed). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
* | README: one thing a sketch keeps, in one file; what a crash loses; the capGabriel Schneider28 hours
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The manual described a mapped state file, a sessions database beside it, a probe, private files for scripted runs and exits that compact past 64 MiB. Now, in The host: "The save" replaces "State file" (one thing, State, in one file, `<name>.xitdb`; the present restored and replayed at start; keyframes as pages and what they cost, measured; layout migration as before; an old `<name>.state` imported once and left as it was); "Where files go" lists `<name>.xitdb` and the files a sketch appends to, `--state x.state` and `x.xitdb` naming one save; "Sessions" says every run is one, `record` decides how much history is kept (a build that does not record keeps the present and the marks, the last minute of input at most while it runs, none after), a crash loses under a second and the next run starts from the last committed frame; a new paragraph, "The cap": 64 MiB, State half, history dropped oldest first and the file compacted to three quarters (about 170 ms in Debug), the present, marks and clips never dropped, a new mark refused with how to make room. The State row and "Data that grows" say 32 MiB; the appendFile paragraph names `<stem>.<name>` beside the save; scripts and exports save nothing; the Build API loses `probe`, `addProbe` and `probe_exe`; Known limits gains the hash pass's cost. layout.zig's note on what State may hold says where it is saved; micscope's README names its takes `micscope.take-<id>.f32`. Tests: zig build test, 168/168 steps. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
* | micscope: a take starts its file empty; a deleted take's file stays, and whyGabriel Schneider28 hours
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Phase 1 left two loose ends in micscope's take files. A new take could continue an old file when its id met one already written without a jump in between (the jump is what moves next_id past written files), and a deleted take's file stayed on disk. The host gains one call beside appendFile: f.host.writeFile(name, bytes) writes a new, empty file of that name, through the same vtable entry with a `replace` flag. The old file is unlinked, so a readFile mapping of it keeps its bytes, and the host's cached mapping is retired (kept until exit, the sketch may hold it) so the next readFile maps the new file. The web host writes nothing, as for appendFile. micscope writes each take's file so when the take begins: on the frame whose transport request is newly `recording`, live, and not a jump (a jump's requests are restored State's, not a beginning; a fresh Session counts old requests as handled, so a restart mid-recording keeps its file), before the takes are read; `open` writes a file's samples so too. A deleted take's file stays: its State entry comes back with any seek or mark from before the delete, marks are kept with no end, and an exported session carries them; neither the sketch (which cannot see the history) nor the host (which cannot read State's meaning) can tell when none is left. So "never, safely": the file is kept. Tests: zig build test, 164/166 steps, 132/132 tests (the appendFile test now also replaces a file and reads back only the new bytes); the one failure was the Typst bench's 1 ms bound (1.024 ms), timing code this change does not touch, on a machine loaded by other builds; it passed in the next full run (166/166, with the change above this one). micscope's zig build test, 67/67 steps, 10/10 tests. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
* | micscope off the Store, its takes files written through Host.appendFileGabriel Schneider28 hours
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The library could read a file and not write one, so micscope kept its takes in the Store: a tape appended every frame while recording, which a save of 64 MiB could not hold (under six minutes of 48 kHz audio, and micscope allows ten-minute takes). Now a sketch has one call that writes: f.host.appendFile(name, bytes) appends to `<state>.<name>`, beside the state file (in .sketchbook/ under `zig build run`), creating it, and returns the file's path for readFile, or "" when nothing was written. It is pointer and length in, a C-callconv entry in the vtable like newSound. Only draw and command have a host, so a write is not replayed, like sound. The web host writes nothing and returns "". readFile still maps a file once, so what is appended after is not in what it returned. A scripted --fresh run works on `<state>.<pid>`; the files it appends to are `<state>.<pid>.<name>`, and the exit now moves every file of the run (found by that prefix in the state's directory) to the given name, or removes them for an export, where it moved the state and its store by two fixed suffixes. micscope: State lists the takes (sk.List(Take, 64): id, source) and the counter, next_id; `update` adds a take when recording starts and removes one on delete. Each take's samples are `take-<id>.f32` (mono f32 at the host's rate), appended to by draw as it records and by `open`, which also puts them straight into Session (the web keeps no files). Session holds the tape (every take's samples, read from their files once a process) and a clip per take (start, len, and heard, the playhead, which a restart no longer keeps); draw makes the tape follow State: a take State lost leaves it, one it lacks is read from its file. A deleted take's file stays, so a seek back finds it again; after a jump (start, seek, load, set, reload) draw moves next_id past take files already written (--fresh keeps them, and a seek back finds the future's) with a `next-id N` command. Gone: the Store, the remove request, the `takes N` command that told State the Store's count, adoptTape. Old micscope.state.store files are not read: their takes stay in them. README: appendFile among the host calls, a paragraph on it, and the private run's appended files. Tests: zig build test, 164/164 steps, 133/133 tests (one new: appendFile appends beside the state and names the file). micscope's zig build test, 67/67 steps, 10/10 tests; transport.script reads `takes.len`, loses the miscounted-takes check with its mechanism, and gains a deleted take read back from its file after `load` and the counter moved past written files. Pictures: the four scripts' 18 screenshots before and after, compared by pixel: the differences are where two runs of one build differ by themselves (playheads, the microphone's take lengths, the live view). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
* micscope: on the scope module, its copy of the scope code goneGabriel Schneider28 hours
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
* examples: micscope and spheres come home, as they were, buildingGabriel Schneider28 hours
| | | | | | | | | | | | | | | | | | | | 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 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
* anim: Event.key, and the talk example runs in a windowGabriel Schneider28 hours
| | | | | | An Event says its key (abi.Event.key), which the player and the talk example each spelled out by hand; `zig build talk` shows examples/talk.zig in a window on the generic host, its state under .zig-cache, and `zig build talk-lib --watch` beside it reloads every edit in place. Co-Authored-By: Claude Fable 5.2 <[email protected]>
* README: talks in the Animation section: the Deck, gates, sub-animations, ↵Gabriel Schneider28 hours
| | | | slides, a talk with a widget, export holds; the player's new keys
* examples: a talk that runs its own Deck, and its scriptGabriel Schneider28 hours
| | | | | | | | | | | | | examples/talk.zig keeps an anim.Deck in its State beside its own data, turns clicks and keys into asks and paints with an anim.Painter: two slides, a mass that bobs (loop) while the deck waits, a damping slider laid out and hit-tested in the talk (it takes its clicks), a choice gate that branches on it, and slide 1 cleared beside slide 2's writing. test/talk.script (zig build test-talk) steps it, finishes a step on a click, goes back, jumps slides, drags the slider without advancing, reloads mid-wait with the first step retimed (same step, t a second later) and checks two exports with 2 s holds frame by frame. The vecanim live scene's words follow the new pause.
* anim: the stock player runs on the DeckGabriel Schneider28 hours
| | | | | | | | | | | | The player's State is an anim.Deck plus the viewer's settings; keys and clicks become an Ask: click, space and page down step (space plays or pauses a scene with no pause), page up and backspace go back a step, ] and [ go a slide, P plays or pauses, left/right/home/end/,/. seek through Ask.to and Ask.end. A compiled scene is a talk without gates. The HUD shows the slide and step, and when the talk waits. Exported, each pause holds the scene file's hold (1 s). Its frozen hold (held, stopBetween, proceed) is gone. Scripts read deck.t and deck.playing where they read t and playing.
* anim: talks: gates that let time run on, pause, beside, loop, clear, slides ↵Gabriel Schneider28 hours
| | | | | | | | | | | | | | | | | | | and the Deck A talk is a live scene re-run from the top every frame, a function of its time and of the gates opened so far. Frame.gate(open) waits while time runs on and records the value it opened with; pause() is the presenter's click. beside and loop are the sub-animations, slide() the second navigation level, clear() the end of a slide. anim.Deck is the playhead and the gate log as plain data for any sketch's State: update() takes an Ask (next, back, next_slide, back_slide, to, end) and runs the talk with the app mutable, shot() runs it read-only for drawing. A click during a step finishes it; back cuts to the picture held before the last click; an edit that moves the last opened gate moves t with it; exported, every gate holds Deck.hold. Live takes a namespace or a tuple of them (sources) and exposes frame. Builder.pause, Instant.clock and Frame.clock are gone: t runs through gates. A test-anim step runs the module's tests and the player's scenes.
* Move standalone sketches into sketchbook examplesGabriel Schneider43 hours
|
* sketchbook: a drawing layer on top, host fixes for replay and migrationGabriel Schneider6 days