Was following along with this blog series from Cycfi research (the company that makes the pickup/sensors I’ve been using in recent builds) and they have a series on “Enhanced Pitch Detection Techniques”, which I found intriguing.
The main thing I found interesting is that it seems to include onset/offset detection as a core part of the algorithm, whereas AFAIK all the common algorithms (YIN, sigmund, etc…) all work exclusively on a rolling basis, or more specifically are architectured around that idea(?).
It’s also open source (GPL v3 I believe).
As best I can make sense of it (from reading the blogs, as the code itself is outside my understanding) it combines pre-processing with onset/offset detection, as well as some maths to do “first-cycle detection” where you get not starts and ends with regards to pitch with low latency.
Highlights
Blue: Signal conditioner output. The signal conditioner serves as a preprocessor, enhancing the raw audio input to facilitate analytical processes such as onset and pitch detection.
Orange: Onset and offset detection output. Positive displacements are onsets, while negative displacements are offsets. The result determines the signal’s attack and release levels relative to the most recent signal average.
Green: Main pitch detection result. Utilizing a highly specialized, fast, and efficient form of autocorrelation. The autocorrelation function (ACF) is, by far, the most accurate form of time-domain pitch detection, but it is computationally intensive. The ACF complexity is O(NM), where N is the number of samples and M is the maximum lag. We employ various optimizations to significantly speed up processing time.
Red: First-cycle pitch detection. Employs feature-guided methods to capture pitch information from the initial cycle of the signal. Autocorrelation requires two cycles to determine pitch. This auxiliary processor is designed to capture the first cycle before autocorrelation registers a pitch.
There’s more technical info on the blogs (part 1, part 2, part 3)
A tid-bit from the 2nd blog here with some technical info:
Individually, the components of the period detector aren’t groundbreaking. Zero-crossing detectors have been used to estimate the period of simple signals for quite some time. The comb filter used for autocorrelation is similar to those found in pitch detection algorithms like YIN and AMDF (average magnitude difference function), although it is presented differently using the difference function instead of the comb filter.
The key innovation of the Hz period detector is how it leverages zero-crossings to optimize the search for a matching period, while structuring the process to operate seamlessly in a real-time, event-driven, per-sample approach. Normally, autocorrelation, and variants have a complexity of O(NM), where N is the number of samples and M is the maximum lag (period in samples). By leveraging these zero-crossing hints, the detector reduces the need for an exhaustive linear search, enabling faster and more efficient detection.
The Hz period detector is optimized for low-latency, real-time pitch detection. On a 2022 M2 MacBook Air, CPU usage is measured in the nanoseconds per sample range. With an STM32H7 MCU running at 550MHz, I achieve a detection time of 690µs across six channels simultaneously, while handling interrupts at 32,000 samples per second. This includes signal conditioning such as envelope following, audio compression, gating, band-pass filtering, dynamic noise filtering, and onset and pitch detection.