TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Detecting pitch with the Web Audio API and autocorrelation

52 pointsby otrasabout 3 years ago

5 comments

fxtentacleabout 3 years ago
As someone who has worked in pitch recognition for a piano app, I&#x27;m doubtful that autocorrelation can work. Typically, the energy in overtones is much larger than the energy in the base pitch, which is also why phantom bass works so well in EDM.<p>Also, the plucking sound when the hammer hits the string is much closer to pink noise than to its actual pitch. I&#x27;d expect an autocorrelation to have plenty of false positives there.<p>FFT with remapping between bins works well. The remapping can accumulate the energy of overtones into the frequency bins of possible base pitches, thereby resolving the ambiguity.
评论 #30764753 未加载
kotxigabout 3 years ago
You can compute an autocorrelation with FFT&#x27;s by applying the convolution theorem which IIRC the audio api can do the FFTs for you. I also found the the YIN estimator is a lot better as a time domain estimator <a href="http:&#x2F;&#x2F;audition.ens.fr&#x2F;adc&#x2F;pdf&#x2F;2002_JASA_YIN.pdf" rel="nofollow">http:&#x2F;&#x2F;audition.ens.fr&#x2F;adc&#x2F;pdf&#x2F;2002_JASA_YIN.pdf</a> and some years ago I worked out how to compute that estimator with FFTs also.
评论 #30763847 未加载
dspigabout 3 years ago
&gt; One way to get around this would be to decrease bucket size by increasing the FFT size.<p>A better way is parabolic interpolation, which is in the source code but not mentioned in the article - and that works for finding the fractional position of peaks in the FFT or in the autocorrelation.<p>An even better way is by comparing the phase of the peak in two successive FFTs: If the signal phase has changed by X degrees after T seconds, what&#x27;s the nearest frequency to the bin centre that can be true for? (this is the main thing a &quot;phase vocoder&quot; does)
PianoGymabout 3 years ago
This is fantastic! I&#x27;ve been looking for a way to do this myself on my website <a href="https:&#x2F;&#x2F;pianogym.com" rel="nofollow">https:&#x2F;&#x2F;pianogym.com</a>!<p>Right now we rely heavily on MIDI input from the Web Audio API and it&#x27;s been my dream to make it so any instrument can use the website!<p>You are so cool! Thank you for sharing this!
dr_dshivabout 3 years ago
How do you measure how dissonant a piece of music is, either at a given time or as a whole?<p><i>No one knows!</i><p>Assumptions:<p>1. Real music. I.e., should demonstrate that a punk song is more dissonant than a recording of Vivaldi.<p>2. Dissonance defined based on published literature.