Coloring Musical Scales

code
d3

January 02, 2021

After we found a basic way of coloring pitches, let's now look at a way to color scales.

Chroma Center

This is the C major scale in a chromatic circle, indexed from 0 to 11:

0C1Db2D3Eb4E5F6Gb7G8Ab9A10Bb11B

If we now add all indices of active notes inside modulo 12, we get:

(0 + 2 + 4 + 5 + 7 + 9 + 11) % 12 = 2

... which is the index of D. Interestingly, D is the only place we can put a mirroring axis that won't change the notes after reflection. Let's call this the chroma center. We can calculate it for any chroma like this:

export default function chromaCenter(chroma: string) {
  const digits = chroma.split('');
  const ones = digits.map((d, i) => (d === '1' ? i : -1)).filter((i) => i !== -1);
  return ones.reduce((sum, i) => i + sum, 0) % 12;
}

Here, we are summing all indices that contain "1" inside mod 12.

What is a chroma?

A chroma is a string with 12 characters that represent a set of pitches with a combination of 1s and 0s. A 1 means that the note is in the set, a zero means not. The 12 characters represent all chromatic notes going from C to B. For example, the chroma of C major is 101011010101:

101011010101 
C D EF G A B

Scale Colors

Now, we can use the chroma center for cyclical color interpolation:

import { interpolateSinebow } from 'd3-scale-chromatic';
import chromaCenter from './chromaCenter';

export default function chromaColor(chroma) {
  return interpolateSinebow(chromaCenter(chroma) / 12);
}

... and run it on all diatonic scales:

  • C majorD dorianE phrygianF lydianG mixolydianA aeolianB locrian
  • G majorA dorianB phrygianC lydianD mixolydianE aeolianF# locrian
  • D majorE dorianF# phrygianG lydianA mixolydianB aeolianC# locrian
  • A majorB dorianC# phrygianD lydianE mixolydianF# aeolianG# locrian
  • E majorF# dorianG# phrygianA lydianB mixolydianC# aeolianD# locrian
  • B majorC# dorianD# phrygianE lydianF# mixolydianG# aeolianA# locrian
  • Gb majorAb dorianBb phrygianCb lydianDb mixolydianEb aeolianF locrian
  • Db majorEb dorianF phrygianGb lydianAb mixolydianBb aeolianC locrian
  • Ab majorBb dorianC phrygianDb lydianEb mixolydianF aeolianG locrian
  • Eb majorF dorianG phrygianAb lydianBb mixolydianC aeolianD locrian
  • Bb majorC dorianD phrygianEb lydianF mixolydianG aeolianA locrian
  • F majorG dorianA phrygianBb lydianC mixolydianD aeolianE locrian

Here, we can see that scales that contain the same notes have the same color.

Show Source
export const circleOfFifths = Array.from({ length: 12 }, (_, i) => Note.get(Note.fromMidi(60 + ((i * 7) % 12))).pc);
export const scaleColor = (scale) => chromaColor(scaleChroma(scale));
export const familyScales = (family) => (
  <ul style={{ margin: 0 }}>
    {circleOfFifths.map((tonic) => (
      <li style={{ marginBottom: 2, listStyle: 'none', display: 'flex' }} key={tonic}>
        {Scale.modeNames(`${tonic} ${family}`).map(([root, scale], i) => (
          <span style={{ backgroundColor: scaleColor(`${root} ${scale}`), marginRight: 2, padding: 2 }} key={i}>
            {root} {scale}
          </span>
        ))}
      </li>
    ))}
  </ul>
);

<div>{familyScales('major')}</div>;

More Scales

Modes of Harmonic Minor:

  • C harmonic minorD locrian 6Eb major augmentedF dorian #4G phrygian dominantAb lydian #9B ultralocrian
  • G harmonic minorA locrian 6Bb major augmentedC dorian #4D phrygian dominantEb lydian #9F# ultralocrian
  • D harmonic minorE locrian 6F major augmentedG dorian #4A phrygian dominantBb lydian #9C# ultralocrian
  • A harmonic minorB locrian 6C major augmentedD dorian #4E phrygian dominantF lydian #9G# ultralocrian
  • E harmonic minorF# locrian 6G major augmentedA dorian #4B phrygian dominantC lydian #9D# ultralocrian
  • B harmonic minorC# locrian 6D major augmentedE dorian #4F# phrygian dominantG lydian #9A# ultralocrian
  • Gb harmonic minorAb locrian 6Bbb major augmentedCb dorian #4Db phrygian dominantEbb lydian #9F ultralocrian
  • Db harmonic minorEb locrian 6Fb major augmentedGb dorian #4Ab phrygian dominantBbb lydian #9C ultralocrian
  • Ab harmonic minorBb locrian 6Cb major augmentedDb dorian #4Eb phrygian dominantFb lydian #9G ultralocrian
  • Eb harmonic minorF locrian 6Gb major augmentedAb dorian #4Bb phrygian dominantCb lydian #9D ultralocrian
  • Bb harmonic minorC locrian 6Db major augmentedEb dorian #4F phrygian dominantGb lydian #9A ultralocrian
  • F harmonic minorG locrian 6Ab major augmentedBb dorian #4C phrygian dominantDb lydian #9E ultralocrian

Modes of Melodic Minor:

  • C melodic minorD dorian b2Eb lydian augmentedF lydian dominantG mixolydian b6A locrian #2B altered
  • G melodic minorA dorian b2Bb lydian augmentedC lydian dominantD mixolydian b6E locrian #2F# altered
  • D melodic minorE dorian b2F lydian augmentedG lydian dominantA mixolydian b6B locrian #2C# altered
  • A melodic minorB dorian b2C lydian augmentedD lydian dominantE mixolydian b6F# locrian #2G# altered
  • E melodic minorF# dorian b2G lydian augmentedA lydian dominantB mixolydian b6C# locrian #2D# altered
  • B melodic minorC# dorian b2D lydian augmentedE lydian dominantF# mixolydian b6G# locrian #2A# altered
  • Gb melodic minorAb dorian b2Bbb lydian augmentedCb lydian dominantDb mixolydian b6Eb locrian #2F altered
  • Db melodic minorEb dorian b2Fb lydian augmentedGb lydian dominantAb mixolydian b6Bb locrian #2C altered
  • Ab melodic minorBb dorian b2Cb lydian augmentedDb lydian dominantEb mixolydian b6F locrian #2G altered
  • Eb melodic minorF dorian b2Gb lydian augmentedAb lydian dominantBb mixolydian b6C locrian #2D altered
  • Bb melodic minorC dorian b2Db lydian augmentedEb lydian dominantF mixolydian b6G locrian #2A altered
  • F melodic minorG dorian b2Ab lydian augmentedBb lydian dominantC mixolydian b6D locrian #2E altered

Issue: Same Color for Different Scales

While the coloring inside one scale family works, we can see that some scales across families have the same color, for example C melodic minor and C mixoldian.

This is because the center is the same for both:

C melodic minor
0C1Db2D3Eb4E5F6Gb7G8Ab9A10Bb11B
C mixolydian
0C1Db2D3Eb4E5F6Gb7G8Ab9A10Bb11B

We can also double check this by calculating the chroma center:

(0 + 2 + 3 + 5 + 7 + 9 + 11) % 12 = 1 // C melodic minor
(0 + 2 + 4 + 5 + 7 + 9 + 10) % 12 = 1 // C mixolydian

Still, this way of coloring chromas is very helpful to differentiate different tonal centers inside the same scale family.

That's it for today, the next color post will be about scale light and darkness to diversify the colors.

Felix Roos 2023