I would like to write an algorythm that builds regular 3key piano chords progression in a given octave shifting to the next one if not all possible notes were covered. For example:
Cmaj key will give all the notes/chords in it’s progression, since the starting note is a start of the octave it will terminate at the next C. But if I start with the B note of the same octave, it will end with the B in the next one as well.
I would like to build it both for major and minor scales with ability to extend it for 7 and 9 type chords in the future.
This is not a homework, I would like to use c# and then re-write it in f# to learn the language a little bit more.
Edit:
My question is this then:
What data structure should I use for the octave (C to C): LinkedList List or may be this will require completely different structure?
Edit2:
So if we index notes like this, which I am not sure if it’s a correct approach:
0 1 2 3 4 5 6 7 8 9 10 11 12
Input: Note = C (0), Scale = Maj
Output: 0 4 7, 2 5 9, 4 7 12, etc.
The easiest way to model this, perhaps, is to use the notion of midi note mapping, as the keys are enumerated and a first inversion triad from a given root will be
next inversion would be
next inversion would be
where root is the midi note number for your root.
In fact, given a chord in first inversion, it’s trivial to generate all the other inversions by removing the first entry, putting it on the end and adding 12. So your chords would really start to look like this:
Then whatever is returned from here (and probably using List would be better), you can write an IEnumerable that returns each of the inversions. Then you add the value of the root to the output and ta-da! you have your chord, which is now tremendously easy to output as, well, midi.