Machines who play (and compose) music

Ages ago I decided to take up a musical instrument. As a child and young boy I had violin lessons, and achieved a certain level of proficiency. But then in my late teens this string instrument was not in. Bob Dylan and Joan Baez were, and I decided to learn to play the guitar. Due to my early childhood exposure to classical music it had to be gut guitar, like the instruments my great heroes Andrés Segovia, John Williams and Julian Bream played — not the 32-string rock variety.

So I went to a well-known classical guitar teacher named Lindemann in Hamburg. After an interview he said he could not take me on, because I was way below his level of teaching. I was hurt and upset, but then I got to know a very young and very talented guitarist, who played and composed. Sonja started giving me lessons —she taught me the strings. A year or so later I met Lindemann at a musical meeting, where I played Bach’s famous Bourrèe. He was impressed: “So you found a good teacher? Who was it?” “Sonja,” I said, in plonking tones. You see, this girl was his teacher. It was a wonderful triumph and I had to tell you about it.

Sonja went on to become an eminent professor of classical guitar. My friendship with her lasted a number of years, and during that time computers were invented. Actually the first Commodores and Ataris became available, and I experimented vigorously with them. When I discovered that I could make them play musical notes — just sinus wave sounds, actually — I wrote a program to execute the pieces I was playing on the guitar. At this stage Sonja came over for a lesson, and I showed her what my Commodore could do.

Sonja was shocked. “So this is going to put me out of my profession?” she said. No, not for a long time, Sonja — if ever. But my playing piece after piece for her on the computer did not alleviate her fears. Until she at last began to find grounds for criticism: “It’s too mechanical,” she said, “Humans play differently, there is more variation of individual notes.” So I put in a random number of milliseconds before and for the length of each note. That gave her a few minutes of pause. “It’s too much hesitation, too much random variation” she objected at last.

So I reduced the range of the random numbers. All of this was being executed in minutes. “Okay, that’s better, but we humans vary intervals according to the speed of the passage,” and tried to explain specifically when humans play faster and when they slow down. That took maybe half an hour to implement. Then came stress, which took another half-hour to teach the computer to do. In the end she gave up and was thoroughly depressed. I made her play a number of classical pieces on her guitar, to help restore her faith in human superiority. There was a world of difference from the beeps and feeps emanating from my Commodore.

What I had been doing thus far was getting a computer to reproduce classical pieces. The next step was to try to teach it to actually compose music — the classical variety. I did not know very much about harmony and counterpoint (at which Bach excelled), about rhythm and contour. So I tried taking existing pieces and varying them automatically, using a number of different algorithms. But the resulting pieces were not really like Bach. So I gave up.

Many years passed, and then I discovered David Cope. He was an American professor of music at the University of California who was experimenting with artificial intelligence and music composition. The programs he wrote would analyse classical music and then compose pieces in the style of that music.

Image for post
Image for post

On his home page we find a description of how he got into this:

I began Experiments in Musical Intelligence in 1981 as the result of a composer’s block. My initial idea involved creating a computer program which would have a sense of my overall musical style and the ability to track the ideas of a current work such that at any given point I could request a next note, next measure, next ten measures, and so on. My hope was that this new music would not just be interesting but relevant to my style and to my current work. Having very little information about my style, however, I began creating computer programs which composed complete works in the styles of various classical composers, about which I felt I knew something more concrete.

I could write an extensive description of the work Cope embarked on, but this has been done in superb fashion by Yuval Noah Harari in his book Homo Deus: A Brief History of Tomorrow. If you haven’t read that book, order it today, together with the first part, Sapiens: A Brief History of Humankind. They are possibly the most important purchases you will make this year.

Harari writes (given here in excerpts):

David Cope has written programs that compose concertos, chorales, symphonies and operas. His first creation was named EMI (Experiments in Musical Intelligence), which specialised in imitating the style of Johann Sebastian Bach. It took seven years to create the program, but once the work was done, EMI composed 5,000 chorales à la Bach in a single day. Cope arranged a performance of a few select chorales in a music festival at Santa Cruz. Enthusiastic members of the audience praised the wonderful performance, and explained excitedly how the music touched their innermost being. They didn’t know it was composed by EMI rather than Bach, and when the truth was revealed, some reacted with glum silence, while others shouted in anger.

You can listen to EMI Bach chorales, and to Vivaldi, Chopin, Beethoven, and others on this page.

Critics argued the music is technically excellent, but that it lacks something. It is too accurate. It has no depth. It has no soul. Professor Steve Larson from the University of Oregon sent Cope a challenge for a musical showdown. Larson suggested that professional pianists play three pieces one after the other: one by Bach, one by EMI, and one by Larson himself. The audience would then be asked to vote who composed which piece. Larson was convinced people would easily tell the difference between soulful human compositions, and the lifeless artefact of a machine. Cope accepted the challenge. On the appointed date, hundreds of lecturers, students and music fans assembled in the University of Oregon’s concert hall. At the end of the performance, a vote was taken. The result? The audience thought that EMI’s piece was genuine Bach, that Bach’s piece was composed by Larson, and that Larson’s piece was produced by a computer.

I have followed the work of David Cope over the years, but never got to meet him personally. That will change in two months from now, I am determined, when I attend a function in Palo Alto. That is a cat’s leap (as we say in German) from David’s place of residence, and thus he will have a tough time avoiding my visit.

Ludwig

Before I finish I want to mention that in part two of this piece I will be telling you about Ludwig. That is an AI music software suite developed by Matthias Wüllenweber, with whom I founded the chess software company ChessBase, back in 1987. Matthias is the programming brains behind our products. He is also a music aficionado. At some stage he discovered that the search algorithms he was using for chess are also applicable to the composition and arrangement of music. So he took a break and created Ludwig. Let chess grandmaster Danny King explain how it works.

And here is Ludwig arranging Bach’s “O Haupt voll Blut und Wunden” as a classical four-part arrangement, applying around 50 rules of music theory and writing an independent and pleasing bass line in the process.

The demonstration is in German, but it is easy to follow the gist.

So Ludwig is a program that helps you to write your own songs, making them highly presentable. You simply enter or play a melody —the computer does the rest: it finds the proper chords and writes all parts of a professionally sounding band. It has never been easier to compose, arrange or accompany songs: you can choose from a broad variety of styles — apart from classical it allows you to select Pop, Pop Ballad, Rock, Rock Ballad, Big Ballad, Funk, Disco, House, Jazz Combo, Fast Swing, Samba, Salsa, Rumba, Beguine, Tango, Klezmer, Folk, Polka, March, and many others. You can even define your own styles. And if you don’t want to or can’t enter your own melodies just load them from a database of many hundreds of public domain songs that are included in the package. You can download and try Ludwig 3.0 here.

Written by

Frederic Alois Friedel, born in 1945, science journalist, co-founder of ChessBase, studied Philosophy and Linguistics at the University of Hamburg and Oxford.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store