A concrete starting point
C#4 = Db4 · F#4 = Gb4 · A#4 = Bb4 on an equal-tempered piano
Pitch class is not written position
The letter chooses a staff line or space; the accidental modifies that written pitch. C to F-sharp is an augmented fourth, while C to G-flat is a diminished fifth. Both span six semitones in twelve-tone equal temperament. A reverse chord finder may collapse these pitch classes, whereas a staff construction check can require the intended spelling.
Naturals and double accidentals
E-sharp shares a piano key with F natural; B-sharp shares one with C natural. F-flat and E natural are another pair. Double sharps and double flats move a written natural pitch by two semitones. Octave labels follow the letter: B#3 and C4 sound alike, not B#4 and C4. Spelling therefore cannot be recovered uniquely from a MIDI number alone.
Choose spelling from the musical structure
D major uses D E F# G A B C# so every letter occurs once. Replacing F-sharp with G-flat duplicates G and omits F, hiding the scale-degree structure. Start with a diatonic letter skeleton before adding accidentals. These equal-tempered equivalences do not claim that every historical tuning system or expressive performance treats the pitches identically.
Put it into practice
These examples describe explicit written notes and relationships. A diagram or generated phrase does not replace listening to a complete musical context, choosing a comfortable register or checking a physical technique with a teacher.