DeepBach Uses ‘Deep Learning’ To Create Music In The Style Of Bach

Flow Machines, a research project that has been exploring using ‘deep learning’ to analyze and model ‘style’, shared this example of DeepBach – using the process to create music, harmonized in the style of Bach.

The above example is a reharmonization of Wer nur den lieben Gott läßt walten (He who allows dear God to rule him), a 1641 hymn by Georg Neumark. generated by DeepBach and played by Emmanuel Deruty.

DeepBach, developed by Gaëtan Hadjeres, Sony CSL et UPMC, is an example of how artificial intelligence promises to bring new tools to music theory and composition. 

Here’s what Flow Machines’ Gaëtan Hadjeres & François Pachet have to say about DeepBach:

The composition of polyphonic chorale music in the style of J.S Bach has represented a major challenge in automatic music composition over the last decades. The art of Bach chorales composition involves combining four-part harmony with characteristic rhythmic patterns and typical melodic movements to produce musical phrases which begin, evolve and end (cadences) in a harmonious way. To our knowledge, no model so far was able to solve all these problems simultaneously using an agnostic machine-learning approach.

This paper introduces DeepBach, a statistical model aimed at modeling polyphonic music and specifically four parts, hymn-like pieces. We claim that, 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. We evaluate how indistinguishable our generated chorales are from existing Bach chorales with a listening test. The results corroborate our claim.

A key strength of DeepBach is that it is agnostic and flexible. Users can constrain the generation by imposing some notes, rhythms or cadences in the generated score. This allows users to reharmonize user-defined melodies. DeepBach’s generation is fast, making it usable for interactive music composition applications. Several generation examples are provided and discussed from a musical point of view.

Here are two more examples, two reharmonizations of God Save The Queen:

Does DeepBach pass the ‘Musical Turing Test’?

In tests with 1,600 listeners, of whom about a quarter were trained musicians, more than 50% thought examples of DeepBach’s work were actually written by Johann Sebastian Bach.

Turing originally proposed that an artificial intelligence would exhibit human behavior if it was indistinguishable from actual human behavior to 70% of the people evaluating it. So, while DeepBach isn’t there yet, it’s getting close.

Check out the examples and let us know in the comments what you think of the promise of artificial intelligence applied to music!

