Google’s next Doodle uses AI to generate music in the style of Johann Sebastian Bach

Google’s Doodles are often elaborate creations, but the upcoming Doodle to celebrate the birthday of composer Johann Sebastian Bach is positively baroque.

With the help of artificial intelligence, the interactive Doodle allows users to generate harmonies for any melody they input in the style of the famous 18th century composer. Google used machine learning to analyze the harmonies of more than 300 Bach compositions, replicating the patterns it found to fit the user’s suggested melody.

You can input short single-line melodies that are just two bars long and change the key of the music and its tempo. You can also download the resulting composition as a MIDI file or share it with friends. The Doodle also includes some hidden surprises. Click the mini amplifier to the right of the keyboard to upgrade the instruments to ‘80s synths.

Image: Google
Bach and friends in their ‘80s regalia.

The Doodle is a neat demonstration of both the possibilities and limitations of AI to generate music. As Anna Huang, a resident AI researcher with Google’s Magenta project who created the Doodle, explains to The Verge, the underlying AI model was trained on Bach’s chorale harmonizations, which are harmonizations of existing hymns.

This is particularly compliant data for AI to learn from, says Huang. “The Bach compositions in this dataset are highly structured, and the style is very concise, yet with rich harmonies, allowing machine learning models to learn more with less data.” It also helps that Bach is a composer of Baroque music: a highly formalized genre with consistent rules.

Huang, who studied music composition as an undergrad and grad, says she’s always looking for new ways to compose. AI gives her a tool that can fill in the missing parts of a piece, giving her new material to sculpt. “As a result, you can try out ideas more quickly, and see if you encounter something that sparks,” she says.

She also notes that as with other musical AI projects, this technology is far from a perfect composer. One thing machine learning generators struggle with, for example, is creating long-term structure and coherence. “What is harder to replicate is Bach’s balance in simplicity and expressiveness and the longer arcs in his music,” says Huang.

The Bach-inspired Google Doodle will go live 12AM ET on Thursday, March 21st, and it will be available for 48 hours across 77 markets. You can read more about the technology behind it here.

Update March 20th 3:00PM ET: Updated with additional comment from Magenta AI resident Anna Huang.