Skip to content

Pitch Correction and Note Editing

Pitch correction nudges a note from its current pitch toward a target.

Note editing reshapes a chosen region, such as stretching one held note or tightening timing, without touching the rest of the clip.

Both are surgical, region-aware edits rather than whole-clip transforms. This page explains them through libsonare's PitchCorrector and NoteEditor; for the vocabulary, read Editing Basics.

You supply the current pitch

pitchCorrectToMidi does not guess what note you sang. You provide the current note.

The workflow is:

  1. Estimate the current pitch with pitchYin, pitchPyin, or your own detector.
  2. Convert or read that pitch as a MIDI note number.
  3. Pass the measured value as the current MIDI note.
  4. Pass the desired note as the target MIDI note.

MIDI note numbers are semitone indexes:

ExampleMeaning
69A4, 440 Hz
68.7Slightly below A4
60C4, middle C

Fractional values are normal because singers are rarely exactly on a note.

Correction strength and transparency

Correction is a pitch shift applied over a region, so the same artifact rules apply: small intervals stay transparent, large ones expose phase-vocoder smearing. For natural vocals, correct by small amounts toward the nearest scale tone rather than forcing a big jump. Hard, full-snap correction is a creative effect, not a transparent fix.

PARAM SWEEP · PITCH SHIFTIDLE
Pitch shift — moving the whole harmonic comb

Pitch shifting transposes a sound without changing its length. Drag the semitones and watch the spectrum: every harmonic scales together and the fundamental marker tracks the new pitch. Because this shift is not formant-preserving, the formant bumps move too — the "chipmunk" effect. Press play to hear it.

Pitch
0 st

Note regions: samples, not seconds

Region-based edits like noteStretch take sample offsets, not seconds, because sample positions are exact and never drift. Convert with samples = round(seconds × sampleRate) — at 48 kHz, 0.25 s is sample 12000. A region has an onset sample and an offset sample; stretchRatio > 1 lengthens that region while leaving the surrounding audio in place.

How libsonare corrects and edits

pitchCorrectToMidi maps a current→target MIDI interval to a pitch shift over the signal, reusing the phase-vocoder path from Time Stretch and Pitch Shift. Region edits use NoteEditor (NoteEditorConfig) over a NoteRegion defined by onset/offset sample offsets, with NoteSegmenter helping locate regions. noteStretch applies a region-bounded stretch ratio. All operate on decoded mono samples; the Audio wrapper exposes the same operations as instance methods so file workflows can load once and edit.

Related: Editing Basics, Time Stretch and Pitch Shift, Melody and Pitch, Editing DSP