[math-fun] Kraehenbuehl's harmonization algorithm
It seems Matt Earnshaw programmed it Listen to his example: https://soundcloud.com/mattearnshaw/kraehenbuehl-harmonies-test His algorithm in a LISP-like language: https://gist.github.com/mattearnshaw/ba3928a256d55341e288 I did not understand this algorithm. Be nice if somebody translated it into something understandable. (Which likely Knuth already did, but I do not have his book.) So I will now try...: Supposedly any N-note single-voice melody -- i.e. time-ordered sequence of N notes -- is converted in this way into any of 2^N + 2^(N-1) harmonized versions (in which each single note is converted into a 4-note chord) "all of which sound pretty good." A "standard major triad" chord is CEG with note-separations (using the 12-tone scale) 4 & 3. To "invert" it (I apologize for the asinine wording used by musicians) you move the lowest note (here C) up one octave (to a higher C), converting the note-separations to 3 & 5. Invert it again by moving lowest note (now E) up one octave to higher E, yielding note-separations 5 & 4. Finally invert it again by moving the lowest note (now G) up 1 octave to higher G, yielding note separations 4 & 3. Thus applying the "inversion" operation 3 times, invert^3, is the same as the frequency-doubling (i.e raising everything 1 octave, i.e. 12 steps) operation (I re-apologize for the asinine nature of musician word usage). In other words, note-separation ordered-pair (X,Y) is converted by inversion to (Y,12-X-Y), then to (12-X-Y,X) then to (X,Y). I suppose perhaps Kraehenbuehl might also allow harmonizing using all "minor triad" chords instead of all "major triads" but in the exact same way. The minor triad is ACE with note-separations 3 & 4. It inverts to 4 & 5, which in turn inverts to 5 & 3, which finally inverts back to 3 & 4. Apparently Kraehenbuehl's algorithm is this. Replace the first note in the melody, by one of the three "inversions" of a major (or we could allow minor?) triad chord, appropriately shifted to contain that note as its highest note. (Hence, if major, then 3 choices: note separations either 4&3, 3&5, or 5&4.) Now, for the subsequent N-1 notes in the melody, do the same, except on all these N-1 occasions only 2 among the 3 invert-versions, of the triad with that note topmost, are permitted -- because Kraehenbuhl demands the invert-versions must differ, i.e. the note-separation-ordered-pair for the Kth chord, cannot equal the note-separation-ordered-pair for the (K-1)th chord. So on each successive non-first note in the melody, there are 2 allowed choices. (You always stay all major or all minor since all chords agree with the first chord about majorness or minorness.) The total number of all-major harmonizations thus produced, is 3*2^(N-1), and each note in the original melody has been converted to a 3-note chord. Now Knuth as a further refinement, wants each note to be converted to a 4-note chord, not merely a 3-note chord (i.e. "4 part harmony"). To accomplish that, he adds 1 more bass note to each chord, which is 12 tones (i.e. 1 octave) below one of the 3 Kraehenbuehl notes we already have. Which one? Well, each of the Kraehenbuehl chords was either an invert^0, invert^1, or invert^2. Keep track of this exponent (modulo 3). The extra bass note is 1 octave below the topmost 3-note-chord note if 0, the middle one if 1, or the lowest one if 2. (Warning: I may have switched "1" and "2" here.) idenity operation (excvpet upo 1 octave).
participants (1)
-
Warren D Smith