# Pitch Correction Under the Hood: Pitch Detection, Shifting and Why Auto-Tune Sounds the Way It Does

> Source: <https://dev.to/taniaalwan/pitch-correction-under-the-hood-pitch-detection-shifting-and-why-auto-tune-sounds-the-way-it-does-2dji>
> Published: 2026-11-04 18:47:27+00:00

*By Tania Alwan*

Pitch correction is everywhere in modern music, from subtle tuning on ballads to the hard, robotic effect in pop and rap. Under the hood it's a neat chain of signal processing: detect the pitch, decide the target, shift the audio, and do it without making the voice sound like a chipmunk.

This post walks through each stage with small Python examples, explains where artefacts come from, and covers how pitch correction fits into AI vocal workflows.

## 
  
  
  The pipeline in four stages

Almost every pitch corrector, hardware or software, follows the same steps:

1. 
**Pitch detection:** estimate the fundamental frequency (f0) of the voice over time.
2. 
**Target selection:** map each detected pitch to the nearest allowed note in a scale.
3. 
**Correction curve:** decide how fast and how strongly to move toward the target.
4. 
**Pitch shifting:** resynthesise the audio at the new pitch while preserving timing and, ideally, timbre.

## 
  
  
  Stage 1: detecting pitch

Monophonic pitch detection is a well-studied problem. Common algorithms include:

- 
**Autocorrelation:** find the lag at which the signal best matches a shifted copy of itself.
- 
**YIN and pYIN:** refinements of autocorrelation that reduce octave errors; pYIN adds a probabilistic model to track pitch over time.
- 
**Neural pitch trackers:** models like CREPE, trained on audio to predict f0 directly.

With librosa, pYIN is one call:

`f0` is an array of frequencies in Hz (NaN where unvoiced). **Clean input matters:** reverb, noise and backing-track bleed all confuse detectors, causing octave jumps or flicker.

## 
  
  
  Stage 2: snapping to a scale

Converting frequency to MIDI note numbers makes the maths easy:

Real products add a lot on top: key detection, note-level segmentation, and handling notes that sit exactly between two targets.

## 
  
  
  Stage 3: the correction curve (the "Auto-Tune effect")

The famous robotic sound isn't caused by pitch shifting itself. It comes from **correction speed**.

- 
**Slow correction:** pitch glides gently toward the target, preserving vibrato and scoops. This is transparent tuning.
- 
**Instant correction:** pitch jumps immediately to the target note. Natural transitions between notes become hard steps, and vibrato disappears. That's the "hard-tune" effect.

A simple smoothing model:

Most plugins expose this as a "retune speed" or "humanize" control.

## 
  
  
  Stage 4: shifting the pitch

Once you know how many semitones to move each frame, you need to shift the audio. Options:

- 
**Resampling:** simplest, but it changes duration and timbre together (the chipmunk effect).
- 
**Phase vocoder:** works on the STFT; changes pitch independently of time, but can sound smeared.
- 
**PSOLA (pitch-synchronous overlap-add):** cuts the signal into pitch periods and re-spaces them. Very good for monophonic voice, the basis of many classic correctors.
- 
**Formant-preserving shifting:** keeps the vocal tract resonances in place so large shifts don't change the perceived "size" of the singer.

For a quick global shift, librosa is enough:

Time-varying correction (different shift per frame) needs a PSOLA or vocoder implementation, such as those in Praat via the parselmouth package or the WORLD vocoder via pyworld.

## 
  
  
  Where the artefacts come from

- 
**Octave errors** in detection cause sudden, wrong jumps.
- 
**Unvoiced sounds** like "s" and "t" have no pitch; correcting them produces glitches if not gated.
- 
**Breathy or noisy takes** reduce detection confidence.
- 
**Large shifts without formant preservation** change the character of the voice.

## 
  
  
  Pitch correction in AI vocal pipelines

Pitch matters in AI voice work too. In voice conversion pipelines such as RVC, a pitch track is extracted from the source vocal and passed to the model, and a transpose setting shifts it, for example when converting a male vocal for a higher target voice. Errors in that pitch track show up directly in the output.

That's why a typical cover workflow looks like:

1. 
**Separate the vocal** from the mix (e.g. Demucs, or a hosted stems tool).
2. 
**Clean it:** reduce reverb and noise so the pitch tracker isn't confused.
3. 
**Tune lightly** if the source is off-pitch.
4. 
**Convert** with the voice model.

Hosted tools bundle some of these steps. Voicestars, for example, has a [reverb remover](https://www.voicestars.co/ai-reverb-remover) and [noise remover](https://www.voicestars.co/ai-noise-remover) alongside its voice conversion, while open-source users can chain the same steps in Python. I covered the separation and conversion part in more depth in [Vocal Isolation and Voice Conversion](https://dev.to/taniaalwan/vocal-isolation-and-voice-conversion-how-ai-covers-actually-work-under-the-hood-9p2).

## 
  
  
  Practical settings for natural tuning

If you just want a vocal to sound in tune rather than robotic, these habits help:

- 
**Set the correct key first.** Most bad tuning comes from snapping to the wrong scale.
- 
**Use a slower retune speed** on sustained notes and ballads.
- 
**Leave vibrato alone** where possible; many tools have a separate vibrato or "flex" control.
- 
**Tune phrase by phrase** instead of applying one setting to the whole track.
- 
**Bypass often** and compare with the original to avoid over-processing.

## 
  
  
  Free tools to experiment with

- 
**Graillon (free edition)** and**MAutoPitch** are free pitch-correction plugins for DAWs.
- 
**librosa, parselmouth and pyworld** cover detection and shifting in Python.
- 
**Audacity** offers pitch changes for whole clips.

## 
  
  
  Try it

Record a short sung phrase, run pYIN on it, plot `f0` against the nearest semitones, and see how far off you really are. If you're preparing vocals for AI conversion, clean them first; you can do that locally or with the [Voicestars reverb remover](https://www.voicestars.co/ai-reverb-remover).

*Disclosure: this article was written in partnership with Voicestars.*
