Topic: Algorithmic composition using Pianoteq
I’ve always been in awe at J.S. Bach’s transformation of simple chorale melodies into fugues or other types of counterpoint, mostly in his vocal works, as well as the outstanding harmonizations he made of those melodies.
There is a data base of over 400 of these harmonizations in the form of similarly sequenced MIDI files freely available here: http://www.jsbchorales.net/index.shtml
I downloaded it and proceeded to write a program (in C for speed) to process these files and automatically generate four-part strict canons to the fifth with all this data, in the form of MIDI file that I render with varying pianoteq instruments. Canon form has the advantage that I don’t have to generate additional counterpoint as is necessary with a real fugue, while still keeping the spirit of what motivated me.
The program itself works by doing harmonic analysis of the harmonized chorale, extract the musical phrases using the results and then use brute force to evaluate harmonically ALL possible canons with the choral melody in the soprano. The other voices of the source harmonization are discarded. The best one is kept after the iterations are finished.
This process can be almost instantaneous when the number of case analyzed is in the thousands or hundred of thousands, but the longest case I found involved over twelve million cases, using about an hour in cpu time on a quad-core 3.7 GHz MacPro! These hard cases were very rare so I managed to process all the MIDI files in a couple of months (part-time of course) generating about a thousand canons since I can vary to some point the shifting parameters of the four voices. This sometimes gives an arpeggiated result rather than a canon impression.
Of these, about 400 are at least « listenable » and about 120 have something I find interesting about them. The discarded ones are by no mean completely worthless, they sometimes are just bland or the source chorale doesn’t translate well into strict canon.
The evaluation process simply gives an arbitrary value to desirable features such as three or four notes chords while down-voting things like consecutive fifths and minor second intervals. This is purely heuristic, but I found it works quite well. Favoring all four note chords sometimes give rise to more modern harmonies as well.
I give here a number of examples, grouped by the instrument used, since the pieces are short, as are the sources chorales. All use stock presets unmodified.
1. To illustrate the complete process, here is a file with first the source harmonized chorale on the Blanchet harpsichord, followed by a canon rendering on the Vintage Tines R2, just to show how different the result can be from the source, this being a rather extreme example:
http://www.forum-pianoteq.com/uploads.p...o_R2_2.mp3
2. On piano, here are three examples, first a three-part invention, then two more jazzy pieces on the U4. The invention was initially four-part but I removed the tenor to clarify the voicing (as Bach did in his)
http://www.forum-pianoteq.com/uploads.p...o_U4_3.mp3
3. Of course, sometimes the contrapunctal nature of the canon is more obvious so here are two examples on the harpsichord:
http://www.forum-pianoteq.com/uploads.p...chet_2.mp3
4. In a more intimate or improvisation mood, here are three examples on the Kremsegg Streicher, the sound of which is interestingly vintage, I find.
http://www.forum-pianoteq.com/uploads.p...cher_3.mp3
5. Most of the pieces are very well tailored to the vibraphone’s sound. Here are two on the V-M:
http://www.forum-pianoteq.com/uploads.p...hone_2.mp3
6. My (current) favorite instrument, the Kremsegg Bechstein, has a nice midrange and works well for pieces where the harmony is more prominent than the counterpoint. Here are three examples:
http://www.forum-pianoteq.com/uploads.p...tein_3.mp3
I used a heuristic to humanize the generated velocities so as to follow the natural melodic tendency of the four voices inside their vocal range and have a less mechanical result. No pedalling though, this is a hard feature to add.
Since all the chorales have a german text attached, all these canons could be sung as well! Brahms, for instance, published a great vocal work consisting of all canons, see here:
https://www.youtube.com/watch?v=3HSFYQ2Nuvc
Finally, sometimes using orchestra instruments can enhance a result. Here is a rendering of the second Streicher example using the stock brass section samples of GarageBand:
http://www.forum-pianoteq.com/uploads.p...ection.mp3
I also used baroque pipe organ samples with very good results.
Sorry for the long post, I hope some of you find this work interesting. I used the regular forum instead of the music creation section because this is not really performed music, but I guess it really belongs there...