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
Another E major example:
E A B. Is this
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 . 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.).