Make the transform a Fourier transform - #48
Merged
Conversation
`listen.ts` is how the app reads sounds out of a recording: find where they are, then say whether two of them are the same kind of thing. Underneath all of it is a Fourier transform, and it was not one. The angle it multiplies by was turned once per block instead of once per butterfly, so every butterfly in a block used the angle it started at, which is no angle at all. What that computes is a Walsh-Hadamard transform. A five cycle cosine, which belongs in bin five and nowhere else, came out spread across every odd bin with its peak in bin fifteen. Found by comparing against a transform written straight from the definition. Nothing else could have found it. Every test that compares one fingerprint against another passes on a transform that is merely consistent, and this one was: it scrambled every spectrum the same way, so two takes of a sound still matched and nothing above ever complained. What was lost was every comparison between sounds that are not the same, which is the whole of what this file does. The four pages under `tools/` have the same transform with the line in the right place. This copy is the one that moved, and the comment above it says why that matters -- "moved here so that the app and the pages that measure it cannot come to disagree about what a sound looks like". They had come to disagree. After the fix it matches the definition to 4.6e-13. Thirteen tests, including that comparison, a tone landing in its own bin at five different frequencies, silence staying silent, a constant living entirely in the bin that means no change, and what the fingerprint is for: that taking out what a set of sounds have in common pushes two of the same kind apart, 0.95 to 0.45, which is the thing the ordinary exists to do. Three of those tests were mine and wrong first. `mono` does not take the centre out, `ordinary` averages the logs rather than the prints, and a quieter take of a sound is not identical to it -- half of a print is how loud each slice was -- so that one asks whether it is nearer to itself than to something else rather than asking for a number. 333 unit tests, 88 browser tests, build clean. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ux1kydvUkLRoMbHp82ofDi
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
listen.tsis how the app reads sounds out of a recording — find where they are, then say whether two are the same kind of thing. Underneath all of it is a Fourier transform, and it was not one.What was wrong
The angle it multiplies by was turned once per block instead of once per butterfly:
So every butterfly in a block used the angle it started at, which is no angle at all. What that computes is a Walsh–Hadamard transform.
A five-cycle cosine, which belongs in bin 5 and nowhere else:
Only one kind of test could find it
Every test that compares one fingerprint against another passes on a transform that is merely consistent — and this one was. It scrambled every spectrum the same way, so two takes of a sound still matched and nothing above it ever complained. What was lost was every comparison between sounds that are not the same, which is the whole of what this file does.
It took a naive DFT, written straight from the definition and slow enough that nobody would ship it. After the fix, the two agree to 4.6e-13.
The comment above it says why this matters
The four pages under
tools/have the same transform with the line in the right place. This copy is the one that moved, and its own comment reads:They had come to disagree.
Thirteen tests
The DFT comparison, a tone landing in its own bin at five frequencies, silence staying silent, a constant living entirely in bin zero, and what the fingerprint is actually for — taking out what a set of sounds have in common pushes two of the same kind apart, 0.95 → 0.45.
Three of those tests were mine and wrong first, which is worth saying:
monodoesn't take the centre out,ordinaryaverages the logs rather than the prints, and a quieter take of a sound isn't identical to it (half a print is how loud each slice was) — so that one now asks whether it's nearer to itself than to something else, rather than asking for a number I picked.333 unit tests (was 320), 88 browser tests, build clean.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Ux1kydvUkLRoMbHp82ofDi
Generated by Claude Code