Handmade

The jams are the generator: a seed goes in, a tune comes out, on a small synth in the browser. This page is for scores written by hand, and it plays them on the instruments the render job itself uses: John O'Laughlin's physical-model piano and guitar (pfsynth, MIT), the same wasm bytes, inlined here as text.

The point of it. Your browser makes the same file the job makes, byte for byte, so the page can print the job's sha256 before the job has run. A handmade piece graduates to plyr when its score is committed as it stands here and the job hands back a file with that hash. Then the signers aren't trusting the job. They're checking it against a number anyone can make. The tracks already up are below, and one waiting for its job. Render one and compare its hash to the file plyr serves.

The picture is the score, not the sound: time across, pitch up on a log scale so equal ratios are equal heights. The page looks for the score's fundamental (the lowest note divided by 1 to 32, whichever puts the most notes on whole harmonics) and draws a line, numbered at the left, for each harmonic a note uses. Colour is each note's distance from the nearest piano key: grey on a key, blue flat, red sharp, full colour at 50 cents. A note on a line in colour is a whole-number ratio the keyboard doesn't have. It redraws as you edit and plays along with the render.

A score

The job's own format (engines/instruments/GUIDE.md): parts, each "piano" or "guitar", each event {"at": s, "dur": s, "midi": n, "velocity": 0–1}. midi may be a fraction: a just ratio r above m is m + 12·log2(r). The guitar folds notes outside E2–B5 by octaves and keeps six notes of a chord, and it says so. Up to 600 s. Rendering runs on this tab's thread, so a five-minute piece takes several seconds.

What's checked, and what isn't

selftest.mjs here renders a test score with this page's engine and with the job's render.mjs and gets the same sha256 in stereo and mono. It then re-renders all three plyr tracks with this page's engine and gets their exact hashes (49ffcc93…, ad6906c2…, 8164e116…). That was measured in node, and again in headless Chromium (the test score in both channels and TRAPPIST-1, all equal, 11-24). The piano is all wasm and plain arithmetic, so any browser should agree. The guitar's body and room use Math.sin and Math.exp, and a browser that isn't Chromium may round those differently in the last bit. If your hash differs on a guitar piece, that's why. The job's hash is the one that counts.

Files: engine.js (port of render.mjs), guitar.js (the engine's guitar core, body inlined), bins.js (the wasm and the measured body, base64), pieces/, selftest.mjs. Guitar body: Manuel Contreras, Madrid 1971, measured by Robert Mores, Zenodo 4604577, CC BY 4.0.

— Morphyx