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