Sitemap
Arushi Shetty

Arushi Shetty

Real-Time Musical Note Detection with DSP

5 min readOct 25, 2026

--

Can a small DSP board listen to a note and tell you what it is, as it happens? We built one that does, on a TI TMS320C6748 board, using a 1024-point FFT and a bit of careful math. A guitar tuner, a pitch trainer and a transcription app all answer the same question: what note is this, and how far off is it? Doing that offline on a recording is easy. Doing it continuously, frame after frame, on an embedded processor is where the signal processing choices start to matter. This post walks through how our system works, why each step is there, and where it falls short. Our project, from the DSP lab at Sardar Patel Institute of Technology, Mumbai, is a realtime note and fundamental-frequency detector running on the C6748 LCDK. It takes live audio, finds the dominant frequency, and reports the note name, octave, MIDI number and tuning error in cents.

From sound to a note name

A musical note is, physically, a frequency. Western music uses the equal-tempered scale, where each octave doubles the frequency and is split into 12 equal semitones. With A4 fixed at 440 Hz, any frequency maps to a note through the MIDI relation:

m = 69 + 12 log₂(f / 440)

Round m to the nearest integer and you have the MIDI note number.

The remainder tells you how out of tune the sound is, measured in cents (1/100 of a semitone):

cents = 1200 log₂(f / fₙ)

Here f is the measured frequency and fₙ is the ideal frequency of the nearest note. A positive value means sharp, a negative value means flat.

The missing piece is f itself. The Fast Fourier Transform converts a block of time-domain samples into a spectrum, so the strongest peak in that spectrum is a natural estimate of the pitch. The catch is resolution: with a sampling rate Fs and a frame of N samples, FFT bins are spaced Fs/N apart. At 48 kHz and N = 1024 that is 46.875 Hz, which is coarse next to the gap between low notes. The method below spends most of its effort working around that limit.

How the detector works

The board’s AIC3106 codec samples audio at 48 kHz. An interrupt routine reads each left channel sample, passes it to the output, and drops it into a 1024-sample buffer. When the buffer fills, it raises a flag and the main loop takes over. Each frame then goes through six steps:

  1. Level check. Compute the frame’s RMS value. If it is below a threshold of 300, the frame is treated as silence and skipped, so background hiss never produces a bogus note.
  2. DC removal. Subtract the frame’s mean from every sample. A DC offset would otherwise show up as a large spike at 0 Hz.
  3. Hann window. Multiply the frame by a Hann window. A frame is a hard cut of a longer signal, and that cut smears energy across neighboring bins (spectral leakage). The window tapers the edges to reduce it.
  4. 1024-point FFT. A software radix-2 Cooley–Tukey FFT: bit-reversal reordering, then ten butterfly stages.
  5. Peak search. Scan the positive-frequency bins between 30 Hz and 5000 Hz and pick the one with the largest magnitude-squared value.
  6. Parabolic interpolation. Fit a parabola through the peak bin and its two neighbors, and take the vertex as the true peak. This gives a fractional-bin estimate, converted to hertz using Fs and N.

The last stage maps the refined frequency to a MIDI number, a note name from the 12 chromatic names, an octave, the ideal note frequency and the deviation in cents, using the equations above.

Why interpolation matters

A 46.875 Hz bin spacing is wider than a semitone below roughly 800 Hz, so picking the largest bin alone would often land on the wrong note. Parabolic interpolation uses the relative heights of the neighboring bins to place the peak between bins. It does not change the underlying resolution, and it works best for clean, stable tones, but it is what makes the cents readout meaningful.

Running it on the board

The program stores its output in global variables that we watch live in the Code Composer Studio (CCS) Expressions window. In one capture, the detector reported 375.00 Hz and identified it as F♯4, 23.3 cents sharp.

Press enter or click to view image in full size
Variables used, with their values and meaning

The numbers are self-consistent: 1200 × log₂(375.003 / 369.994) ≈ 23.3 cents, and MIDI 66 is F♯4 in the equal-tempered scale. The tone sat closer to F♯4 than to G4, so it was labelled F♯ with a sharp error rather than a different note.

Get Arushi Shetty’s stories in your inbox

Join Medium for free to get updates from this writer.

The system is designed for clear single tones. It reports the strongest spectral component in the 30–5000 Hz range, so the reading depends on input level and on the signal staying stable for the length of a frame (1024 samples is about 21 ms at 48 kHz).

Limits, and where it could go

A peak-picking FFT detector is simple and fast, and it has known weak spots:

  • Coarse bins. Resolution stays at 46.875 Hz. Interpolation helps, but low notes remain the hardest to read accurately.
  • Strongest is not always fundamental. For instruments whose harmonics are louder than the fundamental, the peak can sit on an overtone and read an octave or more too high.
  • One note at a time. Chords and overlapping voices produce several peaks, and the detector reports only the largest.
  • Stability. Notes that glide or decay within a 21 ms frame spread their energy and weaken the peak.

There are clear next steps: a longer frame or zero-padding for finer bins, a harmonic-product-spectrum or autocorrelation stage to find the true fundamental, averaging across frames for steadier readings, and an on-board display instead of the CCS watch window.

Even as it stands, the same pipeline suits digital tuners, pitch trainers and basic audio analysis, the applications this project was built around.

Takeaways

A handful of classic DSP steps, an RMS gate, DC removal, a Hann window, an FFT and parabolic interpolation, is enough to turn raw audio into a note name and a tuning error in real time on a C6748. The design shows how each step earns its place, and how much of pitch detection is about managing the limits of a short frame.

Built by Ananya Nigam, Arushi Shetty and Maulya Shetty at Sardar Patel Institute of Technology, Mumbai, under the guidance of Shubham Mundada, Prof. Reena Sonkusare and Dr. Kiran TALELE.

--

--