GrepAwk Blog

Blog / GrepAwk

GrepAwk

Audio fingerprinting for WoW arena: how a phone hears spell sounds

How a phone recognises World of Warcraft arena spell sounds with Shazam-style audio fingerprinting: peaks, hash pairs, offset voting, and test results.

By Yisheng Jiang · · 13 min read

The Solo Shuffle Audio Coach listens to World of Warcraft arena through a phone microphone and speaks a call: "Run" when an enemy pops an offensive cooldown, "Attack" when an enemy defensive is about to end or a healer is crowd controlled. This post explains the audio fingerprinting behind it, why the first approach failed, and what the tests show. The code is public and the app runs in any phone browser.

The coach only listens and talks. It never attaches to the game, reads memory, inspects network traffic or sends inputs. The microphone is its only input.

The idea: the game replays the same file

Every time a spell goes off, the game plays the same recorded sound file. That turns a vague "does this sound like a spell" problem into the problem Shazam solves: find a known recording inside noisy audio. Arena audio is a dense mix of abilities, footsteps, voice chat and music, and the phone adds a speaker, a room and a cheap microphone on top.

Each spell in the library has a role, and the role decides the call:

Role Call When
Threat (offensive cooldown) "Run" Right away
Defensive "Attack" At cast time plus the buff duration, minus a 0.5 s lead
Crowd control "Attack" Right away
Pipeline diagram: Wowhead spell pages become clips, then a preset of peak-pair hashes; on the phone the microphone feeds a spectrogram, peaks, pair hashes, an index lookup and an offset vote, then a role policy and speech

Building the library

A script opens each spell's Wowhead page in a visible Chrome window, one page every 4 to 8 seconds. It downloads the audio files listed under Sounds and reads the buff duration, which the defensive timer needs. The manifest lists 2 to 3 spells per class, each tagged threat, defensive or crowd control.

What the harvest and fingerprinting produced Count
Spells 40 (20 threat, 16 defensive, 4 crowd control) across 13 classes
Spells with at least one fingerprinted cue 40 of 40
Sound kits found on Wowhead pages 84
Clips downloaded 191
Cues fingerprinted 165
Landmark hashes in the preset 165,919
Defensives with a buff duration 16 of 16

The 26 clips that were not fingerprinted are looping "state" sounds. They are skipped whenever the spell also has a one-shot cast or impact sound. Each clip is fingerprinted from its first 3 seconds, which gives about 1,000 hashes per cue on average (165,919 over 165 cues).

The site ships only the hashes, in one JSON file with labels and spell metadata. It contains no audio. The clips themselves stay in the repo so the preset can be rebuilt, and they remain Blizzard's audio.

Why the first matcher failed

The first version compared spectral shape. It turned each frame into 18 mel bands, centred and normalised them, and scored the newest live frames against each cue's frames by mean cosine similarity:

// removed matcher: mean cosine between live frames and a cue template
total += obs.reduce((sum, value, j) => sum + value * ref[j], 0);
// ...fire when the best mean score passes the threshold (default 0.86)

On injected spells it caught about a third of them while making about 140 false calls a minute. Arena noise and commentary have a coarse spectral shape similar to many spell sounds, so there was no good threshold:

Threshold Recall at +6 dB False alarms on a clean VOD
0.86 (default) 33 to 35% about 140 per minute
0.93 13 to 18% about 22 per minute
0.96 5 to 8% about 3 per minute

Even clips that were in the library were missed 60 to 80% of the time. The lesson is that coarse spectral shape is the wrong feature. Exact peaks in time and frequency are far more specific, so the matcher was replaced, not tuned.

Scatter of recall against false calls per minute on a log axis: mel-cosine points sit at 5 to 35% recall with 3 to 140 false calls per minute, the landmark matcher at 94 to 100% with 0.1 to 0.9

Audio fingerprinting, step by step

landmark.js is a single ES module. The same file runs in the phone's browser and in the Node test tools, so the test numbers describe what the phone does. All parameters live in one object:

