2

I'm creating a scale visualiser (JavaScript based website) for guitar. I recently updated so it will use "correct" enharmonics e.g. major scales it will default to "Bb" tonic rather than "A#" because there's less accidentals.

But currently it's the same rules for all scales and modes, including harmonic major and harmonic & melodic minor scales and modes... It just calculates the least number of accidentals and ensures there's only one letter for each note.

So question is for example: (excuse my terminology) if A# major scale is "Db", should something like the "altered dominant bb7" scale (7th mode of harmonic minor) also be built in Db? Because if so, technically it then would have more flats that sharps (compared to if I built it from A#)

Because this is a project where i want to do all this programmatically (i.e. there's no fun in me just doing it based on a big table of information) then I'm looking for the "best option that makes logical sense that I can easily code".

My best guess is "check if the third is major or minor, then base it off the same enharmonic as the major or minor key"?

[Edit:] So based on responses I've hopefully settled on a design that satisfies the majority of users, and doesn't completely devastate the music theory experts (oh which I am in awe of, and thanks everyone for your detailed answers and comments).

I think key thing I've learnt (excuse the pun) is both enharmonic options are just as valid in different contexts, i.e. there's no set rule to automatically select one over the other. And obviously 7 note scales should have one of each letter. There seems conjecture over the rule "minimum symbols", but I think for users of my tool, that option will be nice. By extension, if there's no "default" option, then comparing to "default for Major scale" may be non-sensical... but Im keeping that option for now.

For seven note scales I have three options for enharmonics in top dasboard (you'll need to be on a wide enough device to see the buttons):

  1. Manual: you can now drop the note to the left or right side of the same "spot" to set the enharmonic (i.e. just after previous fret = A#, just before next fret = Bb). So "manual" mode just displays scales built from that "drop note"

  2. Auto: this uses whatever has the fewer amount of symbols regardless of where you dropped the note (but that information is retained if you want to switch back to manual mode). The tool doesn't work very well with more than one sharp or flat especially (i.e. not much space on a dot): so this is probably going to be the most comman use

  3. Parallel Major: this uses the same enharmonic that the parallel Major does (assuming that's also based on minimum symbols)

5
  • A# major scale is "Db" You mean "Bb", not "Db", right? Jun 8, 2023 at 17:29
  • You need to explain more about what the input/output is. Surely you are not going to map a whole bunch of scales all overlapping on a fretboard image. Does the user choose a string/fret starting point then scale type, or choose a lettered pitch then scale type, or something else? There is no right choosing of A# over Bb. Your program should be able to spell the scale with either tonic. How is the enharmonic choise first encountered in your program? Jun 8, 2023 at 19:46
  • Also, I think you should distinguish between "exotic" scales and modes/rotations of major & minor scales, because making the modes/rotations is just a mechanical process applied to the major/minor scales. Exotic scale are more like whole tone, or diminished with less/more than 7 tones, or non-diatonic ones like double harmonic, basically scales that aren't major, minor, or a mode of either. Jun 8, 2023 at 19:52
  • Yeah I meant Bb... You can see what I mean at sidawg.github.io/Vuetar/. They drop a scale on a fret, so they don't really choose the enharmonic. It's up to to the user how complicated they want to go, if they want to visualise more than one scale at a time. I get how to decide the names on a single scale, the question is if other scales should base their names on the major scale or if they should just follow the same rule of "minimum accidentals". It's the four seven note scales and their seven modes that I'm wondering about.
    – Simon
    Jun 8, 2023 at 23:03
  • That comment doesn't really add anything
    – Simon
    Jun 12, 2023 at 4:53

4 Answers 4

3

Naming notes in seven-note scales is fairly mechanical and straight-forward. You take the letter of the scale degree, and adjust it with sharps or flats to reach the pitch you want.

In other words: for each scale degree, you (1) take the accidental-less natural letter name like C, D or E, (2) calculate the pitch of your target scale degree in semitones, (3) compare the target pitch with the corresponding natural note with the same letter, and (4) add as many sharps or flats as are needed to reach the target pitch. If the pitch difference is -1 semitones, you add one flat. If the pitch difference is +2 semitones, you add two sharps. If the pitch difference is 0, you add nothing.

FOR EACH i in [0..6]
    letter(i) = note_names(scale_root_note + i)
    accidentals(i) = pitch difference between scale note (i) 
            and natural note (scale_root_note + i)

Then actual Python code for that idea. Should work with Python 3.x and even 2.7. There can be bugs. I checked the example scales below and they seem to be correct.

note_names = ['C','D','E','F','G','A','B']
# scale pitches are in semitones relative to root = 0
scales = {'major': [0, 2, 4, 5, 7, 9, 11],
          'melodic minor': [0, 2, 3, 5, 7, 9, 11],
          'harmonic minor': [0, 2, 3, 5, 7, 8, 11]}

def get_mode(base_scale_pitches, mode_idx):
    pitches = []
    for i in range(7):
        pitches.append(base_scale_pitches[(mode_idx+i)%7] - base_scale_pitches[mode_idx] + ((mode_idx+i)//7)*12)
    return pitches

def get_note_name(natural_note_idx, accidentals):
        natural_name = note_names[natural_note_idx % 7]
        if accidentals > 0:
            return natural_name + '#'*(accidentals)
        else:
            return natural_name + 'b'*(-accidentals)

def get_scale_notes(root_idx, root_accidentals, scale_pitches):
    result = []
    root_pitch = scales['major'][root_idx] + root_accidentals
    for i in range (7):
        natural_pitch = scales['major'][(root_idx + i) % 7] + ((root_idx + i) // 7) * 12
        scale_pitch = root_pitch + scale_pitches[i]
        result.append(get_note_name(
            root_idx + i,
            accidentals = scale_pitch - natural_pitch # how many flats or sharps are needed
        ))
    return result

Then some examples, how to generate scales as modes of other scales and print note names for them:

scales['dorian'] = get_mode(scales['major'], 1)
scales['natural minor'] = get_mode(scales['major'], 5)
scales['aeolian'] = scales['natural minor']
scales['altered'] = get_mode(scales['melodic minor'], 6)
scales['lydian'] = get_mode(scales['major'], 3)

def print_scale(root_idx, root_accidentals, scale_name):
     print(get_note_name(root_idx, root_accidentals), scale_name,
           get_scale_notes(root_idx, root_accidentals, scales[scale_name]))

# Print some example scales
print_scale(0, 0, 'natural minor')
print_scale(0, 0, 'harmonic minor')
print_scale(2, 1, 'altered')
print_scale(3, -1, 'altered')
print_scale(0, 0, 'dorian')
print_scale(3, -1, 'lydian')
print_scale(2, 0, 'lydian')
print_scale(5, 0, 'aeolian')

Running the examples prints the following:

C natural minor ['C', 'D', 'Eb', 'F', 'G', 'Ab', 'Bb']
C harmonic minor ['C', 'D', 'Eb', 'F', 'G', 'Ab', 'B']
E# altered ['E#', 'F#', 'G#', 'A', 'B', 'C#', 'D#']
Fb altered ['Fb', 'Gbb', 'Abb', 'Bbbb', 'Cbb', 'Dbb', 'Ebb']
C dorian ['C', 'D', 'Eb', 'F', 'G', 'A', 'Bb']
Fb lydian ['Fb', 'Gb', 'Ab', 'Bb', 'Cb', 'Db', 'Eb']
E lydian ['E', 'F#', 'G#', 'A#', 'B', 'C#', 'D#']
A aeolian ['A', 'B', 'C', 'D', 'E', 'F', 'G']

In this process, I do not see any need for the concepts of key or key signature. Or any such thing as a "rule of minimal accidentals". You take the letter of the scale degree, and adjust it with sharps or flats to reach the pitch you want.

2

I've also created a javascript project, but mine only works for visualising major modes. The most important thing about a major scale is its sequence of intervals. When you represent these on a pie chart you can see it has a very distinctive shape.

Scale Construction Webpage

ScaleConstructionJS project in Github

The rule of thumb I tried to stick to is to try to minimise the number of accidentals in the key signature. Given that the {number of flats} in a key signature is 12-{number of sharps} you can do an enharmonic shift at the right moment.

Key signatures with 8 to 12 sharps or 8 to 12 flats can be written, but they're more of a technical exercise - you wouldn't use such key signatures in actual written music.

You might need to use double sharps or double flats to make your scales technically correct - otherwise you might end up with scales that have say two fifths, rather than a fifth and a sixth.

6
  • 1
    Cool I'll check it out! I'm at sidawg.github.io/Vuetar/
    – Simon
    Jun 8, 2023 at 22:44
  • Sharps and flats in the key signature are not accidentals. Jun 9, 2023 at 2:03
  • 1
    @AriBrodsky - You're absolutely right - what should I have said? Jun 9, 2023 at 8:25
  • @Simon Vuetar is an astonishing piece of work. Good job! Jun 9, 2023 at 12:08
  • Ah OK thanks Ari I should just call them "symbols" i guess
    – Simon
    Jun 12, 2023 at 4:31
1

7th mode of harmonic minor

I'm afraid there is no simple catch-all solution for this kind of scales. This is because depending on the context, various steps of the scale could be interpreted in many ways.

If you start with C harmonic minor: C D Eb F G Ab B, and rotate it by one step, you get: B C D Eb F G Ab. It's not terrible.

But, does it make sense? E.g. the D is often interpreted as #9, and Eb as 3, then these two notes should be Cx and D#. Then F could be either #4 or b5, and G could be either #5 or b13. Finally, would Ab be really perceived as bb7, or rather as 6?

In practice I see corners being cut in the scores, e.g people write scales with both b3 and 3, or make other choices to minimize the number of accidentals, sacrificing theoretical correctness.

In this SE site you'll find heated discussions about correct spelling. There might be no way for you to please everyone. For the "exotic" scales you may add some commentary about possible different spellings of a scale.

1
  • Thanks yeah for the degrees, if it's a seven note scale I just compare to major to determine if something is a b3, or bb7 etc... And pentatonic I do the same but with "special' indexing. If there's no "correcter" way for the names/spellings I could always have a toggle setting...
    – Simon
    Jun 8, 2023 at 22:51
1

...So question is for example: (excuse my terminology) if A# major scale is "[B]b"

A# major is not Bb major. They are enharmonically equal, but not the same.

If you really want to do this programmatically, you shouldn't even force the issue of choosing one enharmonic spelling over another. Your program should be able to spell either A# major or Bb major.

... (7th mode of harmonic minor) also be built in [B]b ... (compared to if I built it from A#)

Build it on whatever tonic is given. The question is the method to use. I see basically two ways to do it: rotate a harmonic minor scale or by interval above the tonic. I suppose you could do it something like an alteration of a natural minor scale with lowered ^2, ^4, ^5, ^7, but I don't see an advantage to that. Personally, I like the interval method, and years ago a programmed a scale and chord speller in PHP.

The intervals for 7th mode of harmonic minor are:

  • ^1 - P1 unison
  • ^2 - m2 minor second
  • ^3 - m3 minor third
  • ^4 - d4 diminished fourth
  • ^5 - d5 diminished fifth
  • ^6 - m6 minor sixth
  • ^7 - d7 diminished seventh

So, starting from A# it's...

  • A# P1 - A#
  • A# m2 - B
  • A# m3 - C#
  • A# d4 - D
  • A# d5 - E
  • A# m6 - F#
  • A# d7 - G

The interesting thing with that is when working with the seventh mode of harmonic minor the "tonic" of that scale is the leading tone of the harmonic minor scale rotated. So, you could ask yourself before making the scale: "of what minor tonic is A# the leading tone?" The answer is: "B". So, we are rotating a B harmonic minor scale, which turns out to be not really that strange, in terms of enharmonic spellings.

If we start from Bb it's...

  • Bb P1 - Bb
  • Bb m2 - Cb
  • Bb m3 - Db
  • Bb d4 - Ebb
  • Bb d5 - Fb
  • Bb m6 - Gb
  • Bb d7 - Abb

Looking at the leading tone aspect again, we ask: "of what minor tonic is Bb the leading tone?" The answer is: "Cb". So our reference scale would be Cb harmonic minor. That should immediately signal things will probably get a bit messy with double flats and the potential to enharmonically respell things more simply.

I really don't understand the actual problem.

There is no rule of "minimum accidentals". The choice between enharmonically equal tonics or roots is usually related to some key signature or harmonic context, for example going up from F# major to C# major - up a perfect fifth - rather than moving to Db major - up a diminished sixth.

I looked at your example on sidawg.github.io/Vuetar/.

It seems like you already decided on a least sharps/flats decision. So, a user can't label a C# major scale and is forced to have only Db major, etc.

I understand your reason for doing that, but I think it is bad music fundamentals. Avoiding a theoretical key signature is one thing, but completely removing a basic key signature really cannot be justified.

Also, there is something inconsistent with the current application logic if it is supposed to end up with fewest sharps/flats. I tried putting the locian scale with starting pitch on the sixth string, sixth fret, and the it was named Bb rather than A#. Bb ends up spelling the scale with seven flats as compared to A# which would only need five sharps.

Instead of dragging the scale to a string/fret, you can have them select a lettered pitch, then you just map the correctly spelled scale pitches to the fretboard.

If you stick with the drag and drop thing, you might add some kind of enharmonic shift control. The simplest thing would probably be something to "flip" any non-natural starting pitch, for example flip Bb to A#.

Given the interface is so slanted to the fretboard, you could do something like label the fretboard with scale degree numbers 123... by default, then generate a set of buttons for various enharmonic spelling options for the user to choose from. Match the fretboard labeling to input type. Numeric in, numeric out. Letter pitch in, letter pitches out. The actual problem is giving the user a numeric input (fret/string numbers) and then guessing what they meant by that in terms of lettered pitches.

It's hard to recommend anything more specific without knowing how the program works.

1
  • Thanks yeah I have to find the right design balance: can always add more features but my users are probably not theory experts: they wouldn't have a need for the tool. At the same time I don't want to have horrible mistakes that teach beginners wrong information. If you're using phone you'll notice some settings when you rotate to landscape, i.e. you can change labels to degrees. But thanks maybe a way to toggle enharmonic is needed and I stick with the "minimum accidentals" default
    – Simon
    Jun 9, 2023 at 23:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.