# General procedure for determining the name of an interval given a major key / diatonic collection [duplicate]

I'm attempting to program a library that lets one make use of concepts from Peter Westergaard's tonal theory.

The current problem I'm trying to solve is to determine the specific name of an interval given two notes (including octave, so something like B#4 and Cb5) AND a diatonic collection (which you can just think of as a major key, if you are unfamiliar with tonal theory).

Tonal theory states that the name of the interval between two notes is based on the number of major and minor seconds that comprise the interval. Here's the definition for every interval up to an octave:

minor 3rd - 1 minor 2nd, 1 major 2nd

major 3rd - 0 minor 2nds, 2 major 2nds

diminished 4th - 2 minor 2nds, 1 major 2nd

perfect 4th - 1 minor 2nd, 2 major 2nds

augmented 4th - 0 minor 2nds, 3 major 2nds

diminished 5th - 2 minor 2nds, 2 major 2nds

perfect 5th - 1 minor 2nd, 3 major 2nds

augmented 5th - 0 minor 2nd, 4 major 2nds

minor 6th - 2 minor 2nds, 3 major 2nds

major 6th - 1 minor 2nd, 4 major 2nds

diminished 7th - 3 minor 2nds, 3 major 2nds

augmented 6th - 0 minor 2nds, 5 major 2nds

minor 7th - 2 minor 2nds, 4 major 2nds

major 7th - 1 minor 2nd, 5 major 2nds

perfect octave - 2 minor 2nds, 5 major 2nds

imperfect octave - 1 minor 2nds, 6 major 2nds

or 3 minor 2nds, 4 major 2nds

Let me make sure my assumptions are correct, first. I'm assuming that you cannot always determine the specific name of an interval without knowing the key/diatonic collection that the notes are present in. For example, take the interval C to E. If we are in the key of C major (diatonic collection starting on C), you would go C->D->E which is 2 major 2nds - a major 3rd. But, if you are in the key of D major, you would be starting on a note that isn't in the scale. I'm not sure of the process for naming the interval, given this situation (this is part of the question), but you could go C->C#->D->E, which would be 2 minor 2nds and one major 2nd - a diminished 4th. Given that, I assume you can't just say that C to E is a major 3rd regardless of the context those notes appear in.

My other assumptions is that counting 2nds is a valid way to determine the interval name.

With that in mind, my question is this: How do you determine how many major and minor 2nds are in an interval, given a major key (with the goal of naming the interval)?

I would guess that, if the interval notes are in the scale, you simply walk up through the scale and count the intervals.

But I don't know how to handle the case for when the interval notes are not on the scale. Here's what I've tried to do to solve this:

You can think of any off-key note as being a deviation above or below an on-key note. You determine whether it is above or below using the note name. For example, in D major, let's consider the off-key note C. The only time the letter C appears in the major scale is as C#. So we think of C as being a half-step below C#. Similarly, we think of D# as being a half-step above D in that key.