export const LANDMARK = {
  rate: 16000,
  fftSize: 512,        // 32 ms window, 31.25 Hz bins
  hop: 128,            // 8 ms frames
  minBin: 4,           // ignore below 125 Hz
  maxBin: 232,         // ignore above 7.25 kHz
  peakTime: 5,         // local max over +/-5 frames (+/-40 ms)
  peakFreq: 6,         // and +/-6 bins (+/-188 Hz)
  peaksPerFrame: 4,
  peakFloorDb: 8,      // above the frame's mean log magnitude
  fanout: 6,           // pairs per anchor peak
  pairMinDt: 2,        // 16 ms
  pairMaxDt: 50,       // 400 ms
  pairMaxDf: 48,       // +/-1.5 kHz
  maxClipFrames: 375,  // first 3 s of a clip
};

1. Spectrogram

An AudioWorklet resamples the microphone to 16 kHz (with a 4th-order low-pass at 7.2 kHz first when the device runs faster) and sends 2048-sample chunks, about 128 ms each. Each 512-point Hann-windowed FFT gives one frame every 8 ms. Magnitudes are converted to decibels, and only the band from 125 Hz to 7.25 kHz is kept. Rumble and mains hum sit below it, and the resampler's anti-alias band sits above it.

2. Peaks

A bin is a peak when it is the maximum of its neighbourhood (5 frames either side, 6 bins either side) and at least 8 dB above the frame's mean. At most 4 peaks are kept per frame, loudest first.

if (v < floor) continue;           // floor = frame mean + peakFloorDb
// isMax: no bin in the +/-5 frame, +/-6 bin box is louder
if (isMax) candidates.push({ f: b + LANDMARK.minBin, v });
candidates.sort((a, z) => z.v - a.v);
for (const peak of candidates.slice(0, peaksPerFrame)) { /* keep */ }

Peaks are the part of a sound that survives noise. Adding background audio hides some of them, but the loud, narrow ones usually remain.

Spectrogram of the Recklessness cast clip with peaks as blue dots and white lines joining the pairs made from anchors between 0.55 and 0.7 seconds

That clip is 2.8 seconds long. Its fingerprint has 156 distinct peaks and 815 hashes.

3. Pair hashes

One peak alone says little. A pair says a lot: "a peak at frequency A, then a peak at frequency B, this many frames later." Each peak (the anchor) is paired with up to 6 later peaks that are 16 to 400 ms after it and within 1.5 kHz. A pair packs into 22 bits:

export function makeHash(f1, f2, dt) {
  return ((f1 & 255) << 14) | ((f2 & 255) << 6) | (dt & 63);
}

The hash holds frequencies and a time gap, but not the absolute time. The anchor's frame number is stored next to it, as [hash, t].

4. Look up and vote

At start, the matcher builds a map from every preset hash to the list of (cue, clip frame) pairs that contain it. Each live hash is looked up, and every hit adds one vote to a bucket keyed by cue and offset, where the offset is the stream frame minus the clip frame:

const offset = t - list[i + 1];
const key = cue * 65536 + (offset & 0xffff);
this.counts.set(key, (this.counts.get(key) || 0) + 1);

If the clip really is playing, all of its hashes agree on one offset: the moment the clip started. Background audio produces some accidental hash hits, but they land on scattered offsets and never pile up. Votes are kept for a 2.5 second window, and each offset's score includes its neighbours at plus or minus 1 frame for timing jitter. A cue is reported when its best score reaches the minimum matches setting.

Bar chart of hash hits by offset for the Recklessness cue: 66 hits at frame 250 and almost none elsewhere, well above the lines for 8 and 12 minimum matches

The chart is from a check I ran for this post: the Recklessness clip mixed into white noise at 0 dB, two seconds in. The cue got 78 hash hits in total, 66 of them at frame 250 (2.0 s at 8 ms a frame). The strongest wrong cue peaked at 4 hits.

