Sunday, 4 March 2012

Artificial Intelligence Composers: Can computers write music?

Music seems to be such a human thing, and, although as we’ve shown in our previous posts it does follow mathematical patterns, a computer couldn’t ever write good music could it? And if it could we’re miles off, right? Think again.

Much work has been done on Artificial Intelligence, particularly in Linguistics, but very little has been done in other, more creative areas, such as music. This is partly because it is difficult: there are no set rules to program; such programming would require great musical insight from the coder, and partly because of the emotional effect that music has on people. All advanced musicians achieve the standard they do because they feel the emotion in pieces, and because they put those emotions into their own performance and writing. Artificial Intelligence challenges that. Computers (as of yet) don’t have feelings: they don’t have emotions. How could a computer write music successfully when it had no emotional message to send? There were not many musicians who believed that this field would lead to any results.

One man who did believe, however, is David Cope. Born in 1941, he was a conventional composer, with a huge passion for music. However, when commissioned to write an opera in 1980, he suffered from a terrible case of writer’s block. He had hit a complete creative dead-end.

Desperate, he had the idea of creating a ‘virtual David Cope,’ a computer programmed with certain rules that he tended to follow in his compositions to try and create new material, which he named “Experiments in Musical Intelligence,” or “Emmy” for short. It didn’t take long before he realised that this was simply too big a task, but he didn’t give up completely. He decided to try to code the computer to harmonise Bach chorales.

For those of you that don’t know, Bach chorales are 4-part vocal hymns that obey certain harmonic rules, (e.g. no parallel fifths or octaves, thirds fall, leading notes rise) and harmonising a single line into a full chorale is a common task for music students. The tight, rule based nature of it lent itself very nicely to automation, and it wasn’t long before the computer could accurately harmonise these chorales, following all the rules. However, the results were only of a level comparable to a mediocre music undergraduate, and could certainly not be compared with Bach himself. The music lacked drive, it lacked passion: it felt mass-produced.

David Cope realised that Bach didn’t always follow his own rules. When they needed to be broken, he broke them. But how do you tell a computer to break its own rules? How will it know when to do so?

This was Cope’s masterstroke. He input all 371 original Bach chorales into the computer, and got it to analyse them and derive its own rules. This approach is known as data-driven programming. The computer still needed to be told exactly what to analyse though! The initial results sounded good when played as extracts but lacked a logical pattern throughout the piece. To combat this, Cope came up with many ingenious analytical solutions: analysing how often a certain motif has been repeated, or how long a piece should remain in the same key. The results were astonishing. When first performed in 1987, it was played alongside genuine Bach chorales. The audience, full of musical and academic luminaries, were polled on which pieces were Bach’s and which were Emmy’s. They couldn’t tell the difference. One could argue that this means that Emmy passed the Turing test. Not only this, but Emmy was fast. She composed over 5000 chorales in half an hour, 15 times as many as Bach produced in his entire lifetime.

He expanded Emmy from the basic, prescriptive Bach chorales to incorporate many other, more complex composers, from Mozart to Scott Joplin, and even himself. Once again, many pieces were indistinguishable. Below are excerpts from two ‘Chopin’ Mazurkas, one genuine and one composed by Emmy. Can you tell the difference? Which one is genuine? We will tell you at the end which is Emmy, but how about you take the poll on the sidebar before you find out?

This has massive implications for many musicians. If a computer can write music just like, and as good as, theirs, then what is it that makes their music so great? Most identified with the soul and passion that they put into their works, but the computer can’t do this! The computer is just following mathematical patterns and algorithms. Does this mean that, ultimately, Mozart, Debussy, Beethoven, Chopin, and every other composer in the world were just subconsciously following similar algorithms?

 Cope’s answer is an unreserved yes. He says that the emotion isn’t in the music itself, but that it triggers the emotion in our own heads. As the songwriter Irving Berlin said, “Life is 10% what you make it, and 90% how you take it.” A human composer may feel they are putting in the emotion themself, because they are feeling that emotion whilst writing it, but the emotion is triggered in them in the same way it is triggered in the listener. A computer could trigger those notes in the same way. However, people’s perceptions are very important: people are very biased when it comes to computers and emotion. When one music professor was played a piece by a later version of Emmy at a concert, having not been told it was written by a computer, he described it as “one of the most intense musical experiences of my life.” However, a year later, when played a recording of that same piece at a presentation by Cope about his work, this time knowing it was computer generated, he said, “You know, that’s pretty music, but I could tell absolutely, immediately that it was computer-composed. There’s no heart or soul or depth to the piece.” For some people, the emotional origin of the music is important, for others it is only the result.

Cope found it difficult to get Emmy a recording contract. It was just so controversial that agents wouldn’t let their artists touch it. Many also felt that with so many thousands of pieces being generated by her, the pieces didn’t seem special enough. There was simply an overload.

Cope had to move on. In 2004, he deleted Emmy. He kept the original algorithm backed up, and a small sample of the database, but for all intents and purposes, she was gone. He replaced her with the more human sounding "Emily Howell," so named so that critics would not realise instantly that she was a computer. He used all of the scores used by Emmy as a starting point, and fed them in. Emily then has a musical conversation with Cope: she comes up with a phrase, and she responds to his positive or negative feedback. Emily learns his style, and gradually creates better and better music. Cope understandably does not want to give away to many of the precise details of how Emily works, but the results are truly amazing: original, moving music. Her first album, "From Darkness, Light", is available on iTunes and Spotify.

This music moves me deeply; I don't care that it comes from a computer. It is excellent, and innovative, it's just that a computer made it rather than a human.

Emily Howell doesn't just do pastiches, her style is recognisably unique, and adapts depending on Cope's feedback. For this reason, Cope feels that the program is essentially an extension of him: he is just teaching her his biases, and she is speeding up the job for him. In fact, she may be better at the job with him: the element of randomness in the rule-breaking is very important in music, and humans are notoriously bad at being random. Almost everything we do is extremely predictable. In a way, computers are better at coming up with original ideas than we are.

Emily Howell may make you look at music differently. Music is emotional for us, but that emotion comes from us, not from the music itself. The music merely triggers that. I write music to express emotions and feelings, but I listen to music to feel, myself, whether or not someone intended me to feel it. That's not important to me.

Emily Howell is an absolute miracle of AI. She is probably the first program that could really make people feel, that could bring people to tears, and Cope is a genius. He has found the essence of music, and reproduced it like never before, and we can only wait and see what he and Emily will do next. And by the way, the second of the two sound clips was Emmy.

We hope you enjoyed this post. If you have anymore questions, you can follow us on twitter, @theaftermatter, email us at or search "The Aftermatter"on Facebook. We really like hearing your feedback or just talking about the posts or other physics and maths. We hope you enjoyed this post.

Theo Caplan.

Check out our last two posts:
What is the Theory of Everything? (Part 1) - How can a theory describe everything? And are there moral implications if it can?
What are Imaginary Numbers? - What is a imaginary number? Surely a number, by definition, is a unit of measurement, and if it is, how can a number not exist?

What are we posting about next:
What Are Superconductors? - What impact will a wire with no resistance have on our society and our technology?

No comments:

Post a Comment