midi key signature meta event calculator
MIDI Key Signature Meta Event Calculator guide
An editor may display E-flat major while the event list shows FD 00. These are two descriptions of the same key signature. Count the accidentals printed at the beginning of the staff, make flats negative, and choose major or minor. The result gives the complete file meta event except for the time that precedes it.
Play the instrument ↑- Default result
- FF 59 02 00 00
Calculation and units
The prefix FF 59 identifies a key signature. The following 02 is the number of payload bytes. The first payload byte is a signed count from minus seven to plus seven. Negative counts use eight-bit two’s complement, so minus one is FF and minus three is FD. The final byte is zero for major or one for minor.
Worked examples
Select a named case in the Worked example control to load these values. You can then edit any input to compare the result.
No accidentals
Signed accidentals (flats negative) = 0 · Mode = Major.
FF 59 02 00 00. C major · signed sharps/flats count 0. File event bytes exclude delta time.
A zero count combined with major mode spells C major. Finding two final zero bytes is expected, because the accidental count and major-mode flag are independently represented.
Relative minor
Signed accidentals (flats negative) = 0 · Mode = Minor.
FF 59 02 00 01. A minor · signed sharps/flats count 0. File event bytes exclude delta time.
With the count unchanged, changing only the final flag selects A minor. Both keys have an empty written signature even though they use different tonics.
Three flats
Signed accidentals (flats negative) = -3 · Mode = Major.
FF 59 02 FD 00. E♭ major · signed sharps/flats count -3. File event bytes exclude delta time.
The signed byte uses two’s complement, so the hex payload looks large when displayed as unsigned decimal. Interpret it as minus three to identify E-flat major.
Three flats in minor
Signed accidentals (flats negative) = -3 · Mode = Minor.
FF 59 02 FD 01. C minor · signed sharps/flats count -3. File event bytes exclude delta time.
C minor shares the same signed accidental byte with E-flat major. A leading-tone accidental in a melody does not alter the three flats specified at the beginning of the staff.
Seven sharps
Signed accidentals (flats negative) = 7 · Mode = Major.
FF 59 02 07 00. C♯ major · signed sharps/flats count 7. File event bytes exclude delta time.
The positive end of the standard written range spells C-sharp major. All seven diatonic letters carry sharps, while the signed count still fits in a single positive byte.
Seven flats
Signed accidentals (flats negative) = -7 · Mode = Minor.
FF 59 02 F9 01. A♭ minor · signed sharps/flats count -7. File event bytes exclude delta time.
The opposite end of the range gives A-flat minor here. Its bytes differ from a possible enharmonic spelling because the event preserves the written signature and the mode.
Interpreting the result
The same accidental count supports a pair of relative keys. For three flats, major gives E-flat and minor gives C minor. Changing mode changes just the last byte. By contrast, selecting an enharmonic spelling may change the accidental count, so a pitch-class comparison alone cannot recover the written signature.
Measurement and model limits
Read the event at its own position in the conductor track. A file can introduce a new signature after the first measure, and individual chromatic notes can differ from the displayed key. To repair a score display you may need to preserve the notes and edit only the appropriate timed signature. Editing the meta event does not transpose those notes.
Music theory tools → · Key Signature Calculator → · MIDI Association Standard MIDI Files specification →
Answers before you play
Common questions
Can I enter an accidental for every altered note?
Count the signature at the clef. Temporary accidentals inside a measure belong to the written pitches and do not automatically change this event. A sharp used in a minor melody does not by itself add a sharp to the signature.
What about modes such as Dorian?
The standard mode byte here distinguishes major and minor. A tool may use a related written signature for a modal piece, but this event alone cannot label its mode or distinguish the intended tonal center for a listener.
How do I encode F major?
F major has one flat. Enter minus one and major mode to obtain FF 59 02 FF 00. The second FF belongs to the signed payload.
Will moving this event move my notes?
A key signature can change how a score is spelled or displayed. Moving it affects where the notation applies. Note numbers and the events that trigger each sound remain separate.