Null Test
Null Test is a terminal tool that compares two files by playing both through the same plucked string and keeping what is left when one is taken from the other: identical files give exact silence, and any difference rings. Build it with go build -o nulltest . (Go 1.22 or later, standard library only) and run ./nulltest A B on any two files on your machine, up to 256 MiB each. It prints a 64 by 20 report sheet, writes the recording to null.wav, plays it if a terminal is attached and a player exists (afplay, paplay, aplay, play or ffplay), and exits 0 for identical, 1 for different and 2 for trouble, as cmp does. ./nulltest A alone plays one file as a string.
nulltest [-s seconds] [-o file] [-q] A [B]
-s longest stretch to render, from the start of the recording, 2 to 120 (default 10)
-o WAV path (default null.wav, overwritten without asking)
-q never play, and write no WAV unless -o is given; the sheet still prints
nulltest -q a b >/dev/null && echo same # works like cmp -s
How it listens
- One byte is one sample at 44,100 a second. Past the end of a file every position reads 0, and the end itself reads 256 (the end mark), so a file and the same file with NUL bytes appended never compare equal.
- Both files go through the same string: a one pole AC coupling at about 21 Hz, then a Karplus-Strong loop of 400 samples and a two point average (gain 0.98). The string is linear, so B's string taken from A's is the string of the byte difference alone. Until the first difference the two strings compute the same numbers and the result is exactly 0.0.
- The recording starts one second before the first difference, stops at the last difference inside the
-sstretch, and rings out for 4.0 s. Identical files give up to 2.0 s of exact silence. - The recording is always normalised to -3 dBFS. The true level of the difference is on the sheet (
Level), not in the volume. Ringsis the sheet's account of what the ear gets: one changed byte is one pluck of about 1.8 s, an overwritten stretch is a short burst, an insertion or a truncation is one unbroken ring to the end.
Limits
- Byte for byte on purpose: no alignment of insertions or deletions. After an insertion every later byte differs, and it sounds like a truncation; the
Lengthrow tells them apart. - Files over 256 MiB are refused before reading. A pair at the limit held 530 MB of memory and took 0.3 s of CPU when identical, 1.4 s when every position differed (arm64, Linux).
- Playback needs one of the players above. Without one the WAV is still written and nothing is said about it.
- Names outside printable ASCII show as
?on the sheet, so it stays 64 columns. - The string is found at 110.11 Hz, 1.8 cents sharp of the nominal A2, and is not adjusted.
Checks
go test ./... runs the unit tests on the test binary itself as real input. bash check.sh builds the tool and runs every acceptance check of CARD.md end to end (needs cmp, tmux, uv); it keeps the sheets, the terminal captures and the recordings in out/.
Colophon
Form NT-1. Built from a delay line of 400 samples, a two point average and a 44 byte header. Set in the monospace your terminal already has, with no colour. The instrument was inspected at the time of building and found 1.8 cents sharp. It was left as found.
normal is dead
Files
- .gitignore
- README.md
- check.sh
- compare.go
- go.mod
- main.go
- nulltest_test.go
- out/burst.wav
- out/check.log
- out/flip1.wav
- out/identical.wav
- out/ins.wav
- out/pane-different-desktop.txt
- out/pane-different-phone.txt
- out/pane-errors-desktop.txt
- out/pane-errors-phone.txt
- out/pane-identical-desktop.txt
- out/pane-identical-phone.txt
- out/pane-insertion-desktop.txt
- out/pane-insertion-phone.txt
- out/pane-single-desktop.txt
- out/pane-single-phone.txt
- out/readme.wav
- out/sheet-burst.txt
- out/sheet-flip1.txt
- out/sheet-flip3.txt
- out/sheet-identical.txt
- out/sheet-ins-s5.txt
- out/sheet-ins.txt
- out/sheet-longname.txt
- out/sheet-readme.txt
- out/sheet-trunc.txt
- out/test.log
- out/tmux-ctrl-c.txt
- out/tmux-flip1.txt
- sheet.go
- shots.py
- string.go