I have an arduino attached to a Stradella system Piano Accordion. I have optical sensors on each of the 12 notes of the chords on the left hand. When I play a chord it triggers three sensors. That's ok if I want the synthesiser to play the chord but sometimes I want it to just play the root note; so if I play C major I want it to play just the note C.
In the table below you can see that the triggered sensors for the chord C major is sensors 0,4 and 7. But because they are all triggered at the same time they may not arrive in that order, i.e. they could arrive as 4,0,7 or any combination.
Finding the root note for C major is easy, find the two notes whose difference is 7 and the root is the lower of the two. Same for D and E Major etc. But the higher chords like F major have a high note that wraps round to the bottom again so the numerical difference is not 7 anymore.
0 1 2 3 4 5 6 7 8 9 10 11
C Major X X X
C# Major X X X
D Major X X X
D# Major X X X
E Major X X X
F Major X X X
F# Major X X X
G Major X X X
G# Major X X X
A Major X X X
A# Major X X X
B Major X X X
Does anyone have any ideas of how I could determine the root notes of these chords fairly cheaply (It's running in a loop at 600 times a second and the arduino is doing a LOT of other stuff).
I'm completely stumped, I've experimented with looping up incrementally until 11 is reached and then starting again from 0 and doing this three times for every chord but it seems messy.
I would also like to be able to resolve the other two rows of buttons on the accordion, the dominant and diminished 7th
These are the four shapes for C, the other 11 notes will be the same shape but shifted to the right until it wraps back to 0 again.
0 1 2 3 4 5 6 7 8 9 10 11
C Major X X X
C Minor X X X
C 7th X X X
C Dim7th X X X
Any suggestions much apprecciated!.