Deep-Learning Machine Listens to Bach, Then Writes Its Own Music in the Same Style
Can you tell the difference between music composed by Bach and by a neural network?
Johann Sebastian Bach is widely considered one of the great composers of baroque music. Bach lived and worked in Germany during the 18th century and is revered for the beauty of his compositions and his technical mastery of harmony and counterpoint.
One form of music that Bach excelled in was a type of polyphonic hymn known as a chorale cantata. These are based on Lutheran texts and sung by four voices. The composer starts with a well-known tune which is sung by the soprano and then composes three harmonies sung by the alto, tenor, and bass voices. Bach wrote over 300 short chorale compositions.
These compositions have attracted computer scientists because the process of producing them is step-like and algorithmic. But doing this well is also hard because of the delicate interplay between harmony and melody. That raises an interesting question: could a machine create chorales in the same style of Bach?
Today we get an answer thanks to the work of Gaetan Hadjeres and Francois Pachet at the Sony Computer Science Laboratories in Paris. These guys have developed a neural network that has learned to produce choral cantatas in the style of Bach. They call their machine DeepBach (see also “AI Songsmith Cranks Out Surprisingly Catchy Tunes”).
“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,” say Hadjeres and Pachet. Indeed, about half the time, these compositions fool human experts into thinking they were actually written by Bach.
The machine-learning technique is straightforward. Hadjeres and Pachet begin by creating a data set to train their neural network. They begin with 352 chorales composed by Bach and then transpose these to other keys that lie within a predefined vocal range, to give a data set of 2,503 chorales. They use 80 percent of these to train their neural network to recognize Bach harmonies and the rest to validate it.
The machine then produces harmonies of its own in the style of Bach. The team tests the device by giving it a melody, which it then uses to produce harmonies for three other voices, the alto, tenor, and bass.
While other algorithmic approaches can also do this, an important question is how well they all compare with Bach’s work. To find out, the team asked more than 1,600 people to listen two different harmonies of the same melody. More than 400 of them were professional musicians or music students. Each had to determine which of the two harmonies sounded more like Bach. The team also included harmonies produced by other algorithms in this test.
The results make for interesting reading. When given a DeepBach-generated harmony, around half the voters judged that it was composed by Bach. That’s significantly higher than with music generated by any other algorithm. “We consider this to be a good score knowing the complexity of Bach’s compositions,” say Hadjeres and Pachet.
Even when confronted with music composed by Bach himself, participants only judged that correctly 75 percent of the time.
That’s interesting work that has fascinating implications. If it is possible for a deep-learning machine to produce chorales in the style of Bach, then why not also in the style of other composers and perhaps even other styles of music?
That could provide an interesting way to analyze compositions and to study the nature of creativity. “This method is not only applicable to Bach chorales but embraces a wide range of polyphonic chorale music, from Palestrina to Take 6,” say Hadjeres and Pachet.
In many cases, that will be easier said than done. Bach’s chorales are highly structured and follow specific rules in their construction, albeit a great many of them. Other forms of music are not always so organized.
Nevertheless, deep-learning machines from Sony’s labs and elsewhere have begun to produce well-regarded pieces of music. It will come as no surprise if these machines soon begin to take on more ambitious works such as symphonies, operas, and more. Bach would surely have been amazed!
Ref: arxiv.org/abs/1612.01010: DeepBach: A Steerable Model for Bach Chorales Generation
Learn from the humans leading the way in intelligent machines at EmTech Next. Register Today!
June 11-12, 2019