| Commit message (Collapse) | Author | Age |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
`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
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
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
|