If (note number % 12) = 11, you play a diminished chord (root, root+3, root+6)įrom that point, you can do your overall transposition to shift the output to the right key. If (note number % 12) = 9, you play a minor chord. If (note number % 12) = 7, you play a major chord. If (note number % 12) = 5, you play a major chord. If (note number % 12) = 4, you play a minor chord. If (note number % 12) = 2, you play a minor chord. If (note number % 12) = 0, you play a major chord. Let's assume that we are using the major scale, so that we want to generate the diatonic chords of the major scale. You say that you know your controller always outputs in the key of C major, so you might actually save yourself some logic if you work out the chords at that point, because you know the 'root note' of the scale is C - midi note 60, which is, handily, also a multiple of the number of semitones in the chromatic octave. To do this, we have to make some assumptions as to what the 'right' chords are, but a common starting point in Western music is to assume the diatonic chords of the scale.
#Midi note number for c0 how to#
So everything we said so far about how to generate major and minor chords is correct - but if I understand correctly, you also want to generate the 'right' chord based on the degree of the scale. Therefore I believe I must consider the distance of the note being played relative to the root note of the key I am in.
In addition when I am in this key I want a switch to give the option of generating a minor triad or a major triad along with the note played. In order to transpose this to any key I am adding a constant number to the MIDI notes. My controller outputs in the key of C major. I'm not sure what your use case for generating all major or minor chords, but note that a minor key does not always use minor chords, and a major key does not always use major chords! For minor triads, just add 3 to get the minor third, and 7 to get the perfect fifth.
You already have the formula for generating major triads. Is there a way to generate all major ( or minor ) triads for any given root note? The formula for each type of chord in terms of number of semitones is always the same.
Another way of looking at this is that the diatonic scale 'skips' some notes in the chromatic scale, which is why you get different numbers of semitones, and why triads based on different degrees of a major scale are sometimes major, sometimes minor.īut MIDI note numbers aren't based on degrees of the diatonic scale - they're purely numbers of semitones. For example, on the major scale, the third between degrees 1 and 3 is a major third, and the third between 2 and 4 is a minor third. When you talk about "major or minor depending on the starting note", maybe you are thinking of intervals between degrees of the diatonic scale, like 'a third', which can have different sizes. However, I don't think it works like that because adding a fixed number will result in a major or minor triad depending on the starting note.ĭon't worry, it does work like that - starting with a root note and adding intervals with a fixed number of semitones, which is what the MIDI note numbers represent, will always result in the same chord. As I understand it the fifth is generated by always adding seven to the MIDI note number, and the third is generated by adding four.Ĭorrect - even more specifically, the perfect fifth is generated by always adding seven to the MIDI note number, and the major third is generated by adding four.