Given that, when given an interval and a key, determine how the interval notes deviate from the notes in the key. For the bottom note, if the deviation is above (like D# in the previous example), then, when counting up, use a 2nd to get up to the closest on-key note (in the D# example, this would be using a half-step to get up to E). Then count as normal. If the deviation of the bottom note is below (like C in our example), then count as normal, but start from the note it is below (so C#). If there were any minor 2nds, remove one and add a major 2nd. If there weren't any, add a minor 2nd to the count.

I'm honestly not sure how to handle "top note deviations", but at this point you can at least see what I tried. Based on how hacked-together and complicated it seems, I believe it's unlikely it's right, anyway, so it's not worth continuing to try to flesh it out.

So, does anyone have a method that actually works to determine the number of seconds in an interval, given a major key? Or, for that matter, just a method for determining the name of an interval, given a major key? I assume there is a method, but I haven't been able to find a good resource through Google.

EDIT: I did find some potential resources for this, going to take a look through them. It seems my assumptions may be wrong: http://www.eartrainingmastery.com/en/blog-and-music-theory/blog-en/299-enharmonically-equivalent-intervals-augmented-second-or-minor-third

https://www.musicgoals.com/webhelp/interval_naming.htm

• Welcome to the Site! It sounds like you need to be acquainted with interval vectors and set theory. Try looking them up and see if they help. – jjmusicnotes May 8 '14 at 6:59
• Interval vectors do not have the ability to distinguish between a major third and a diminished fourth (and other enharmonically equivalent intervals). The concept of a diminished fourth doesn't even exist in interval vectors. I need a tool that is able to distinguish between enharmonically equivalent intervals, but it seem interval vectors just assume that a given semitone distance always has a specific interval name (i.e. it assumes 4 semitones is always a major 3rd). But that is NOT the case in music - 4 semitones is sometimes called a diminished 4th. – chairbender May 8 '14 at 16:29
• You are correct about interval vectors, though I wonder why you are speaking about them negatively. Not distinguishing between enharmonic spellings is kind of the point - in music most theoretical constructs are developed to describe how music sounds not how it looks - which by-and-large is the less important of the two. AFAIK, I directly answered your question. I am also puzzled why it is important for you to name intervals via their enharmonic spelling? Lastly, I really don't appreciate your patronizing tone; it is unnecessary and unwelcome. – jjmusicnotes May 8 '14 at 19:24
• Oh, I have to honestly apologize, then! Sorry, I wasn't intending to be patronizing (I'm not sure how it came off as patronizing, but I can understand how that wouldn't carry over in text). I never intended to communicate that interval vectors weren't useful or anything negative, I just wanted to try to be clear about why they didn't solve my problem - and I tried to be very clear about it because I think it's a potentially confusing question. Sorry if my overly-wordy response came off as patronizing! – chairbender May 8 '14 at 19:59
• If the solution to your problem is not clear to you from the above question and answer, the only piece of the puzzle that is not explicitly named in that Q&A is that diatonic collections are completely irrelevant to naming intervals. C-Fb is a diminished fourth in any key, C-E is a major third in any key. – 11684 May 11 '19 at 20:48

As noted, the term "Pitch Class" (PC) assumes enharmonic equivalence, and there are only 12 of them. Rather than calling them "note names" I have also seen the term "Tonal Pitch Class" (TPC) used to represent the non-enharmonic version of this concept. IOW, F# and Gb have the same PC, but a different TPC. This terminology, for example, is used by the open source notation editor Muse Score. http://musescore.org/en/plugin-development/tonal-pitch-class-enum

If the 12 PCs can be arranged via the well-known "Circle of Fifths", the TPCs can be arranged using its lesser-known cousin, the "Line of Fifths". This can be formed by taking the circle, and disconnecting it at the point where the sharps become flats, and then stretching it out infinitely in both directions. One direction constantly becomes more sharp, the other direction, more flat. The following PDF is the first Google result for "line of fifths" and introduces the concept nicely. http://theory.esm.rochester.edu/temperley/papers/temperley-ma00.pdf

Once you have this line of fifths, determining the proper interval name is just a matter of counting the distance between the two TPCs on this line. In the diagram below, the left column is the line of fifths, and the right column is the name of the interval from D to that note (I chose D because it lies exactly between the flats and the sharps). To start from another note besides D, you could just shift the right column up or down until PU (perfect unison) is next to the desired starting note.

```  …     …
F♭    d3
C♭    d7
G♭    d4
D♭    dU
A♭    d5
E♭    m2
B♭    m6
F     m3
C     m7
G     P4
D     PU
A     P5
E     M2
B     M6
F♯    M3
C♯    M7
G♯    A4
D♯    AU
A♯    A5
E♯    A2
B♯    A6
…     …
```

You'll notice that the interval names fall into a nice pattern. The numeric part of the name follows a repeating pattern of {U, 5th, 2nd, 6th, 3rd, 7th, 4th} while the qualitative descriptors are arranged with 3 perfects in the center, 4 minors/majors on each side, followed by 7 diminished/augmented, and then 7 doubly-diminished/doubly-augmented, and so forth. These later aren't shown here, but they can be found by a simple extension of the chart.

• @CalebHines I just formatted your post with pre tags. Is this better for you? – Dom Dec 7 '15 at 5:10

"So, the real way to figure out an interval name, given 2 pitch classes"

I think this is the wrong starting point. Pitch class is just the collection of sounds (tones) that are 1 octave apart. In a well-tempered 12 tone system, 0, 1, 2, ... 11 are pitch classes.

"First, count the distance between the letters of the pitch classes, then add one."

Going by this I'd say your starting point is not pitch class, but note names. So I'd reword your step to:

"count the difference between the numerical value of the letters of the note names (ignoring the postfix that might be added due to flattening or sharpening)"

More formally to calculate from note N1 to note N2 you'd do:

``````(((N2.numVal - N1.numVal) + 7) mod 7) + 1
``````

"Subtract the Semitone Count (from the last step) from the actual half step count and use the Interval Type to figure out the interval quality using the table"

I think the operation is ok, but I don't really agree about your use of terms "interval type" and "interval quality". I'd say, "third" is an interval type, "minor" and "major" is a quality. You don't say, "I have a majord 3rd with the minor quality" - that doesn't make sense: minor third and major third are separate entities and both first class citizens.

"...and there you have your interval!"

Final word: I think i'd add "harmonic" to interval. If you're talking about "melodic intervals", the operation would start the same but would also have to reflect "descending" and "ascending" as properties, and you'd probably care about the octave. I mean, in melody it is a huge difference whether you repeat a note (prime interval) or take a leap of an octave. That is not to say octaves don't matter at all in harmonic sense: It makes a big difference in sound whether you're hearing a 2nd as compared to a 9th;

• Thanks for the corrections! I updated my answer to use more accurate terminology. I did mean to say "note" instead of pitch class. – chairbender May 9 '14 at 16:12
• I agree with everything here except that the minor and major 3rds are always separate entities. Set Theory proves that minor and major triads are actually the same chord. – jjmusicnotes May 9 '14 at 16:45
• @jjmusicnotes Interesting. I'd have to admit that I don't know enough about set theory to oversee it. First thing that comes to mind is that major and minor triads are inversions (mirrors) of each other. Is that how the are "the same" according to set theory? Even if that is the case, it seems to this still does not invalidate my remark that the intervals minor and major third aren't completely separate entities. – Roland Bouman May 9 '14 at 18:23
• @dfhwze, uh, indeed. We could just remove the +7 if we're doing mod. I think I wrote it and then modified the calc to make it work regardless of which one is lower. – Roland Bouman May 11 '19 at 19:23

Well, it seems like the answer to the question is that my assumptions are wrong. (Note to self for the future: I should've just looked up intervals on wikipedia as a starting point and I could've easily answered my question.)

My first assumption was that you cannot determine the name of an interval without knowing the key it exists in. That seems to be wrong given the new sources I discovered. You don't need to know anything other than the notes.

My second assumption was that using seconds is a valid way to name an interval. I got this from reading Introduction to Tonal Theory, where Westergaard describes each interval in terms of the major and minor seconds they are composed of. I don't really know why he does this.

So, the real way to figure out an interval name, given 2 notes, is this (I'm only handling intervals up to a major 10th. Any larger interval is generally referred to as a compound of some number of octaves + an interval less than an octave):

First, count the difference between the numerical value of the letters of the note names (ignoring the postfix that might be added due to flattening or sharpening).

Next, figure out the interval naming scheme and semitone count. Use this table:

```    |-----------------|--------------------------|
| Interval Number | Scheme  | Semitone Count |
|-----------------|---------|----------------|
| 1               | Perfect | 0              |
| 2               | Major   | 2              |
| 3               | Major   | 4              |
| 4               | Perfect | 5              |
| 5               | Perfect | 7              |
| 6               | Major   | 9              |
| 7               | Major   | 11             |
| 8 (octave)      | Perfect | 12             |
| 9               | Major   | 14             |
| 10              | Major   | 16             |
|-----------------|---------|----------------|
```

Now count the half steps between the actual interval. Subtract the Semitone Count (from the last step) from the actual half step count and use the Interval Naming Scheme to figure out the interval quality using the table:

```    |-------------------|------------|---------------|-----------|------------------|
| -2                | -1         | Scheme        | +1        | +2               |
|-------------------|------------|---------------|-----------|------------------|
| diminished        | minor      | Major         | augmented | doubly augmented |
| doubly diminished | diminished | Perfect       | augmented | doubly augmented |
|-------------------|------------|---------------|-----------|------------------|
```

For example, if the interval number is 5 but you count 6 half steps, you would do 6-5 = +1 and look at the Perfect row, giving you augmented.

...and there you have your melodic interval (a harmonic interval would need to also describe which note came first)!

• Actually, "A-C" is a minor 3rd. I don't understand how you are arriving at "2" for a distance between Ab and C. Also, it is pointless to do anything more than 12 semitones (an octave) as every theorist would immediately just displace the pitch class at the octave and bring it down to a manageable size. I still don't understand why the enharmonic nomenclature is so important? Regardless of key, the names you're using are applied with respect to the lower pitch of the interval. Therefore, Ab-C# would be an augmented 3rd. It's as simple as that. Lastly, no one uses the Westergaard text. – jjmusicnotes May 9 '14 at 5:09
• Oops, accidentally switched the intervals in my first comment. The number "2" is the distance between the letters A and C in an ordered alphabet. I care about the nomenclature because I actually care about the notational aspect, and also because I think it's interesting. – chairbender May 9 '14 at 5:54
• I see, thanks for the clarification. Why go through the trouble of programming a library that makes use of a tonal theory that was never accepted and that no one uses? – jjmusicnotes May 9 '14 at 6:46
• It's occasionally useful to refer to the 9th, 11th, and 13th intervals because they turn up in extended chords, where they function a bit differently from 2nds, 4ths, and 6ths. – Bradd Szonye May 9 '14 at 7:41
• "You don't need to know anything other than the names of the pitch classes." I think I understand, but I think technically, there is no such thing. Or rather PC0 could have multiple names: C, B♯ D𝄫. I'm not sure though what the proper name is for that whing we denote by "c". "note name" sounds wrong since we can talk about that think without talking about an actual note. – Roland Bouman May 9 '14 at 9:20