Two more details keep it to one call per sound. Variants of one spell share a group, so a sound that was reported is ignored while it keeps playing, and when two cues match the same moment because they share a file, the stronger one wins.

From a match to a spoken call

The app applies a small policy on top of the matcher. Each spell has a 1.4 second refractory period, and threat and crowd control calls share a 2 second global cooldown. A defensive heard at time T schedules "Attack" for T plus its buff duration minus the attack lead. The phone ignores the microphone while it is speaking its own call. A defensive that is dispelled early still waits out the full timer, because the coach times from the cast sound.

Test results

All numbers below come from docs/detection-testing.md in the repo, tested on 2 December 2026, unless a section says otherwise. The offline tools run the phone's exact matcher (LandmarkMatcher plus the app's call policy) over recorded audio.

Question Result
Landmark recall on injected spells, direct mix 93 to 100%
Landmark false alarms on a clean VOD 0.1 to 0.9 per minute
Landmark recall through a simulated phone and room 46 to 88% with 0 false alarms
Median latency after the sound starts 0.7 to 0.8 s direct, 0.5 to 0.6 s in room mode
Sound variants that are not in the library found about 11% of the time
Real 7 hour stream, detections with 12 or more matches independently confirmed by waveform correlation

Injection test: known answers

Recorded VODs come with no list of when spells were cast. To get ground truth, detect-vod.mjs --inject mixes library clips into real arena audio every 9 seconds at +6, 0 and −6 dB against the local background, then counts hits, wrong-spell calls, false alarms and latency. The --room option simulates the phone path on the whole mix: a 250 Hz to 6 kHz speaker band, about 0.35 s of reverb, microphone noise and plus or minus 0.3% clock drift. --holdout removes the injected clip's own fingerprint to test a variant that is not in the library.

Two VODs, minimum matches 8:

Path Recall at +6 / 0 / −6 dB False alarms (clean VOD) Median latency
Direct mix 94 to 100% / 93 to 100% / 100% 0.1 to 0.9 per minute 0.7 to 0.8 s
Simulated room 58 to 88% / 46 to 67% / 50 to 67% 0 per minute 0.5 to 0.6 s
Held-out variant about 11% not measured not measured
Floating bars of landmark recall range at +6, 0 and minus 6 dB for the direct mix (93 to 100%) and the simulated room (46 to 88%), with a dotted line at about 11% for held-out clip variants

Settings that were tried and rejected: a coarser frequency cell (hashFreqShift: 1) gave slightly more recall but 17 to 240 false alarms a minute. A shorter pairing window (pairMaxDt 25 or 35) with a fan-out of 8 cut latency to about 0.4 s but lowered recall in room mode. Dropping minimum matches to 5 or 6 added 5 to 10 points of recall and 0.4 to 4 false alarms a minute.

A real stream: 7 hours 8 minutes

The injection test is synthetic, so the detector also ran over a real stream of a Fury and Arms Warrior player, arena and battlegrounds. The whole 7 h 08 m stream was processed in about 2 minutes and produced 1,159 calls, or 2.7 a minute.

Agreeing hashes Calls What they look like
8 to 9 1,105 Spread over unrelated spells (178 "Dragonrage" calls in a Warrior stream), mostly noise
10 to 14 48 Mixed
15 or more 6 Recklessness and Polymorph
Bar chart on a log axis of the stream's 1,159 calls: 1,105 with 8 to 9 matching hashes, 48 with 10 to 14, and 6 with 15 or more

Of the 13 calls with 12 or more matches, 9 are Recklessness, the streamer's own cooldown. In the last 25 minutes its 7 hits with 12 or more matches were 1 minute 51 s to 3 minutes 47 s apart, which fits its 90 second cooldown. Only one pair of detections (6:57:14 and 6:57:58, 44 seconds apart) was closer than the cooldown allows.

An independent check: waveform correlation

