Key detection

How to find the key of a MIDI file

A MIDI file does not always carry a key signature, and even when it does, the notes may tell a different story. This guide explains how to estimate the key from the notes, how much to trust the result, and when to transpose.

A piano roll with highlighted notes and a key confidence chart
The estimate weights note duration and velocity, then compares the result with every major and minor key.
Editing5 min readEditMIDI Product Team

What matters most

  • A key estimate is statistical evidence, not a score annotation.
  • Short loops and sparse melodies can fit several keys.
  • The relative key and Camelot code help when matching harmonic material.
  • Transpose only after checking the target key and the drum channel.

Why the key matters

The key tells you which notes are likely to feel stable, which chords are likely to resolve, and which transposition will suit a singer or an instrument. It is also a practical check when a generated MIDI file was supposed to be in a certain key but sounds slightly wrong.

A key is not the same as a scale, and a song can visit several keys. The estimate describes the weighted center of the file. That is useful for choosing a transposition, but it does not replace listening to the actual sections.

How the key finder reaches an answer

The tool builds twelve pitch-class weights from the file. Each note contributes its duration and a velocity factor, so long or loud notes carry more evidence than short grace notes. Drum channel 10 is excluded because those notes are mappings, not pitches.

The twelve weights are compared with established major and minor profiles for every possible tonic. The highest correlation becomes the best estimate. The next three candidates are shown so you can see how crowded the result is.

Read the confidence, not just the label

A high confidence means the best key is clearly separated from the next candidate. A low confidence means several keys fit the notes almost equally well. That often happens with a short loop, a single chord, or a melody that avoids the third and sixth.

If the confidence is low, loop a longer section that contains the harmonic movement. If the song changes key, analyze the section you actually want to transpose rather than the whole file. The tool reports what the notes support, not what the title claims.

Use the relative key and Camelot code

Every major key has a relative minor with the same notes, and every minor key has a relative major. The tool reports that relationship so you can move between the two without changing the scale collection. This is useful when a song feels major in the chorus and minor in the verse.

The Camelot code is a DJ-friendly way to describe harmonic compatibility. Tracks with the same code or neighboring codes tend to mix more smoothly. It is a convenience, not a rule; a transition can work for reasons that have nothing to do with the wheel.

Transpose with the right target

Once you know the current key, decide the target key before opening the transpose tool. Moving up or down by semitones changes the pitch of every pitched note. Drum channel 10 stays unchanged by default because transposing a kick or snare usually changes the kit mapping rather than the musical key.

Large transpositions can push notes outside the MIDI range. EditMIDI clamps them to 0–127, so check very low bass parts and very high leads after a big interval. A smaller transposition is usually safer for a mix that already uses the full range.

When to trust your ear instead

Modal music, atonal passages, heavy chromaticism, and files with wrong notes can produce a plausible but musically wrong estimate. The pitch-class chart shows the evidence, but it cannot understand the style. If the result contradicts a clear tonal center you can hear, trust the ear and investigate.

The key finder is most useful as a second opinion. Use it to confirm a suspicion, choose between two close keys, or catch a transposition mistake. It is not a reason to ignore the actual harmony of the song.

How to verify a key by ear

Play the tonic chord and then the melody. Does the phrase feel resolved when it lands on that root, or does it want to move elsewhere? Try the relative major or minor. A song can share the same notes with its relative key while feeling centered on a different tonic.

Listen for the bass and the final chord. The bass often points to the tonic even when the melody is ambiguous. If the ending sounds unfinished, the file may be in a mode, may modulate, or may simply stop before the resolution. Use the key estimate as a map, not a verdict.

A note on modes and modulation

A mode such as Dorian or Mixolydian shares notes with a major or minor scale but centers on a different tonic. The key finder may report the closest major or minor profile because those are the profiles it compares. If the music sounds modal, treat the label as a starting point and check the tonal center by ear.

Modulation is another reason a single key label can feel incomplete. A song that moves from one key to another may produce a global estimate that fits neither section perfectly. Analyze the section you need, transpose that section, and leave the rest of the arrangement in its original key.

  • Modes can share notes with a relative major or minor key.
  • A global estimate may not fit a song that modulates.
  • Analyze the section you actually need to transpose.

Questions and answers

Does MIDI store the song key?

A MIDI file can contain key-signature meta events, but not every exporter writes them and not every file follows them. The notes themselves are the more reliable evidence, which is why a key finder analyzes the pitches.

Why does the key finder disagree with my DAW?

A DAW may be reading a key-signature event or a project setting, while the finder is analyzing the actual notes. Both can be useful. If they disagree, check whether the file modulates or contains wrong notes.

Can I find the key of a drum-only MIDI?

No reliable key can be inferred from drum mappings. EditMIDI excludes channel 10 and reports that there are no pitched notes to analyze rather than inventing a result.

Does transposing change the tempo?

No. Transpose changes note pitches. Tempo events and note timing stay in place. If the file also needs a tempo change, use the separate tempo tool.