{
  "id": 30484,
  "title": "Building a Better Erhu Tuner: Why Auto correlation Beats Standard Pitch Detection in the Browser",
  "url": "https://urgent.news/2026/08/02/building-a-better-erhu-tuner-why-auto-correlation-beats-standard",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-08-02T05:23:34.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/amila_100255eb03f63860e2d/building-a-better-erhu-tuner-why-auto-correlation-beats-standard-pitch-detection-in-the-browser-44h2"
  },
  "original_language": "en",
  "account": "Creating a more accurate erhu tuner for web-based instruments presents challenges due to the unique nature of bowed strings. Traditional tuners using frequency-domain Fast Fourier Transform (FFT) fail to accurately detect pitches in such cases. This article explains why time-domain Autocorrelation proves more effective for erhu tuners, and how to implement it in a modern web environment. The inherent non-periodic nature of bow noise, combined with complex harmonics generated when the horsehair rosin contacts the steel string, confuses basic frequency detection techniques like zero-crossing algorithms and FFTs. As a result, these standard methods suffer from erratic readings and a high level of uncertainty. The Autocorrelation algorithm offers a solution by remaining within the time domain. It works by sliding a copy of the waveform over itself to compare the overlapping segments. At each shift, the algorithm calculates a correlation peak which indicates the repeating cycle length of the soundwave. By dividing the sample rate by the found lag, the fundamental frequency in Hertz can be accurately derived. The key benefits of this method for bowed instruments lie in its ability to filter out irrelevant noise from the scratchy bowing action and concentrate on the consistent periodicity of the string's fundamental frequency. Implementing this technique within a web browser requires offloading computations from the main UI thread to an AudioWorklet thread in modern browsers. By doing so, the processing remains real-time and isolated from other tasks like DOM manipulation, ensuring minimum lag. One potential pitfall of Autocorrelation is the \"Octave Error\" where it may mistakenly interpret the pitch as one octave lower than actual due to alignment with higher harmonics. To tackle this issue, heuristics like peak picking are employed—selecting only the most significant and stable correlation peak while filtering out false positives. In conclusion, switching from traditional FFT-based pitch detection to time-domain Autocorrelation can drastically improve the reliability and precision of an erhu tuner. Its robustness against bowing irregularities and non-periodic noise makes it an ideal choice for developers seeking accurate pitch detection for organic musical instruments in web environments.",
  "summary": "The article discusses the challenges of building a web-based instrument tuner for the Erhu, a traditional two-stringed Chinese bowed instrument. Unlike standard pitch detection methods, such as Fast Fourier Transform (FFT), which work reasonably well with synthesized tones or simple plucked strings, the Erhu's unique characteristics pose significant problems. The lack of fingerboard and frets, along with the bowing technique used to play the instrument, creates a complex frequency spectrum with high-frequency noise, transients, and strong harmonics. These factors make it difficult for FFT-based tuners to maintain sub-1Hz accuracy required for fretless instruments. The solution proposed in the article is to switch from FFT-based pitch detection to time-domain Autocorrelation algorithms. Autocorrelation operates in the time domain, analyzing the periodicity of the audio signal without converting it to the frequency domain. By sliding a time-shifted version of the waveform over itself and comparing overlapping data points, autocorrelation generates a correlation peak that indicates the length of one complete cycle of the soundwave. Dividing the audio's sample rate by this lag distance yields the period, allowing for precise pitch detection even in the presence of noise and complex harmonics.",
  "key_points": [
    "Autocorrelation algorithm outperforms FFT in detecting pitches for bowed strings.",
    "Time-domain method filters out irrelevant noise from bowing action.",
    "Implementing Autocorrelation in web browsers via AudioWorklet thread ensures real-time processing."
  ],
  "editors_take": null,
  "illustration": "https://urgent.news/ill/30484.png",
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}