26 thoughts on “DeepBach Uses ‘Deep Learning’ To Create Music In The Style Of Bach

  1. I would suspect that somewhere around 0% of people who actually listen to Bach would mistake these interesting experiments for actual Bach harmonizations.

  2. I am incredibly impressed, and so very intrigued about AI-generated music for the future.

    I don’t care if “Bach fans” would think it’s Bach or not. I actually enjoyed these pieces, and am fascinated at the work Gaëtan Hadjeres & François Pachet are doing.


  3. This is impressive. Though, there are a few little moments that sound like “bold” harmonic choices that stretch beyond what I expect from Bach; generally the AI seems to have absorbed the basic way things move. The reharmonizations of GS the Q are fun to listen to. I like that they stretch well beyond the original key center then trounce right through the flower beds to get back to the original key.

    1. So bold, they hurt me (is funny, isn’t it?, how dissonance can feel almost like physical pain?). That never happens with Bach, even when his work is full of tonal shifts. The art of modulation -in the classical sense- seems to be too subtle for this machine.

      1. There are plenty of dissonances and jarring chromaticisms in Bach, but people do tend to listen to his more accessible stuff.

        I think this software analyzed all of his chorales to get it starting point, which, without weighting, might result in more varied harmonies than many would expect.

        1. “There are plenty of dissonances and jarring chromaticisms in Bach”…I thought I already implied that. Is not about if tonal changes and chromaticisms are or aren’t there, it’s about how are they used/accomplished. The theory at least is you have to use common chords and some other inter-tonal relationships to make the transitions smooth and barely noticeable…but I suspect theory doesn’t cover it all and the composer intuition may play a big role also.

          But, now that I think about it, there’s this thing about the chorales: they are based on texts -they are musical illustrations in a way. And modulation there (any change of “mood”) should be related to a change in the content of the text. The idea that all of Bach music is a perfect and ideal expression of self-contained “pure music” is wrong. All his sacred work -and that’s most of his work, chorales included- is highly expressive and rethorical.

    2. It a reharmonisation of Georg Neumark and not Bach? Though very impressive, I wouldn’t call this a good representation of Bach.

      This isn’t that new, is it? David Cope has been doing this stuff for 2 decades. “Experiments in Musical Intelligence”

  4. *Can* a machine mimic human music, art and literature? Yes, absolutely.

    *Should* a machine mimic human music, art and literature? I would suggest “no”. Automation and intelligent programs are replacing an increasing amount of jobs, and it seems as though in the end humans won’t much to pursue aside from their intellectual pursuits, such as music, art and literature. I suspect if these pursuits fall under automation and intelligent programs as well that the remaining option of passively experiencing entertainment, such as just listening to music or playing games, will not appeal to a large amount of the population, leading to widespread social unrest and resistance. But I guess maybe we’ll see.

  5. A big part of what makes ‘art’ beautiful is knowing that an actual human created it through a process that requires practice, skill, and struggle. When you remove the human element, it diminishes the specialness of the work, because we all know that a machine can replicate things endlessly with no effort. And, machines/computers can only mimic what they’ve been programmed to, by humans! Sure, you can write a program that will generate ‘art’ randomly, but it will never be seen as the work of a brilliant mind that inspires and connects with other humans. There will never be an awe inspiring tale of creation that comes from a computer attempting to replicate the human spirit.

    1. But it could inspire a human to explore a musical territory he/she might not have seen, and then produce art to connect with people/spirit. I see this as useful tool.

    2. Your insightful summery outlines exactly why I no longer like computer animation movies. Pixar was neat, innovative & novel, but now with Disney & Dreamworks churning out shite every other six months, the medium has lost it’s soul. They all look the same. Who makes what now? It doesn’t matter. As long as parents have something to shove their spawn in front of to keep them still for 120 minutes. Music has been headed the same way for the past 15 years. Now with holographic singers & interchangeable boy bands…. It’s a time consuming struggle to find music with soul. It’s out there….

  6. What an interesting tool! I wouldn’t use it without massaging every bar, however. I do think it holds promise as an arranging aid, but will not replace education, experience, and commitment, by any stretch of the imagination. Next, lets invent better models for compensating creatives. There will always be room for spirit-connected humans who can tell a story, whatever tech is used.


  7. Fascinating comments. Thanks for sharing your thoughts.

    I imagine there was quite a bit of human creativity that went into programming this beast, In use, it will, like humans, be at least somewhat derivative. It may be possible also that a computer could generate things that were not so derivative, or at least blending unusual combinations of styles.

    I suppose some drummers have lost work to drum machines; some live bands have lost gigs to recordings, some orchestral players have lost gigs due to samplers, and now, some composers are losing gigs to Garageband loops and this kind of technology. It is what it is. And it will be a mixed bag of consequences.

    Fortunately, the fun of learning and making things will continue on.

    1. I suppose in the end some programmers will lose work because software will write itself, mmm. I think, without being too hyperbolic, we should ask ourselves if we need machines to do what makes us human and replace what is valuable to us.

      1. I don’t think this is ultimately about “needs”, except in the grand sense that humans have a need to make the world a playground, a dump, a laboratory, a pit toilet, a garden, an abattoir.

        The question we should probably ask ourselves is will we look at the big picture?

  8. This has been researched for quite a while and David Cope’s EMI from 1981 is an example of stylistic modelling that’s been possible for many years. These guys are just using a different method to achieve the style of Bach. The machine AI vs. Human argument is very complex and hard to have a simple answer for. Defining what “Art” can be almost seems elitist in even discussing it. There are plenty of advantages of creating AI algorithms to model music. In many ways it’s not necessarily to replace humans, but to research who we are when we create. Many tend to forget that music composition can be seen a system of organizing timbres for a temporal aural experience. To some music is entertainment, for others it may be ritualistic or not even what most would call music at all. Some music can be purely research based also. Just because some humans label something as “Music” doesn’t necessarily mean that it is good or bad. The listener can decide.

    As for what this post is about, I don’t think their intension is to have composers replaced by AI. It seems more of a study. Besides, there aren’t that many composers writing Baroque these days.
    However, there are composers using algorithms in their compositional practices. If you look into the works of Schoenberg, Xenakis, to Autechre etc. you can see how process has become key to their style of composition.
    Some composers use Markov Chains, Multi-Agent systems, Neural Networks, as computational tools to explore new possible ideas. The composer is still in the mix.

    What gets lost in the discussion is what aesthetic decisions an AI system could have. We can create AI to model styles that humans have liked for years but what’s more interesting, is if an AI can have its own aesthetic preferences. What if an AI system was the curator and composer. If it could have a bad day vs. a good one and if it could care less about human aesthetics and write based on its own taste. It still takes humans to make algorithms that explore AI music composition. It’s what some researchers call meta-creation and I find it quite interesting.

    1. Thanks for setting the record straight. I was expecting that I had to write a sort of related work / history section that is sadly lacking original article here to provide the necessary context. I’m not a big fan of the way that machine learning (a form of applied statistics, not learning as a human being knows it) is hyped by all sorts of media outlets. Or if it is not hyped (as is the case with this article) the context is lacking and readers are led to believe that there is more to it than there actually is. It is natural to explore and re-explore different applications of machine learning techniques and work on new or improved methods. That is science. But the hype surrounding the science sets up the whole field for a deeper and deeper fall once the science hits a brick wall and the frequency of impressive results (like Google Go to name just one example) decreases.

  9. Can an elephant paint a picture that expresses something that touches you?
    Is a random Bach muzack remix something unique?
    Are random words generated in the style of Shakespeare funny?

  10. Ha, let him have created an algorithm for writing the techno or IDM
    I think it would not have happened, too much would have to analyze. So that – all this nonsense.

Leave a Reply

Your email address will not be published. Required fields are marked *