Play Intervals - part 3

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

For this lesson we'll create intervals not out of thin air but from known scales with known note names. We'll be able to avoid any strange theoretical naming issues by limiting our intervals to notes we select from known scales. This way when we have some of the edge cases like an augmented 2nd, or a diminished 7th we can show which harmonic minor scale those intervals come from and give that interval a musical context. I think of this process as a sanity check on the music language making sure we don't try to ask weird things like 'what is a major third below Db?' (Bbb [not A], and that is just asking for a migraine). We'll use the major scale and the three forms of minor as our source scales then select two notes from one of those scales and play them. We can still allow the user to limit the selection to only specific interval sizes or specific scales (or let our code make those choices randomly). By whatever method, once a scale is selected we can create a three octave array of that scale and we will then be ready to create an ascending or descending interval of up to an octave starting from any note in the middle octave.

With regard to Tone.js, there isn't anything new about the playing of the intervals. The bulk of the code is dealing with the set-up of this enviroment from which we create the interval. Without going into details about implementation of the code, our process is as follows:

  1. Gather the users choices regarding scale type, key, limits to specific intervals and descending intervals (or use random choices)
  2. Create a three octave version of the scale.
  3. Randomly choose a starting note in the middle octave (save the index of that chosen note). Add that note as the first note of the interval.
  4. Select the second note using the interval size determined in step 1 as an offset to the index saved in step 3. Using (savedIndex + intervalNum) as the index to get the second note, add that note as the second note of the interval.
  5. Use the previously defined PlayInterval() function to play the interval.
  6. When the user clicks the Show Note Names button reveal the contextual information about the interval.

Now we'll have an interval that is drawn from notes of the major scale or one of the three forms of minor. And any of the more rare intervals will be put into a context that might really happen. And if we wanted to add more scale structures to as the source of the generated intervals, the process would remain the same.

Notice that the names in the key menu are the valid names for major scale, however some of these are not valid name for minor keys. If you choose a minor scale and choose one if the invalid key names for minor, the code will change it to the enharmonic name (the menu doesn't change though). We don't want to entertain the naming insanity of Gb minor or Db minor.

(click the stop button between plays)

random key: | Key:

random scale: | Scale type:

Limit to only Intervals of:

When you use a random key or random scale setting you won't be able to determine the musical context just by identifying the interval as there are many different contexts for any single interval. However, if you select specific scales and keys you should be able to identify both the interval name and which scale degrees are used to create that interval. (the first note is always shown)

Back to the Tone.js Setup page.