# Sharps vs Flats - Formula to determine correct sharp and flat notes in a scale

I am trying to figure out how to know if a note in a scale is a sharp or a flat.

So my starting point/input are the intervals of any scale. E.g. here are the Minor pentatonic intervals

``````Interval: 1, b3, 4, 5, b7
Semi-notes: 3 - 2 - 2 - 3 - 2
Formula: Whole and a half, Whole, Whole, Whole and a half, Whole
``````

Now i want to know how do i get the exact sharps and flats for the notes of this scale? For example my output would be the following for Fm in the Minor pentatonic scale:

F, Ab, Bb, C, Eb, F

I understand that if a key is written as a flat or sharp is based on the half step transition, but that doesn't seem consistent in all scales, and i also don't know how to determine if a half step transition is half step higher or lower (to determine flat vs #)

For example here is the F-Mixolydian scale:

F, G, A, Bb, C, D, Eb, F

Why is Bb not written as A#?

The intervals, semi-tones and formula of Mixolydian are:

``````Interval: 1, 2, 3, 4, 5, 6, b7
Semi-notes: 2 - 2 - 1 - 2 - 2 - 1 - 2
Formula: Whole, Whole, Half, Whole, Whole, Half, Whole
``````

So the A -> Bb is a Half step transition, but how do i know if it's half step lower (Bb) or half step higher (A#)?

In General is there a formula i can follow to get the correct notes in any scale with the correct sharps and flats?

I need the same formula to work for Major, Minor, Pentatonic, Mixolydian etc. so i can start from the intervals and get the correct notes.

• "I need the same formula to work for Major, Minor, Pentatonic, Mixolydian etc. so i can start from the intervals and get the correct notes." - Knowing which notes are sharp and flat is one way to get the correct notes; knowing the intervals is another, more direct, way. If you mean "get the correct note names - don't mind me, I'll shut up... – topo morto Mar 25 '15 at 21:53
• Mind if I ask why do you need this? I find this to be theory for the sake of theory only. Could you care to explain the practicality behind this way of thinking? – Chris Mar 27 '15 at 16:55
• Im deveoping music software, so i need an algorithm to get all the correct note names for any scale in any key without "hardcoding" every key and scale combination :) so e.g. if the user selects d-mixolydian on the UI i should be able to calculate the correct note names for this scale. I already have written an algorithm to get note names for a scale in any key, however i need to figure out how to correctly determine if a note is a sharp or a flat. – Faris Zacina Mar 28 '15 at 7:13
• @topo morto yes i meant the note names :) – Faris Zacina Mar 28 '15 at 7:14

What you are looking for are key signatures. A key signature determines which flats/sharps to use on a scale. The flats/sharps that appear, do so in a certain order, not random. So, if you see 1 flat, you have to play B♭, if you see 2 flats, you have to play B♭ and E♭ etc.

So, if you begin to read a sheet music and you see 2 flats, then you know you are in B♭ Major or G minor (the context determines which one). In this example, you have to play B♭ and E♭. This is the way to choose between A# and B♭ and D# and E♭.

The F mixolydian example you provided is the V from the B♭ major scale. So, the key signature would be the same as B♭'s, which is B♭ and E♭. Not A# and D#.

• For the major scale, see the key signature
• For the minor scale, see the key signature; however, there are 3 types of minor scales. For more info on them, read this thread: The differences between natural, harmonic and melodic minors
• The minor pentatonic is a simplified minor scale.
• The mixolydian is the fifth mode of the major scale. So, just descend a 5th or ascend a 4th and see what key signature a scale with that note as root has.
• Last para - descend a fifth is fine; ascend a fifth will take you to the wrong place. As in G Mixolydian : G down to C. Up a fifth takes it to D. – Tim Mar 26 '15 at 9:41
• I ended using the signatures as a basis, and then utilizing the "intervals" to determine if there are any notes modified from the original signature. Seems to work pretty well for all scales. – Faris Zacina Apr 1 '15 at 13:45
• Although there is some existing literature that has used the modal key signatures (e.g.: a key signature with no sharps/flats for D Dorian) it is much more common - even among jazz compositions - to publish the piece in the traditional major or minor key signature, then add accidentals within the body of the work (e.g.: a key signature with Bb for D Minor, then the B marked as natural wherever it occurs). This is the accepted practice in the current publishing world. – Everett Steed Apr 17 '16 at 7:50
• Coming a bit late with similar questioning. @Shevliaskovic so if I understand correctly defining a scale by its intervals instead of its (semi-)tone step is a non sense without knowing the key or context in which the scale is used, right? – renard Nov 26 '18 at 21:20

