Auto-detecting the A–B region (porting ~/dev/Looper's algorithm) #
What Looper actually does #
~/dev/Looper/loop.py, ~140 lines of Python + numpy, is not a looper — the looping is
if i == loop_offset: i = start_offset in a playback loop. The substance is
find_loop_point, and it has four moves:
- One number per frame. Decode to PCM, and per frame take
|rfft|of the first channel, keep only the bins in a "fingerprint region" ([1:25], chosen because that is where the melody of the files they tested lived), mask bins below0.25 × the global peakso noise cannot win, and take the argmax: the loudest bin in the band. The whole track becomes a series of ~40 integers. - Correlate the series with itself. Pearson
rbetween two windows of that series (sig_corr), or the fraction of exactly-equal frames (pct_match, defined but never called —pct_matchis dead in the shipped code). - Search. Ten start candidates (stride
len/10, first at frame 200), everyendafterstart + 500, 500-frame windows. Keep the single best pair. No threshold: the bestrwins however bad it is. - Play. From
starttoend, jump back tostart, forever.
Its README is honest about the consequence: it needs ~20 s of repetition to confirm, and "if the song does not repeat… it will loop, but it may do so at strange points."
Why it is a different piece of work here #
None of Looper's plumbing applies, and pretending otherwise would be the mistake. It
decodes MP3 through mpg123 because it has to; this app already holds the decoded
Float32Array — the store's decoded map keeps the buffer for the playing track, and
bufferDuration() is that buffer's exact length, which is what every boundary in the
A–B feature is measured against. So the port is the detection, run on samples we
already have, and it is automatically as format-agnostic as the app is (their mp3-only
limitation is a limitation of mpg123, not of the algorithm).
Three things in it do not survive contact with this codebase, and each needs a decision rather than a translation:
- No "no".
find_loop_pointreturns the best pair it found. Measured below: a track with nothing repeating scores r ≈ 0.6–0.68 and would be looped. The store's rule is the opposite —setLooprefuses rather than guessing — so detection needs a floor, and the floor needs to be a number someone chose on purpose. - Its constants are frequencies in disguise.
clip_start/end = 1..25and a 500-frame window are 38–957 Hz and ~13 s at 44.1 kHz with 1152-sample MP3 frames. This app's samples arrive at the AudioContext's rate with no frames in sight. The port must say "40–1000 Hz" and "13 s" and derive bin and frame counts, or the numbers silently mean something else on a 48 kHz file. - The dominant bin is a monophonic pitch contour. That representation is what makes Looper good at video-game tunes — one clear melody line — and what makes it blind to a dense mix, where the loudest bin in 40–1000 Hz is a bass note that does not change. It is worth keeping for v1 (it is fast, and the app is a game-music player) but it should be one function with a name, not the shape of the module, because the first thing a wrong answer will make us want to do is change it.
Measured, on a synthetic track whose answer is known #
/tmp/fftbench/{detect,phase,earliest}.mjs — plain Node, fft.js for the transform, a
generated "20 s unique intro + 30 s body × 7" track. These are the numbers the decisions
below rest on; they are not real music, which is the biggest gap in this plan.
Cost, 4-minute track (4952 frames of 2048 samples):
| transform | fingerprint | search | total |
|---|---|---|---|
fft.js, realTransform, 2048-pt @ 44.1 kHz |
58 ms | 8 ms | 66 ms |
| fft.js, box-decimated 8× then 256-pt | 14 ms | 8 ms | ~22 ms |
| hand-rolled radix-2, sin/cos per butterfly | 609 ms (projected) | 8 ms | ~0.6 s |
| hand-rolled radix-2, twiddles precomputed | 26 ms — wrong, see below | 8 ms | not a number worth quoting |
So Looper's own search — one answer, the best pair — costs ~22 ms for a 4-minute track, 46 ms at 8 minutes, and needs no worker. The design we actually chose needs the second number, not the first: anchoring on the playhead means every candidate the track sustains, not just the winner, and enumerating those is ~237 ms (measured over every sustained period, positions sampled every 4 frames — the stride is the lever, and the first number to quote is the one from a run that found nothing at all, so read timings with the answer next to them). That is why there is a worker below, and why it is given the fingerprint rather than the audio. The transform itself was never the problem: no dependency in this file would have made the feature feel faster, because the FFT was already costing 14 ms of a 250 ms feature.
The decimation is the big win and it is not about the FFT at all: the algorithm only ever reads 40–1000 Hz, so the samples can be box-averaged 8× before anyone transforms them — a 4× saving bought by discarding information the fingerprint was never going to look at. Kept visible as a caveat: a box filter is a poor anti-alias, so energy above 5.5 kHz folds back into the band. Decimated and undecimated runs agreed on every synthetic case here — and the synthesised notes top out around 5 kHz, which is exactly where that agreement stops meaning anything. Real, bright, cymbal-heavy audio is what settles it.
fft.js is verified against the definition; my hand roll was not, and that is the
argument. /tmp/fftbench/verify.mjs prices a pure tone three ways — fft.js, my
hand-rolled radix-2, and a direct DFT (the definition, ~15 lines, no way to get it wrong):
120 Hz → bin 6 fft.js peak 6 (rel 1.00) my radix-2 peak 80 (rel 0.03) naive peak 6
440 Hz → bin 20 fft.js peak 20 (rel 1.00) my radix-2 peak 44 (rel 0.46) naive peak 20
990 Hz → bin 46 fft.js peak 46 (rel 1.00) my radix-2 peak 54 (rel 0.03) naive peak 46
fft.js matches the definition at every frequency. My hand-rolled one ran at a plausible
26 ms, produced plausible-looking numbers, and was wrong by up to 400× — nothing about its
output said so; only asking a question with a known answer did. So that fourth row is not
a speed comparison (it times a broken transform doing the wrong arithmetic quickly), and
the dependency question was never really about milliseconds. It is about who owns the
correctness of a bit-reversal loop — and whichever answer you prefer, the tone-vs-DFT
check above ships as a test in detect.test.ts, because it is the only thing in this
plan that caught a bug I would otherwise have merged.
fft.js: MIT, 0 deps, 22.4 kB, 507 lines, published Jan 2021 (frozen — for a radix-4 FFT
that is not the alarm it usually is). One genuine cost: its shipped lib/fft.d.ts is
size: any, createComplexArray(): any[] — the types are useless — so we hand-write
the ~15-line declaration for the three methods used and pass Float64Array storage in
(realTransform wants it; createComplexArray returns a plain Array, which would be the
slowest thing in the loop if we took it).
Accuracy, same track (truth: A=20 s, period=30 s):
| case | Looper's search | |
|---|---|---|
| intro + identical body ×7 | A=28.0 s | period 30.0 s, r=1.000 |
| first pass fades in (not a copy) | A=28.0 s | period 30.0 s, r=1.000 |
| long 60 s intro, 24 s body ×6, denoise cut 0.05 | A=147.7 s | period 24.0 s, r=0.999 |
| same track, Looper's own cut of 0.25 | A=66.2 s | period 47.9 s — twice the truth |
| nothing repeats, 4 min | A=52.9 s | period 72 s, r=0.644 |
| nothing repeats, other seed | A=76.9 s | period 115 s, r=0.601 |
Two things in that table are design instructions, not results:
A period can be a multiple of the truth, and the mask is what lets it happen. The one
track where Looper's own 0.25 cut reported a period, it reported 47.9 s for a 24 s loop —
the second harmonic of the seam, which matches itself just as well. Measured on the same
audio at a gentler cut the answer is the correct 24.0 s, and the reason is visible in the
fingerprint: Looper's mask keeps 35 % of frames at 0.25 and 66 % at 0.05, so at
the harsh setting two thirds of the melody is silent and the correlation is being decided
by the few frames that survive. So: the cut is a tunable with a measured optimum, not a
constant to inherit, and the search must prefer the shortest period that clears the
floor rather than the highest-scoring one — a 24 s loop and a 48 s loop score the same
and only one of them is right.
The floor has a measurable gap to sit in. Real repeats came out at r=1.000; tracks
with nothing repeating topped out at 0.60–0.68. That is the number setLoop's refusal
philosophy needs, and the honest caveat with it: this is synthesised tonal material, where
the separation is easy. Real music — a verse and a chorus that share chord tones — will sit
closer to the line, so the floor is calibrated on the user's own library, not inherited.
Read the A column now: the period is recovered exactly whenever the mask has not thrown away the evidence, including the case Looper's README says it cannot handle (a first pass that is not a bit-exact copy of the later ones). The phase — where A lands — is wherever the ten-candidate stride happened to fall: 28 s when the music's loop starts at 20 s.
That is not a defect to fix, it is a property to understand, and it is the most important thing in this plan. On a body that is truly periodic, every alignment inside the body scores r=1.000 — I tried to buy the phase back by sliding both edges and keeping the best, and it moved nothing, because there is no best: any 30 s window of a 30 s-periodic body is the same loop. Denser sampling does converge on the composer's seam (500 start candidates → A=19.9 s) but it is 1.3 s of CPU for an answer that sounds identical. Where phase genuinely matters is only: (a) the region must not swallow a one-shot intro, and (b) what the user sees drawn on the bar, and what "the loop" means if they go to edit it.
(My attempt to recover the phase by walking forward to the first self-consistent position did not work in the prototype — it refused on every track, including the clean one. It is filed below as an open item, not sold as a plan: the loop point it would produce is a nicer-looking region and an identical-sounding loop, which is a thin reason to spend more time on unproven code.)
Also measured: the mask's proportionality. Looper's 0.25 cut throws away 65 % of
frames (audible 35 %) — one loud passage raises the global peak and blanks every
quiet frame in the track. At 0.05 the answer is unchanged and 66 % of frames survive.
And the trap I set for myself: a corr that gates on "at least half the window audible"
rejects everything once the mask has eaten 65 % of the frames — it has to gate on the
jointly-audible count relative to what is audible at all, not on the window length.
Plan #
Detection is a pure function over samples, and that is the shape that keeps it testable: no audio graph, no clock, no DOM, no signals — Float32Array in, region-or-refusal out. Everything else is wiring to that, and each of those steps earns its place on its own.
1. src/lib/player/detect.ts — the algorithm, alone.
export interface Candidate {
start: number;
end: number;
period: number;
r: number;
}
export type Notfound = "no-bytes" | "no-repeat" | "not-convincing";
export interface DetectResult {
candidates: Candidate[];
not?: Notfound;
}
/** The cheap half: samples in, a compact bin series out. Runs on the main thread. */
export function fingerprint(
samples: Float32Array,
sampleRate: number,
opts?: DetectOptions,
): Series;
/** The expensive half (~237 ms of a worker core): bins in, every candidate out. */
export function search(fp: Series, opts?: DetectOptions): DetectResult;
Two functions and not one, because they run on different threads — see step 3 for why the
seam falls exactly there. search returning candidates: [] with a not is the interesting
part of the signature: the emptiness is typed, it is named, and it says which kind of empty. Internal steps:
band-energy fingerprint (decimate → transform → band peak with a proportional mask) →
correlation(a, i, b, j, len) over the masked series → the search → the floor. Two rules
the measurements above force, both of them departures from Looper's text:
- shortest period over the floor, not highest score. A 24 s loop and a 48 s loop score identically and only one is the loop; the search takes the smallest period that clears the floor and only then looks for where it begins.
- the correlation's bail-out is counted against joint audibility, not against the window. With the mask eating two thirds of the frames, a pair of windows is never half audible, and a gate written that way — which is what I wrote first — rejects every pair and reports "no loop" on a track that loops. The number of frames where both windows are audible is the evidence; that is what must clear the minimum.
Tests first, against generated signals, in detect.test.ts. The generator goes in
src/test/signal.ts beside the existing fake — the same argument as test/audio.ts:
what these tests need is a track with a known answer, and a fixture mp3 in the repo
could not say "the body repeats at exactly 20 s" as legibly as a function can. Cases, in
the order that finds the lies:
-
the transform, against the definition. A pure tone at a handful of frequencies, priced by the fingerprint's own transform and by a direct DFT, agreeing on the peak bin. This is the test that caught the bug I would have merged — my hand-rolled radix-2 ran at a plausible speed and was wrong by 400×. If fft.js is used it documents why; if anything hand-rolled is ever used it is the only thing standing between us and a silent wrong answer.
-
identical body repeated → the period, exactly, and a region whose
end - startis the period (detectdoes not get to choose the phase — see the finding above — so the test asserts the period and that A lies inside the body, not that A equals 20). -
the first pass not a copy (faded in) → still found. This is Looper's advertised limitation and the one case where a plausible-looking implementation quietly fails.
-
nothing repeats →
null. Both from the same generated family, different seed. This is the test the port has to have and Looper does not. -
a repeat shorter than the floor (a 2-bar motif in a 4-minute track) →
null, so that finding a hook is not mistaken for finding the loop. -
silence, and a track that is one constant tone →
null, not a confident answer. (The degenerate case is reachable: a series with no variance makes Pearson undefined, which in numpy is NaN and in the prototype is a bail-out — and NaN compared against a threshold is false, so a naive port returns "nothing" where it means "this means nothing" and a careless one returns the pair it started with.) -
the fingerprint's own behaviour, pinned separately: the same song synthesised at 44.1 kHz and at 48 kHz yields the same seconds, which is what keeps the constants from being frequency-in-disguise.
-
the mask: a track with one very loud passage and a quiet melody still gives the fingerprint that the quiet melody deserves — the assertion behind choosing a lower cut.
2. The samples. AudioBufferLike gains getChannelData(channel: number): Float32Array
— the real AudioBuffer has it; the structural interface in engine.ts has simply never
needed it. That is the whole engine change, and it is one line of the interface plus the
fake: FakeAudioContext's buffers must answer it, which means the fake learns to hold a
waveform. Existing tests hand the fake a URL-shaped body and get a duration; a track with
samples is a new option on the same constructor (waveformFor?: (url) => Float32Array),
defaulting to silence so nothing existing moves.
3. Two halves, split where the measurement says to split them. detectLoop is not one
job, it is two, and they are 17× apart in cost:
| half | what it needs | measured, 4-min track |
|---|---|---|
| fingerprint | samples + the transform | ~14 ms |
| search | a ~20 KB Int32Array of bins and nothing else |
~237 ms |
So the fingerprint runs on the main thread and the search runs in a module worker
(new Worker(new URL("./detect.worker.ts", import.meta.url), { type: "module" }) — Vite 8
at target: "esnext" needs no configuration for this, and the repo has no worker yet, so
this is the one genuinely new piece of machinery in the feature). The message that crosses
is the fingerprint, not the audio: 4952 integers instead of a ~42 MB channel copy, because
handing the worker the samples would mean copying them — an AudioBuffer's channel
arrays are not transferable, so a 4-minute track would cost a 42 MB main-thread memcpy to
save a message that is 0.05% the size. The worker also then needs no fft.js, no
AudioBufferLike, and no knowledge of what audio is: it takes bins and returns
{period, start, end, r}[].
It is kicked off when a track's bytes land — where the store's decoded map is
written — not on the key press, so c normally reads an answer that is already there.
Three consequences of that choice worth having said out loud:
- The app prefetches and decodes the successor already, so the candidates for the track you are about to hear are usually computed while you are listening to the current one. The key is almost always free before it is pressed.
- An answer that arrives by itself must not act by itself. Nothing lands in the region
unprompted:
cis what applies it. The chip readsA–B?in a muted gold when a suggestion exists and nothing is armed — the machine holding up an answer rather than taking one. - An in-flight result belongs to a track, and tracks change. The store already keeps a generation counter for loads; this needs the same thing, keyed by id, so the answer about a track you left twenty seconds ago is thrown away rather than applied.
createPlayerStore takes the analysis as an injected dependency, the way it already takes
engine, client and fetch — which is also what keeps jsdom honest: there is no
Worker in the test environment, and the seam means no test ever needs one. The fake is
the same pure function called directly. And that is the reason detect.ts must stay pure
with no DOM imports at all: the same module is what runs inline if Worker cannot be
constructed, which is a fallback rather than a second implementation.
- The refusal has to be sayable, and there are three refusals, not one. The result is a
discriminated union — candidates, or no bytes yet / nothing repeated anywhere in this
track / it repeated but not convincingly. A user who pressed a key and got silence needs
to know which happened, and the third of these is not the same news as the second: one
means the evidence was weak, the other means the track is through-composed. The floor:
r ≥ FLOORplus a joint-audibility minimum. Measured: real repeats 1.000, noise 0.60–0.68. The constant sits next to the measurement that set it, and it is wrong until it has been run on real files. - Candidates are ordered shortest-period-first, so the 2× harmonic a coarse mask invites is candidate 2 rather than the answer; and candidates whose run contains the anchor are presented first within that order, since that is what the user asked for by where they happened to be listening.
The anchor filters; it does not veto. Candidates come from the whole track and the anchor
only selects among them — which matters because game music has a one-shot head, so pressing
c at 0:07 of a track that loops 0:20→0:50 asks for candidates containing 0:07 and gets none.
That is not a refusal (decided): the chip reads there's a loop, just not where you are,
holding up the shortest candidate un-armed, and c again arms it. The alternative — refusing,
making the user seek into the body and press again — reads as "this track has no loop", which
is the opposite of the truth the bytes already told us. Nothing was guessed to produce that
readout: the region came from the audio, and the only claim being withheld is that it is where
you are. So the bar ends up carrying one more thing on one chip than it does today — nothing,
the hand-marked region, an armed candidate (A–B 2/4), a held-up candidate that misses the
anchor, and searching while the worker is out there — and two of those must not be
confusable — there's a loop, not where you are and nothing in this track repeats are
several seconds of music apart in what they mean, and collapsing them into "no loop found"
would be the design error that makes the whole feature look broken.
4. One key with a state machine, matching what m already does. c, for cycle:
first press filters the candidates to those containing the playhead, takes the first, and
arms it through setLoop — which is what makes every existing rule (refusal, the per-track
lifetime, the boundary on the audio clock, the session stamp) apply to a machine-chosen
region without a single new branch. Press again: the next candidate, wrapping, chip reading
A–B 2/4. C re-anchors at wherever the playhead is now — the two have to be different
keys because the playhead is always inside the current region, so "cycle" and "re-anchor"
would be the same words for two different acts. The chip clears, as it does now.
The empty filter is a state of this machine, not an exception to it: c with nothing under
the anchor holds the shortest candidate up un-armed, and the next c arms what is being
held. So the chip is read before it is pressed, and the machine has one shape whether or not
the playhead happens to sit inside the loop.
Each of those transitions gets a test where it lives, the same way the m machine is
covered: c with an anchor inside a candidate arms that candidate and calls setLoop (the
store's fake records the region — the test is that it went through the front door, not that
a signal moved); c again advances the index and wraps at the end; c with an empty filter
leaves the region untouched and sets the held-up state, and the following c arms what was
held; C re-reads the playhead rather than the region; the chip clears both. And one test
for the thing that makes the whole design safe: a detection answer arriving for the track the
listener has since left is dropped, not applied — the same shape of test the load generation
counter already earns.
The alternatives, since both l and L are the repeat-mode cycle today and m is the
manual region: f/F was the other candidate, and c won it for the mnemonic and for
being the one letter with nothing to defend. l/L would mean moving repeat-mode off its
key, which is the most-used control in the bar and not worth spending for a nicer letter.
The isLoopKey comment's claim — that nothing is reserved against Shift+L "because the
transport has no second loop gesture" — becomes false the day this ships, whichever key it
ships on, and should be corrected then rather than left to be discovered.
c joins the focused-button allow-list beside digit, loop and mark (a letter, like
them: a focused button is not what you are pressing it for) and passes through the ArtZoom
capture handler, because the reason you are looking for a loop is that the cover is up and
you are listening to the thing.
5. Persistence: no. A detected region is a claim about the file, not a user's intent,
and session.ts stores intent — which is why it stamps the loop with the track id it
belongs to and drops the mismatch on read-back. A detection is recomputed from the bytes
every session, ~240 ms of a worker core, and it does not occupy the intent slot. If it ever
wants caching the key is id+sid+duration in the idb store harvest/db.ts already
opens — but that is a second answer to "where did this region come from", and the app has
one answer today.
What we are NOT doing (v1) and why it is a defensible line #
- No spectrogram, no beat grid, no chroma, no
librosa. Looper's representation is one argmax per frame and it works, for its stated genre, at ~250 ms. Every "proper" version of this is a much larger module, and the failure mode it buys is only visible on material we have not tested yet. - No phase recovery, and cycling makes that acceptable rather than merely tolerable. The
measurement says any in-body alignment scores the same on periodic material, and the price
of the composer's seam specifically was 60× the CPU for an identical sound. What we have
instead is the candidate list: several alignments are offered,
cwalks them, and the manualmgesture stays the way to make an edge exact. (My attempt to walk forward to the first self-consistent position refused on every track, clean ones included — it is not in the plan because it is not working code.) - No snap-to-zero-crossing / crossfade at the seam. Real click-free looping wants the two edges sample-continuous, and candidates land on a ~46 ms fingerprint grid, so B→A will click on some tracks. Left deliberately: the boundary machinery is already sample-exact about the numbers it is given, so this is a refinement of candidates, not of plumbing, and it belongs with the listening session that calibrates the floor — a click and a wrong region get found in the same pass.
- No second search on the server, and no claim about knowing whether a track loops.
- One worker, not a pool, and it is created lazily. It does one thing at a time; a track change abandons the work rather than queueing it.
Ordering #
Tests against the generated signal first — the tone-vs-DFT check on the transform, then the
fingerprint, then the search, then the floor and the refusal — then getChannelData and the
fake's waveform, then the worker with its message protocol faked in tests, then
store.detectLoop behind the injected dependency (where the refusals get re-tested against a
store that never got bytes), then the key and the chip's states, then the README.
Two things to measure before calling it done, both cheap once the module exists and both
things no synthetic signal can tell us: the floor against real files from the actual server
(print r, period, and the seconds for a dozen tracks and pick the number looking at them),
and whether the seam is silent, by ear.
Decided in conversation #
-
fft.js is in, as the eighth dependency, on the argument that it is code we do not have to own — and on the evidence, which is that it matches a direct DFT on pure tones where my hand-rolled radix-2 did not, while running at a plausible speed and reporting plausible numbers.
-
ccycles,Cre-anchors, one key with a state machine in themidiom, over a candidate list rather than a single best answer — which is what makes the 2× harmonic a candidate instead of a bug. -
Detection is refused, not guessed, below the floor.
-
The machine may replace a hand-marked region, because asking for it is the thing that overwrote it:
capplies a candidate over whatever was there, the same waym's first press does. The chip andm's third press are the way back. -
An anchor with no candidates behind it is information, not a refusal: there's a loop, just not where you are, the shortest candidate held up un-armed until
carms it — spelled out under the refusals above, and distinct in wording and in behaviour from nothing in this track repeats. The anchor filters the candidates; it never vetoes them. -
cis here,Cis all of them,↑/↓are longer and shorter. The three questions a listener at a moment in a song can ask of a detected loop, one key each: the loop nearest the playhead, the next one along the track, the next claim up or down that still covers the region being heard. What was there before was two keys splitting those three badly —cwalked a list by score andCre-anchored it — and the pair that got lost was the one people asked for: the loop where I am, and a loop with some length to it. Re-anchoring is not lost, it is whatcnow does on every press, because "from here" is the unshifted key's whole meaning once the walk has its own key. -
The candidate list is chosen for where it is, not only for what it scores. Up to two per sixth of the file, twelve at most, backfilled from the ranking only when a track genuinely has one thing going on: ranked-and-truncated, a track whose body repeats for three minutes offered four positions of that one body and all of them from the first minute of it, which is the right answer to the wrong question.
cpicks by distance andCwalks the timeline, so a list that lives in the intro is a list that cannot answer a listener standing at 2:40. The per-family position cap went up to match, because it was the number actually holding the list in the intro. -
The walking order is the timeline's, not the search's. Each press a little further into the song: two regions you cannot compare by ear are two regions the key cannot choose between, and a walk that jumps 3:10 → 0:04 → 1:20 because of how the scores fell out is a leaderboard, not a tour.
-
↑/↓trade a detected loop for another candidate rather than stretching its edges. The candidates are the only boundaries with evidence under them; a region grown by a second into the noise is a loop that stops sounding like itself. Containment is asked of the region being heard rather than of the playhead — the same thing while a loop runs, and different in the one case that matters: a pass armed a moment ago is standing at A, and "longer" measured from there grows backwards out of the loop instead of around it. -
Only the detector's regions grow. A region the listener marked is the one piece of evidence a person actually supplied, and a key that quietly replaced their boundaries with the machine's nearest guess would be the feature arguing with the listener at the exact moment it should be listening.
-
←/→walk the list by place, becauseCwalks it by candidate. A place is one of the sixths the list is chosen on — the same partition from both ends, so one press is one visible step along the bar and the chorus-to-outro trip costs three presses instead of eleven. The best-scoring candidate of the place wins, ties to the tighter, which makes the keycasked about the next sixth rather than the current one; empty places are stepped over, and the sweep deliberately stops one place short of a full circle so a track whose loops all stand where the listener is gets its arrow key back unconsumed rather than an arm of something they were already hearing. Unlike the growing keys these answer on a hand-marked region too, because they navigate the detector's list rather than touching anybody's boundaries — the distinction is in the verb, and the colour follows the last one that was chosen. -
A detected region is drawn blue and a hand-marked one gold, in the bar and on the chip, and the store keeps the fact (
loopOrigin()) rather than the component: both kinds of region arrive through the same front door, and a component that remembered which one it had asked for would be wrong the moment the region was cleared, restored, or taken over by a mark. Marking the exact seconds the detector offered counts as taking it over — nothing re-arms, the boundary is already the boundary, but the claim changes, and the ink is told. -
The arrows are the loop's while it can use them and the list's the rest of the time.
↑/↓are already the library's row cursor on the same window; the store answersloopOwnsArrows()and the list yields only when a detected loop is armed and there is somewhere to go, so a key is never taken to do nothing.j/kare not contested and always move the cursor, which is why the list keeps both spellings of one action. -
Mono is the sum of the channels, not a slice of one. LoopMaker takes one channel by slicing every Nth sample, which is cheaper by a factor of the channel count and loses a melody panned to the other one — and the app plays stereo, so "the other one" is a coin flip decided by the mix engineer. Averaging rather than maxing: a melody panned hard left is still a melody, and maxing would double-count whatever the two mics disagree about. The reason this is a decision rather than a default is that the downmix costs nothing in accuracy — every stage of the fold that could care about level measures itself against the track's own peak, its own median frame, or nothing at all, so a hard-panned take folds to a bit-identical chromagram after the centre-placed one, which is the assertion the pin makes. Reversing it would need a reason to prefer one channel, and there is none.
Still open #
- The presence gate has no number yet.
chroma.tsnow knows how to ask whether a pitch class is sounding — within a fraction of the frame's own loudest class — and the default is still0, which means it does not ask, which is why the typicality weights have been a straight line of ones since the day they were written. Settle it on real files (detectTuning({ presence: 0.5 }), then the sitting indocs/research/calibrate-loops.md), and expect it to move the floor and the tail quantile with it: a comparison that starts discriminating produces lower scores everywhere, and thresholds calibrated against a representation that could not discriminate are not going to be the right ones afterwards. - The floor is calibrated against synthesised material, and the band edges too — see
hackermusic.detectReport()for the tool that prints a dozen real tracks in one call, anddocs/research/calibrate-loops.mdfor what to look at once it has run. On the first ten real tracks it was not the floor that decided anything (taucame from the tail every time), so this item is behind the one above rather than beside it.