# Constructing a database of complete music theory?

I would like to write a python program which is connected to a freely downloadable music theory database / data-structure to run the following query:

Return all chords within the E major scale together with their notes:

For example the 2nd arpeggio in this YouTube video uses the following progression over 5 strings:

``````E major 7 --> (E,B,D#,B,E) --> TAB(7,9,8,0,0)
B7 add11 / F# --> (F#,A,D#,B,E) --> TAB(9,7,8,0,0)
E major 7 / G# --> (G#,B,D#,B,E) --> TAB(11,9,8,0,0)
``````

It would be nice to have a computer program tell me that there are X chords in E major 7 and to also display the notes. I notice that some online websites do this but they do not include 'B7 add11'.

What is the best way to source the data or construct the data?

• Even though I spent enough time writing this, it's much faster to do it manually with hands on guitar + eyes on the fretboard. Given that most shapes are movable, you'll be able to recycle most of your explorations. Oct 31, 2022 at 0:21
• I've revised your question so that it will be on topic here and still — I hope — represent your end goal. If not, let me know, and I'll roll back my changes. Oct 31, 2022 at 3:48
• Check the music21 and mingus libraries for Python Oct 31, 2022 at 14:45
• What do you mean by "within the E major scale"? Pieces in E major will commonly contain F sharp major chords even though the third of F sharp major, A sharp, is not in the E major scale. This problem gets worse in minor keys; for example, in E minor you can easily find chords containing not only A sharp but also C sharp and D sharp. A piece in a minor key that isn't particularly adventurous in terms of tonality or chromaticism can therefore easily use 10 of the available 12 tones on the standard keyboard. Nov 1, 2022 at 12:18

## Return all chords within the E major scale together with their notes

#### 1. Can't be done

The query presumes all chords (i.e., collections of notes) within a scale have names or even can be named. However, this is not the case.

As an example, within E major is the chord `E G# B C#`. Given the pitches only, it's impossible to know whether this is `E6` or `C#m7`.

Another E major example: `E A B`. Is this `Esus4`, `Asus2,4`, `A9sus4(omit5)`, `B7sus4(no3)`, or `B11(no3,9)`?

This is a variation on the problem simply of identifying the root of an arbitrary chord (i.e., collection of notes). See How would you identify the root of a non-standard chord / cluster?.

A chord name (i.e., chord symbol) can be created for any collection of notes, but it's not necessarily any more meaningful than just listing the notes themselves.

#### 2. How it might be done

• Every scale of a particular type (e.g., diatonic, harmonic minor, lydian dominant) contains exactly the same chords (i.e., collections of intervals) regardless the starting pitch.

Way A: Just list every possible combination of (3 or more) notes, but don't name them.

Way B: Create a subset of names (M, m, 7, M7, m7, dim, ...) that are of particular importance, and only list those.

Way C: Combine A and B, list every possible note-collection, but only give names for those within the subset.

Way D: Throw out note names and just list pitch or interval classes. For example, all major triads can be denoted [047]. All major scales being "equivalent", they can be denoted [024579E] (E=11). So the program for producing all chords would just spit out subsets.

This is essentially the engine even with note names. Just define the scales numerically, then assign note names by transposing (i.e., adding: c=0, c#=1, d=2, etc.).

• Actually, every scale type with the same number of notes has the same interval collections (e.g. ^1-^3-^5-^7). Scales with different numbers of notes from the usual major scale (e.g. whole tone, half-whole octatonic/diminished, chromatic) can support more or fewer interval collections as chords. Oct 31, 2022 at 12:10
• @Dekkadeci I think my post was unclear. Please take a look at the revised bullet point and let me know if it addresses your comment. Oct 31, 2022 at 13:44
• The revision ("Every scale of a particular type (e.g., diatonic, harmonic minor, lydian dominant)") still doesn't look clear enough. The types sound too specific (diatonic/major, harmonic minor, and Lydian dominant all have the same number of notes, for instance), and you don't emphasize clearly enough what a "type" (of scale) is where each scale of that type - and only each scale of that type - has the exact same chords. As far as I can tell, that "type", at least for Way D purposes, is indeed the number of notes per scale. Oct 31, 2022 at 13:55
• @Dekkadeci Way D would work either way. Harmonic minor and diatonic major, for example, have the same number of notes but different interval and chord contents. Oct 31, 2022 at 16:03
• At least to me, "Every scale of a particular type" implies quite strongly that each of the following scale types should be generalized and not specific, so seeing "lydian dominant" among them was jarring because that scale is mode-locked to only one mode (i.e. the moment you try starting that scale on the 2nd scale degree, you have to call it something different). Nov 1, 2022 at 4:05