A hash match could still be a coincidence, so verify-xcorr.mjs does not use landmarks at all. At each detection it computes the normalised cross-correlation (NCC) between the stream's waveform and the Wowhead clip, and compares that with 150 random positions in the same stretch. A real playback of the file should score above every random position.

Bar chart of waveform NCC for 12 detections between 6:35 and 7:00, with the maximum NCC from 150 random positions drawn as a line over each bar; most Recklessness and Polymorph detections sit above the line

Of the 12 detections in the 6:35 to 7:00 window, 7 were confirmed, 2 were likely (above the random 99th percentile of 0.262), and 3 were not confirmed. The Polymorph hit with 50 matching hashes had an NCC of 0.947 against a random maximum of 0.270, which is a near-exact copy of the file. The detections that failed had 9, 10 and 14 matches.

App tests

The repo has 14 Playwright end-to-end tests with a mocked microphone that streams real harvested clips through the same matcher. They check that hearing Recklessness says "Run" immediately, that hearing Ice Block says "Attack" only after its 10 second buff minus the lead (nothing is said at 9 seconds, then one call at about 9.5 seconds), that stopping cancels pending calls, that silence and noise produce no calls, and that cue labels render as text. I ran the suite on the current main branch: 14 passed in 7.5 seconds.

Reproducing the preset and a synthetic noise check

Two more checks I ran for this post, on the current main branch:

  • Re-fingerprinting all 191 harvested clips with landmark.js reproduced the shipped preset exactly: 165 of 165 cues identical, 165,919 hashes.
  • I embedded each of the 165 clips in 6 seconds of white noise and fed it through LandmarkMatcher. This is easier than real arena audio in some ways and harder in others, so read it as a sanity check, not a replacement for the VOD tests:
Clip level against the noise Minimum matches 8 Minimum matches 12
+6 dB 160 of 165 160 of 165
0 dB 151 of 165 130 of 165
−6 dB 93 of 165 (89 as the correct spell) 63 of 165

Ten minutes of noise alone produced no calls at either setting.

Parsing results: what the library contains

Horizontal bars of fingerprinted cues per spell, coloured by role, with the share from generic-looking files hatched; most spells have 1 to 8 cues

Not every sound file is specific to one spell. 56 of the 165 cues come from generic-looking files (names such as PreCast*, FX_* or numeric titles), and 14 cues come from files shared with another spell. Only 18 of the 40 spells have cues that are all spell-specific. Dragonrage and Obsidian Scales have 8 cues each and every one is generic-looking.

That matters for what a match means. The Recklessness hits on the stream matched SPELL_WR_GladiatorStance_Cast, a file Wowhead lists on the Recklessness page that is named after a stance. The Polymorph hit matched PreCastMageLow, a generic mage precast, so it means "a mage is casting". Divine Shield and Blessing of Protection share files, and so do Barkskin and Aspect of the Turtle.

What it does not do yet

  • The default minimum matches in the app is 8. On the real stream, confirmed hits had 12 to 50 matches and 10 was the noise floor, so about 12 is the better bar. At 8 the real stream gave about 2.5 false calls a minute. Raising it trades some recall in noisy conditions, as the synthetic check above shows.
  • Only the harvested recordings are recognised. A variant that is not in the library is caught about 11% of the time.
  • Generic precasts should become class-level calls such as "mage casting", or be dropped.
  • The tests used recorded VODs and a stream. It has not yet been tested on a real phone next to real speakers in a real room, and the simulated room is only an approximation.

Try it and reproduce it

Open the app on your phone over HTTPS, play the game through your PC speakers rather than headphones, and tap Start Live Coach. The full method is in the approach write-up and docs/detection-testing.md. To run the detector over any audio:

node training/detect-vod.mjs <audio>                 # what the phone would say, with timestamps
node training/detect-vod.mjs --inject --room <audio> # recall test with a simulated phone path
npm run train:wowhead                                # rebuild the preset from the harvested clips

For a related build in audio, see how SoundFonts work.