<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Caron</title>
    <description>The latest articles on DEV Community by Caron (@caron_446492a5d9c5adebd5f).</description>
    <link>https://dev.to/caron_446492a5d9c5adebd5f</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3926218%2F383a7867-ab48-4d88-a8ee-02b3b4139a57.png</url>
      <title>DEV Community: Caron</title>
      <link>https://dev.to/caron_446492a5d9c5adebd5f</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/caron_446492a5d9c5adebd5f"/>
    <language>en</language>
    <item>
      <title>Real-time pitch detection in the browser — how it works and a free tool to try it</title>
      <dc:creator>Caron</dc:creator>
      <pubDate>Tue, 12 May 2026 05:02:31 +0000</pubDate>
      <link>https://dev.to/caron_446492a5d9c5adebd5f/real-time-pitch-detection-in-the-browser-how-it-works-and-a-free-tool-to-try-it-3bph</link>
      <guid>https://dev.to/caron_446492a5d9c5adebd5f/real-time-pitch-detection-in-the-browser-how-it-works-and-a-free-tool-to-try-it-3bph</guid>
      <description>&lt;p&gt;Ever wondered how a tuner app knows what note you're playing? The underlying tech &lt;br&gt;
is surprisingly accessible in modern browsers — no native app, no plugins required.&lt;/p&gt;

&lt;h2&gt;
  
  
  How browser-based pitch detection works
&lt;/h2&gt;

&lt;p&gt;Modern browsers expose the &lt;strong&gt;Web Audio API&lt;/strong&gt;, which gives you access to the &lt;br&gt;
microphone via &lt;code&gt;getUserMedia()&lt;/code&gt;. Once you have an audio stream, you can run &lt;br&gt;
pitch detection algorithms on the raw frequency data.&lt;/p&gt;

&lt;p&gt;The most common approaches:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. FFT (Fast Fourier Transform)&lt;/strong&gt;&lt;br&gt;
The Web Audio API's &lt;code&gt;AnalyserNode&lt;/code&gt; can compute an FFT of the input signal, &lt;br&gt;
giving you a frequency spectrum. The dominant frequency peak is your pitch — &lt;br&gt;
but this can be noisy with real instruments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Autocorrelation&lt;/strong&gt;&lt;br&gt;
More robust for musical instruments. You compare the audio signal against &lt;br&gt;
a time-shifted version of itself. The lag at which they correlate best &lt;br&gt;
reveals the fundamental frequency.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. YIN algorithm&lt;/strong&gt;&lt;br&gt;
A refinement of autocorrelation that reduces octave errors. Popular in &lt;br&gt;
professional pitch detection tools.&lt;/p&gt;

&lt;h2&gt;
  
  
  From Hz to note name
&lt;/h2&gt;

&lt;p&gt;Once you have a frequency in Hz, mapping it to a note is just math:&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
`js
function freqToNote(freq) {
  const noteNum = 12 * (Math.log(freq / 440) / Math.log(2));
  return Math.round(noteNum) + 69; // MIDI note number
}

const noteNames = ['C','C#','D','D#','E','F','F#','G','G#','A','A#','B'];
function midiToName(midi) {
  return noteNames[midi % 12] + Math.floor(midi / 12 - 1);
}`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>algorithms</category>
      <category>api</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
