diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-17 08:07:27 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-17 12:15:01 -0300 |
| commit | abe2962264d590a6f54d64434222cd4b10b62160 (patch) | |
| tree | 1e2b10de257bafe12840ecdebb099d01ad1c30b6 | |
| parent | 3571b3e8bfb54d6f98ad3bc1f89147275716e5fc (diff) | |
| download | sketchbook-abe2962264d590a6f54d64434222cd4b10b62160.tar.gz sketchbook-abe2962264d590a6f54d64434222cd4b10b62160.zip | |
examples/live: the README, the editor's keys, hear this, the drag, scrubbing
The README says the text is pardes's editor and what it needs (pardes
beside sketchbook); the keys that matter, helix's in two lines (`i`,
Escape, the motions, `x`, `d`, `c`, `r`, `u`/`U`, `%`) and the pointer;
hear this (Alt-o, Alt-i, Alt-n, Alt-p: that expression alone, heard and
seen grey until the next key; an example in thump); the drag (a step
every 4 pixels, by the number's own precision, one step to undo); how to
scrub in the console's words (`sessions`, `play session N [at S]`,
`pause`, `seek MS`, `step -N`, `stop`); what the tests play, the
storyboard among them; and in How it works, the editor's value in State
and the grammar, its colours, node walks and indent. The reload is 0.07
to 0.09 s under `zig build lib --watch -fincremental`.
zig build test: 86 of 86 steps.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
| -rw-r--r-- | examples/live/README.md | 58 |
1 files changed, 46 insertions, 12 deletions
diff --git a/examples/live/README.md b/examples/live/README.md index e69b583..ea62cec 100644 --- a/examples/live/README.md +++ b/examples/live/README.md @@ -1,6 +1,7 @@ # live -A program typed over its own picture, and heard. Each line names an +A program typed over its own picture, and heard, in pardes's editor +(helix's keys, the language's grammar colouring it). Each line names an expression; the `out` line is what you hear (-1..1), the `color` line what you see. At every keystroke that leaves a program that parses, the program is compiled into two tapes of at most 128 instructions, and one @@ -22,16 +23,44 @@ The picture pulses with the kick because both lines say `kick`. ## Running it -`zig build run` (with `zig build lib --watch` beside it for hot reload). -Type; Backspace deletes the last character, Return starts a line. The -console (backtick) records, plays and seeks as for any sketch: `play -session 0`, `pause`, `seek 5000`, `step -60`, `stop`; a seek brings back -the text, the tapes and the picture of that moment, and the sound with -them. `capture` appends what is heard to `capture.f32` beside the save -(mono f32 at the device's rate) until `capture` again; `set crossfade -false` lets an edit click. `zig build test` runs the language's tests and -test/live.script headless; `zig build probe` times the interpreter on the -GPU (`--profile-gpu`). +`zig build run` (with `zig build lib --watch -fincremental` beside it for +hot reload: an edit of main.zig is back in 0.07-0.09 s). It needs pardes +beside sketchbook (`../02-pardes-code` of sketchbook's directory), whose +editor it takes as a library. + +**Keys** are helix's: `i` (or `a`, `o`, `O`) to type, Escape back to +normal mode, where `h j k l w b` move, `x` takes a line, `d` deletes, `c` +changes, `r` replaces a character, `u` and `U` undo and redo, `%` takes +it all. The mode is in the corner (NOR, INS, SEL). The pointer drags. + +**Hear this.** Alt-o grows the selection to the expression around it, +Alt-i shrinks it back, Alt-n and Alt-p go to the next and previous: after +any of them, that expression alone is heard (as `out`) and seen (grey, +unless it is a colour) until the next key. Escape, or any edit, goes back +to the program. `f*` then `;` then `mi(` then Alt-o, in +`thump = sin(tau * 48 * t ...)`, hears the sine alone. + +**Drag a number.** Press on a number and drag sideways: it moves a step +every 4 pixels, its step from how it is written (`220` by ones, `0.25` +by hundredths), and the program follows as you drag. The whole drag is +one step to undo. + +**Scrub** through the console (backtick): `sessions` lists the sessions +recorded, `play session N` plays one back (`play session N at 12` paused +at 12 s in), +`pause`, `seek 5000` (to 5 s in), `step -60` (60 frames back), `stop` +(live again from that moment, the session kept as it was). A seek brings back the text, the tapes and +the picture of that moment, and the sound with them. `capture` appends +what is heard to `capture.f32` beside the save (mono f32 at the +device's rate) until `capture` again; `set crossfade false` lets an edit +click. + +`zig build test` runs the language's tests, the grammar against the +language (test/grammar.zig), and test/live.script and test/story.script +(the storyboard: a tone, a drag, a gradient, a kick, a `)` broken and +mended, a probe, a bass and a ring, the session played back and sought) +headless; `zig build probe` times the interpreter on the GPU +(`--profile-gpu`). ## The language @@ -77,7 +106,12 @@ minutes or so a high pitch begins to roughen. src/Lang.zig compiles the text in `update` (no allocation: fixed arrays on the stack) into tapes of `{op, a, b, c}`, instruction i writing register -i; State keeps the text, both tapes, the problem and the time. The tapes +i; State keeps the editor's value (pardes-editor: 39 KiB of plain data, +4 KiB of text), both tapes, the probe's, the problem, the drag and the +time. grammar/grammar.js, generated into the committed grammar/src/parser.c, +is the same language for tree-sitter: its parse colours the text +(queries/highlights.scm, in pardes's orchard theme), gives Alt-o its +nodes and a new line its indent (queries/indents.scm). The tapes go to the GPU as data: the color tape as picture.frag's uniforms, the out tape (with the one it replaces, for the crossfade) in a storage buffer for synth.comp, both including shaders/vm.glsl, a loop over the tape with a |
