summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-17 01:01:26 -0300
committerGabriel Schneider <[email protected]>2026-11-17 12:15:01 -0300
commit70be2e0776d2e61a2d018b264ef5602e7e2c7f86 (patch)
tree620d316cc48062d374b1c270cda0723afbb3fc7f /README.md
parente699ffe4182f66e28180ea2d91ab1fb8c408d49e (diff)
downloadsketchbook-70be2e0776d2e61a2d018b264ef5602e7e2c7f86.tar.gz
sketchbook-70be2e0776d2e61a2d018b264ef5602e7e2c7f86.zip
micscope: a take starts its file empty; a deleted take's file stays, and why
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
Diffstat (limited to 'README.md')
-rw-r--r--README.md8
1 files changed, 5 insertions, 3 deletions
diff --git a/README.md b/README.md
index 7691d85..b59c3a3 100644
--- a/README.md
+++ b/README.md
@@ -124,7 +124,7 @@ State.
`imageAt`, `target`, `blend`, `text`, `print`, `clip`, `canvas`, `cursor`, `voice`, `gain`, `audio`, `microphone`, `pixels`, `gpu`,
`compute`, `upload`, `download`, `openFile`, `run`, `quit`, plus the three allocators and
`f.host` (`loadImage`, `decodeImage`, `newImage`, `newBuffer`, `loadSound`,
-`decodeSound`, `newSound`, `samples`, `readFile`, `appendFile`, `env`, `log`, `textSize`). Commands may be built
+`decodeSound`, `newSound`, `samples`, `readFile`, `appendFile`, `writeFile`, `env`, `log`, `textSize`). Commands may be built
from locals: the methods copy what they keep (text, GPU descriptions,
uniforms) into scratch. Bulk data (vertices, samples, pixels, uploads) is
not copied and must outlive the frame: scratch or session memory.
@@ -172,8 +172,10 @@ files are already written, say).
run`), creating it, and returns its path for `readFile` ("" when nothing
was written, and always on the web). Only `draw` and `command` can call it,
and a write is not replayed, like sound. `readFile` maps a file once, so
-what is appended afterwards is not in what it returned. micscope writes
-each take to `take-<id>.f32` as it records.
+what is appended afterwards is not in what it returned.
+`f.host.writeFile(name, bytes)` does the same to a new, empty file of that
+name. micscope starts each take's `take-<id>.f32` so, and appends to it as
+it records.
`f.download(buffer, .{ .size = n, .key = k })` reads a GPU buffer back
without stalling: the bytes arrive in a later frame's `in.downloads`, a