bell notificationshomepageloginNewPostedit profiledmBox

Hoots : Generating triads from a MIDI note number I have a single note from a MIDI instrument (wind controller) and I would like to generate a major triad from the note number. As I understand it the fifth is generated by always - freshhoot.com

10% popularity   0 Reactions

Generating triads from a MIDI note number
I have a single note from a MIDI instrument (wind controller) and I would like to generate a major triad from the note number. 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. 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. Is there a way to generate all major ( or minor ) triads for any given root note?

Please note I am not a musician which is hampering me in working out how to do this. If needs I can implement a look up table to work out this middle note.


Load Full (4)

Login to follow hoots

4 Comments

Sorted by latest first Latest Oldest Best

10% popularity   0 Reactions

If the starting note is the root of the chord, add +4 (major third) and +7 (perfect fifth) to generate a major chord in root position. E.g. 60 +4 +7 = 60 64 67 = C E G (C major)

To generate a minor triad, +3 (minor third) +7, e.g. 60 +3 +7 = 60 63 67 = C Eb G (C minor)

If by "generate all major/minor triads for a given note" you mean to generate other inversions of the chord, then for example (always taking 60 = C4 as the starting note):

first inversion = +4 +7 +12 = 64 67 72 = E G C (C major, first inversion)

second inversion = +7 +12 +16(12+4) = 67 72 76 = G C E (C major, second inversion)

next octave = +12(12+0) +16(12+4) +19(12+7) = 72 76 79 = C E G (C major, root position, next octave)

For minor triads, use +3 instead of +4

For lower octaves, subtract 12, 24, etc.

For augmented triads: ROOT +4 +8

For diminished triads: ROOT +3 +6

And so on... it's all fairly simple and straight-forward, like a using keyboard where every key is a different number, with middle C being 60.


10% popularity   0 Reactions

There seems to be some confusion as to what you mean by "generate all major ( or minor ) triads". Inversions have been mentioned so I won't repeat that but you might mean something else.

Imagine playing a simple chord shape on a guitar and then moving it upwards fret by fret with a barre or capo. The root will move up a semitone each time and the number of semitones between each note in the chord will remain fixed. If it started as a major triad then it would stay that way. Just add 1 to all of your midi notes to get this effect.

Now play a simple chord on a piano e.g. middle C and the E and G above; this is a major triad. Now move up one white note and you will get D F A. Two differences from the guitar are that the root has moved up a tone and you now have a minor triad. Move up another white note and you have E G B; the root has gone up a tone again and you have another minor triad. Now to F A C, the root has gone up only a semitone and you have a major triad again. When you get to B D F, you will have a diminished triad. This will require a more complex pattern to the MIDI numbers. If this is what you want, I'll add some more details.


10% popularity   0 Reactions

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.

Correct - 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.

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.

Don'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.

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. 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. 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.

But MIDI note numbers aren't based on degrees of the diatonic scale - they're purely numbers of semitones. The formula for each type of chord in terms of number of semitones is always the same.

Is there a way to generate all major ( or minor ) triads for any given root note?

You already have the formula for generating major triads. For minor triads, just add 3 to get the minor third, and 7 to get the perfect fifth.

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!

To add some further information. My controller outputs in the key of C major. In order to transpose this to any key I am adding a constant number to the MIDI notes. 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. Therefore I believe I must consider the distance of the note being played relative to the root note of the key I am in.

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. 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.

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.

Let's assume that we are using the major scale, so that we want to generate the diatonic chords of the major scale.

if (note number % 12) = 0, you play a major chord.
if (note number % 12) = 2, you play a minor chord.
if (note number % 12) = 4, you play a minor chord.
if (note number % 12) = 5, you play a major chord.
if (note number % 12) = 7, you play a major chord.
if (note number % 12) = 9, you play a minor chord.
if (note number % 12) = 11, you play a diminished chord (root, root+3, root+6)

From that point, you can do your overall transposition to shift the output to the right key.

Of course that still leaves some questions unanswered. Will you have a separate way that the player can indicate minor keys, or will they just have to set the transposition suitably and play starting from A? What if a player plays a note that's not in the diatonic scale, or wants a chord that's not in the diatonic set of chords? There aren't any 'correct' answers to those questions - you'll have to find the right balance between flexibility and ease of use.


10% popularity   0 Reactions

adding a fixed number will result in a major or minor triad depending
on the starting note

Wrong. MIDI note numbers are semitones, and adding a fixed number of semitones always results in exactly the same type of chord regardless of the starting note.

But how the chord is interpreted when played in an actual musical context can be very different. In a song in the key of A minor, playing an F major chord creates a completely different effect than an E major, even though both are major chords with exactly the same intervals in semitones (i.e. MIDI note number values) relative to the root.


Back to top Use Dark theme