The key thing to remember is that for diatonic scales (major, minor and the modes) each note has a different letter name. In your example `F G A A C D E F` (ignoring the flats/sharps) has a duplicated letter; thus the 4th note must be a B.

One way to lay out a scale is to put the notes in order, e.g. `B C D E F G A`, and then figure out where the flats/sharps need to go in order to get the intervals correct, `B C# D# E F# G# A#` for a B major scale in this example, or B C# D E F# G A for a B minor. While if you start with `G A B C D E F` and know that the interval relationships for minor are `2-1-2-2-1-2-2` you get G A B♭ C D E♭ F for G minor.

• Good point about the duplicated notes. – Shevliaskovic Mar 25 '15 at 21:36

Every scale will have ONE of each letter name - for a full major or full minor. Starting with C major, with no # or b. The circle of fourths (or fifths, depending which way you go) will give a formula. Go up in fourths, and it will add one extra flat each time. thus - F - has Bb (the fourth note of itself). Up another fourth takes it to Bb - with 2 b, the second being its fourth note, Eb. Etc. etc.

Going the other way from C will give G, with 1 #, the leading note of F#. Go back another 5 finds D, with 2#, the second being leading note C#. Etc. etc.

The same formula will work for the relative minors, starting on the 6th note: Am to C major. The pents work the same. Modes will take the key signature of the 'parent' key, as in C Ionian with no # or b is the same as D Dorian, E Phrygian, F Lydian, G Mixolydian, A Aeolian, and B Locrian. The same order will work for each mode, given the parent key. As in D Mixolydian will have the same notes as G major - 1#.

To muddy the waters, both harmonic and melodic scales have notes which are altered from the natural minor, but a formula can be produced once the originals have been understood.

Although perhaps not the easiest version, but one which will give you the most theoretical background, is the Circle of Fifths; this is especially useful for determining the number of flats or sharps in a scale, or given a number of sharps or flats, determining in which key you are playing.

You start at C, which in major does not have any sharps or flats. Going clockwise on the circle of fifths, you add one sharp for each fifth you go up. So, G has one sharp (F#), D has 2 sharps (F# and C#), etc. Going counterclockwise, you add one flat for each fifth you go down. So, F has one flat (Bb), Bb has two flats (Bb and Eb), etc. When you reach F# or Gb respectively, you'll see that they are enharmonically equivalent, which is why we consider it a circle. For minor scales, this story can be done from a. (You can now see where double flats and double sharps come from: you take your original minor scale, but you raise the 7th by a semitone, which may already have a sharp there)

The trick now of course is to remember which flats and sharps there are, which for me personally, practicing scales has taught me well - I usually use the circle of fifths to see which key I'm playing in given a number of sharps and flats, instead of the other way round! A helpful trick of course is that, going round the Circle of Fifths, you'll only add sharps and flats; the ones you already have don't 'magically' go away.

Fun fact: even though C# major is just as well represented with Db major, Bach famously wrote a few pieces in C# major, so that you have a whopping 7 sharps instead of 5 flats.

Each note in a scale should have a different letter name. For example, the D major scale doesn't have the same letter twice: D E F# G A B C# D

If the scale had flats instead of sharps, G and D would be used twice and F and C would not be used at all: D E Gb G A B Db D

Double flats/sharps were mentioned above. They are sometimes necessary to make sure the same letter is not repeated. The E# (F) scale: E# F## G## A# B# C## D## E#

This would be incorrect: E# G A A# C D E E#

The notes that seem to have 2 different names are actually 2 different notes.

If you are only looking for note names then you should be fine - follow the advise of these commentators and you will automatically get the correct sharps or flats for your key signature. But if you are coding music to be played in precise harmony (for example on Supercollider) then you will be programming pitch frequencies... or formulating equations to create pitch frequencies... and this extra detail will become imperative.

To fully take advantage of this fact in creating a computer music environment, the programmer needs to learn some basic formulae of key signatures, modal theory, tuning systems, orchestra intonation, and studio recording practices.

The notes that seem to have two different names are called "enharmonic equivalents." Many people don't realize that these notes (e.g. the F# and the Gb) are different notes from the standpoint of any section of an orchestra/marching band/jazz band. We are accustomed to seeing them as "the same" on the piano keyboard and the guitar fretboard, but when the band is playing a harmony in tune, all instruments that can adjust their intonation (the violin family, the brass family, the wind family) play those 2 notes slightly differently.

The fudging of these pairs of individual notes into a compromise is a hallmark of the "equal temperament" tuning system. This compromise is done as a convenience for the keyboard family (piano, etc.) and the fretted instruments (guitar, etc.), NOT because the notes are exactly the same pitch frequency.