Skip to content

Speed up cross-correlation with FFT convolution - #69

Merged
chrisn merged 1 commit into
bbc:masterfrom
comavius:use-fft-convolution
Sep 21, 2026
Merged

chrisn merged 1 commit into
bbc:masterfrom
comavius:use-fft-convolution

Conversation

@comavius

@comavius comavius commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Overview

This PR replaces the O((n1 + n2) * nframes * numcep) sequential offset scan with O((n1 log n1 + n2 log n2) * numcep) FFT convolution.

Benchmarking

I compared the execution time of find_offset_between_buffers between this branch and the main branch.

The benchmark uses the full 1812 Overture audio as the reference buffer and the same audio with the first 10 seconds removed as the comparison buffer. Each implementation was run 50 times in shuffled order after decoding the audio once.

Branch Mean execution time (s)
main 4.664295812019845
this branch 0.6442086398595711

The audio file is available on Wikimedia Commons:
https://commons.wikimedia.org/wiki/File:Pyotr_Ilyich_Tchaikovsky_-_1812_overture.ogg

@comavius

Copy link
Copy Markdown
Contributor Author

@stephenjolly
Could you please review this PR? It speeds up hot-path algorithm in both time complexity order and benchmarking score. There's no breaking change in function interfaces and invariants.

@chrisn

chrisn commented Sep 19, 2026

Copy link
Copy Markdown
Member

Thanks for this, looks like a nice improvement! The CI tests were failing, so I've just fixed those. Would you mind rebasing this branch on top of the latest master branch so we can verify all the checks are passing?

This replaces the O((n1 + n2) * nframes * numcep) sequential offset scan
with O((n1 log n1 + n2 log n2) * numcep) FFT convolution.
@chrisn
chrisn merged commit 4886fb8 into bbc:master Sep 21, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants