Enharmonic spelling
F-sharp and G-flat may sound the same on a modern keyboard while doing different jobs on a page.
Same key, different explanation
In twelve-tone equal temperament, F-sharp and G-flat share a piano key. Their written names still matter because notation shows direction and harmonic context. In a D-major scale, F-sharp is its third; G-flat would obscure the expected sequence of letter names. On instruments with flexible intonation, the exact tuning of a note can also depend on musical context.
Write the path of a line
Start with G, move down one semitone and back. Spell the lower note F-sharp if the line is functioning in a key that calls for it; try G-flat when it belongs to a flat-side harmony. Play both written versions on a keyboard, then compare how easy each is to read alongside its chord.
Avoid spelling by keyboard alone
A digital piano roll may label one key with a default sharp. That label is not always the best notation for a score. Use the spelling that makes scale degrees, chord thirds and voice motion legible, especially when you share parts with players who read music.
Related entries
Further reading
These source links provide technical background; the exercises above are Eidolon's own editorial guidance.