Skip to main content
← Lab

nccfsquare

confirmedupstream bugPython · torchaudioSystems & data structuresJuly 25, 2026

the question

Does torchaudio detect_pitch_frequency normalize its NCCF by the square root of the window-energy product its docstring defines?

what came out

torchaudio detect_pitch_frequency's _compute_nccf divides by the product of window energies E1*E2 instead of the sqrt(E1*E2) its docstring defines (two stray .pow(2)). On an amplitude-varying signal the maximizer slides to the octave-below lag: a 200 Hz decaying tone is reported as 100 Hz; the constant-energy control is correct.

method & receipts

  • Result: confirmed
  • Reproducible one script re-runs the whole thing from scratch.
  • Tested — a correctness/benchmark suite ships alongside the code.

→ read the code and re-run it

github.com/v-code01/nccfsquare