The Algorithm of Music
Baroque composer Johann Sebastian Bach is known to have written many chorale cantatas, polyphonic hymns based on Lutheran texts. Each is fairly simple, featuring a single melody accompanied by three harmonies, so Gaetan Hadjeres and Francois Pachet from Sony Computer Science Laboratories in Paris thought it would be interesting to see if a machine could create chorale cantatas indistinguishable from Bach’s.
To find out, they developed a neural network they called DeepBach, and now they have an answer to their question. “After being trained on the chorale harmonizations by Johann Sebastian Bach, our model is capable of generating highly convincing chorales in the style of Bach,” Hadjeres and Pachet told MIT Technology Review.
DeepBach was trained using a data set of 352 Bach cantatas that were transposed to other keys within a predefined vocal range to create a total of 2,503 chorales. Of these, 80 percent were used to train DeepBach and the rest to validate it. After training, DeepBach was able to produce its own harmonies for alto, tenor, and bass in the style of Bach when given a soprano melody.
Most importantly, DeepBach’s compositions even fooled people. The team asked more than 1,600 people — a fourth of whom were professional musicians or music students — to listen to two distinct harmonies of the same melody. The results showed that more than half the listeners attributed DeepBach-generated harmonies to Bach, while music by Bach was correctly identified by 75 percent of the listeners. “We consider this to be a good score knowing the complexity of Bach’s compositions,” said Hadjeres and Pachet.
What You Can Do, AI Can Do
Artificial intelligence (AI) can get into just about anything, but it’s particularly well-suited to anything mathematical — if there’s math in it, chances are you can develop an algorithm for it. Music is mathematical, and composers like Bach often made music that followed a defined, step-like flow that is almost algorithmic.
Interestingly enough, Bach’s music makes it into “Westworld,” a TV series that exploits the topic of AI. However, music isn’t the only field where AI algorithms have performed considerably well, even outperforming actual people in some cases. There are speech-recognition algorithms that outperformed human experts; psychologist AI that predicted suicidal patients, depressive behavior, and criminality; and there’s even AI dabbling in law.