Play Modes

The music theory content can be found at Music Fundamentals on the Web.

Every major scale is the parent scale for a family of MODES that are related to that parent scale. The term 'parent' is used as if it spawns children scales, but the relationship with the Major scale and its Modes is more like siblings. Using the letter names of the C major scale the process for creating modes is shown below. For each mode the starting note is different but it still moves through the notes in the same order using the notes of the parent scale, only the starting point is different. This happens commonly in the key of C, having phrases starting on any lettern name of the scale. But the Modes are different because for each mode the starting letter name is the key center (not C). The C major scale has as it relatives (children?): D dorian, E phrygian, F lydian, G mixolydian, A aeolian, and B locrian. Each one of the Modes (often referred to as 'scales', Dorian scale = Dorian mode) has a unique interval structure and musical characteristics.

The remainder operator (%) is useful for creating modes. As a reminder of how the remainder operator works, it returns the remainder after an integer division has been applied to 2 numbers. For example:

When applied to a scale as shown below, it can help create a mode from any note of that parent scale (modeNum). By using the remainder operator (%) you can wrap around to the beginning of the Cmajor array as i+modeNum exceeds the length of Cmajor. By using the remainder operator with Cmajor.length as the divisor, you'll never go outside the bounds of the Cmajor array. It's a very useful pattern for many aspects of processing musical structures. modeNum = 0 will be the original parent scale and other numbers will offset that starting note. When modeNum = 4 as in the example, the G mixolydian mode is created.

NOTE: Since musicians usually start counting at 'one' and computer code likes to start counting at 'zero', there are possibilities for the classic 'off by one' error when dealing with music structures.


var Cmajor = ["C","D","E","F","G","A","B"];
var modeNames = ['major','dorian','phrygian','lydian','mixolydian','aeolian','locrian']
var modeNum = 4;

function makeMode(scaleNotes, modeNum) {
  var scaleIndex = 0;
  var modeNotes = [];
  for(var i=0; i<scaleNotes.length; i++) {
    scaleIndex = (i+modeNum) % scaleNotes.length; 
    modeNotes.push(scaleNotes[scaleIndex]);
  }
  console.log("mode="+modeNames[modeNum]+" notes="+modeNotes.toString());
  return modeNotes;
}

var myMode = makeMode(Cmajor, modeNum);
// outputs to console: 'mode=mixolydian notes=G,A,B,C,D,E,F'

We could add an octave number to each note and we're ready to use the mode. But we've found that using the interval structure of the scale is a more flexible approach to scale creation. We can create the interval structure of modes with a use of the remainer operator (%) two times. The first use keeps us within the bounds of the majorFormula array, the second use makes the modeIntervals added to the modeFormula start at zero and use numbers within a single octave (less than 12) hence % 12.


var majorFormula = [0,2,4,5,7,9,11];
var modeNames = ['major','dorian','phrygian','lydian','mixolydian','aeolian','locrian']
var myModeNum = 4;

function makeModeFormula(parentScaleFormula, modeNum) {
  var scaleIndex = 0;
  var modeFormula = [];
  var modeInterval;
  for(var i=0; i<parentScaleFormula.length; i++) {
    scaleIndex = (i+modeNum) % parentScaleFormula.length;
    modeInterval = (parentScaleFormula[scaleIndex] - parentScaleFormula[modeNum] +12) % 12;
    modeFormula.push(modeInterval);
  }  
  console.log("mode="+modeNames[modeNum]+" formula="+modeFormula.toString());
  return modeFormula;
}

var myModeFormula = makeModeFormula(majorFormula, myModeNum);
// outputs to console: 'mode=mixolydian formula=0,2,4,5,7,9,10'

Once we have the interval formula we can use the scale creation code we've used previously. So creating modes of a major scale is almost as easy as creating a major scale (just one additional step to create the mode formula). In fact we can create modes of other 'parent' scales. The natural minor scale is already a mode of major, however both harmonic minor and melodic minor have their own unique structure. They can be used as a parent scale from which to spawn a family of modes. Fortunately all of the naming issues should also be solved.

Select a key, scale type and mode number then click Play Mode. The display will show the name of the parent scale, the mode number and the notes names of the mode from that parent scale.

tempo: | Scale pattern: | volume:

key: Parent Scale Type: Mode:



Notice that mode creation code doesn't add the octave note at the end. If we want to easily rotate around the modes from a parent scale like this we'll need to leave off the octave until after the mode is created. If we need the octave note it is a simple task to read the first note, modify the octave number by one then add it to the end of our newly create mode. We use the changeOctave() function for this purpose and add the octave note to the mode before it's passed to playMode().


function changeOctave(note, howManyOctaves) {
    var octaveChange = Number(howManyOctaves);
    var noteName = note.substring(0 , note.length-1)
    var startingOctave = note.substring(note.length-1, note.length)
    var correctNameAndOctave = noteName.concat((Number(startingOctave)+octaveChange).toString()) 
    return correctNameAndOctave;
}
var octaveNote = changeOctave(myMode[0], 1);
myMode.push(octaveNote);

Also, if minor scales are selected AND an illegal minor key name is also selected, the key name is modified to the enharmonic equivalent (however the menu doesn't change). As with other pages, the code is in the head section of this page, view source for details.

Back to the Tone.js Setup page.