Source-linked AI summary
DeepBach: a Steerable Model for Bach Chorales Generation
Gaëtan Hadjeres, François Pachet, Frank Nielsen
TL;DR
DeepBach targets the challenge of generating convincing Bach-style chorales while allowing users to impose musical constraints. It combines a dependency network with Gibbs-like sampling and a voice-aware representation, producing results authors describe as musically convincing and supporting interactive composition. The paper also notes that its sampling conditionals need not define a stationary joint distribution.
Problem
Generating Bach-like reharmonizations requires coordinating simultaneous harmony, melodic voice movements, and stylistic coherence, while sequential neural models do not support interactive constraints such as reharmonization.
Method
DeepBach is a dependency network that uses Gibbs-like sampling, separate voice modeling, metadata, and unary constraints on musical positions.
Results
DeepBach generates musically convincing four-part Bach-style chorales and supports varied reharmonizations, with more than half of its tested extracts receiving majority Bach votes versus one third for MLP extracts.
Takeaways & Limitations
Its interactive graphical interface makes constrained polyphonic composition accessible to non-specialists and supports a constructive dialogue between user and computer.
Takeaways & Limitations
The sampling conditionals may be incompatible, so the Markov chain lacks theoretical convergence guarantees to a stationary joint distribution.
Abstract
from arXiv · showhide
This paper introduces DeepBach, a graphical model aimed at modeling polyphonic music and specifically 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. DeepBach's strength comes from the use of pseudo-Gibbs sampling coupled with an adapted representation of musical data. This is in contrast with many automatic music composition approaches which tend to compose music sequentially. Our model is also steerable in the sense that a user can constrain the generation by imposing positional constraints such as notes, rhythms or cadences in the generated score. We also provide a plugin on top of the MuseScore music editor making the interaction with DeepBach easy to use.
1. Introduction
Automatic Bach-chorale composition must coordinate harmony, voice movements, and stylistic coherence. DeepBach addresses limitations of rule-based and sequential neural approaches with Gibbs-like sampling and user-steerable constraints.
- Bach chorale reharmonization requires intricate coordination between simultaneous harmony, individual voice movements, and each voice’s coherence.
- Rule-based systems can produce occasional flawless examples but require extensive handcrafted rules and do not consistently sound like Bach.Ebcioglu’s system used more than 300 rules and generate-and-test with intelligent backtracking.
- Neural-network and HMM approaches decompose generation into stages or represent chords as interval lists, while relying on expert knowledge and compositional bias.
- Agnostic piano-roll neural models learn temporal dependencies with RNNs, LSTMs, or GRUs but generate left to right and do not support user interaction such as reharmonization.
- DeepBach uses a dependency network with Gibbs-like sampling to generate convincing four-part Bach-style chorales without left-to-right sampling.
- The model supports positional unary constraints on rhythms, notes, parts, chords, and cadences, and is presented with an interactive editor for non-expert composition.
2. DeepBach
DeepBach represents chorales with separate voices and metadata, then models their dependencies for probabilistic generation. Its architecture is intended to support flexible sampling and reflect compositional practice.
- DeepBach uses a representation that separates four voices from metadata and is designed to fit its sampling procedure.
2.1. Data Representation
DeepBach encodes four voices on a sixteenth-note grid, adds hold symbols for rhythm, and supplies metadata for beat subdivision and fermatas. The representation is compact and tailored to chorale structure.
- 2.1.1. NOTES AND VOICES: Notes are encoded as MIDI pitches, voices are modeled separately, and chorales with voice divisions are discarded.
- 2.1.1. NOTES AND VOICES: Time is discretized into sixteenth notes, dividing each beat into four equal parts without losing information in Bach chorales.
- 2.1.1. NOTES AND VOICES: A hold symbol records whether the preceding note continues, yielding an unambiguous and compact rhythm representation suited to sampling.
- 2.1.3. METADATA: The representation includes an implicit metronome, fermata symbols, and the current mode as possible sheet-music information.
- 2.1.3. METADATA: The implemented metadata retains fermatas, subdivision indexes, and key signature information.
- 2.1.3. METADATA: The fermata list F is Boolean and remains active across all time indexes covered by the note carrying the fermata.
- 2.1.3. METADATA: The subdivision list S uses integers from 1 to 4 and does not distinguish beats within a bar, allowing three- and four-beat measures.
- 2.1.4. CHORALE: A Bach chorale is represented as four voice lists—soprano, alto, tenor, and bass—together with metadata lists F and S.
2.2. Model Architecture
DeepBach predicts each voice’s note from neighboring notes, beat subdivision, fermata information, and other voices at the same time. Its architecture combines past and future recurrent context with simultaneous-note processing.
- Each conditional model predicts a voice’s note from neighboring notes, beat subdivision, fermatas, and other voices at the same time.The prediction target is restricted to a small range of notes matching the usual vocal range.
- Four neural networks combine past context, future context, same-time information, and the merged prediction.The first three outputs feed a fourth network whose output is p_i(V_t^i|V_\i,t, M, θ).
2.3. Generation
DeepBach generates chorales with pseudo-Gibbs sampling, repeatedly resampling individual voice-time variables. The procedure supports user constraints and can be accelerated through parallel GPU updates, while relying on a data representation designed for effective sampling.
- 2.3.1. ALGORITHM: The conditional distributions may be incompatible, so the chain is not guaranteed to converge to a stationary joint distribution matching them.The authors report that the chain violates Kolmogorov’s criterion and is therefore not reversible.
- 2.3.1. ALGORITHM: The chain nevertheless converges to another stationary distribution, and prior real-data applications found accurate joint probabilities when distributions were learned from data.The paper also notes that nonreversible MCMC can sometimes sample better than reversible chains.
- 2.3.2. FLEXIBILITY OF THE SAMPLING PROCEDURE: Generation can enforce fixed voices, rhythms, chords, fermata locations, metadata, vocal ranges, and subsets of allowed notes.These constraints are implemented by modifying the resampling procedure or restricting its candidate values.
- 2.3.1. ALGORITHM: Pseudo-Gibbs sampling initializes four voice lists and repeatedly resamples a randomly selected voice at a randomly selected time.The algorithm outputs the four updated voice lists after a fixed number of iterations.
- 2.3.3. PERFORMANCE: Small-batch parallel GPU updates produced samples of great musicality while running ten times faster than sequential sampling.This speedup allows DeepBach to generate chorales in a few seconds, despite the known bias from simultaneous updates.
- 2.3.4. IMPORTANCE OF THE DATA REPRESENTATION: Integrating a hold symbol into the note list makes pitch changes possible through one variable change instead of simultaneous changes across many variables.The representation is intended to reduce trapping in isolated high-probability regions during sampling.
2.4. Implementation Details
DeepBach is implemented and evaluated using a filtered corpus of Bach chorales, transposed to augment the training data. The model uses local context and a specified neural architecture, while weight sharing did not improve validation accuracy or musical quality.
- After filtering instrumental parts and voice divisions, the corpus contains 352 Bach chorales.The implementation uses the chorale harmonizations included in the music21 toolkit.
- The model uses local context around each target note, with reported results obtained using Δt = 16.The authors justify the approximation by noting that Bach chorales lack clear long-term dependencies.
- The neural-network brick has one hidden layer of size 200 with ReLU, while the Deep RNN brick has two stacked LSTMs of size 200.The implementation also applies 20% input dropout and 50% dropout after each layer.
- Sharing weights between the left and right embedding layers improved neither validation accuracy nor the musical quality of generated chorales.
3. Experimental Results
DeepBach was evaluated against Maximum Entropy and MLP baselines using human “Bach or Computer” judgments. Its extracts received more Bach votes as model complexity increased, while musical expertise improved discrimination.
- 3.1. Setup: The study compared DeepBach with Maximum Entropy and MLP models using an online human-listener test.All models were local and used the same scope; the Maximum Entropy model had no hidden layer, while the MLP used one hidden layer of size 500.
- 3.1. Setup: 400 extracts were created by reharmonizing 50 validation chorales with three models and presenting four versions of each melody chunk.The soprano remained fixed across models, while generated alto, tenor, and bass parts were rendered so they could be distinguished and dissonances heard.
- 3.2. Discrimination Test: “Bach or Computer” experiment: The percentage of “Bach” votes increased with model complexity, and expert listeners more accurately distinguished computer-generated extracts from Bach’s extracts.The experiment grouped votes by model and voter expertise level from 1 to 3.
- 3.2. Discrimination Test: “Bach or Computer” experiment: Around 50% of voters judged a DeepBach-generated extract as composed by Bach.The authors characterize this as a good score given the complexity of Bach’s compositions and the detectability of badly sounding chords, even for non-musicians.
- 3.2. Discrimination Test: “Bach or Computer” experiment: More than half of DeepBach’s automatically composed extracts received a majority of Bach votes, compared with only a third for the MLP model.Figure 6 reports the percentage of Bach votes for each of the 100 extracts for each model.
4. Interactive composition
The MuseScore plugin lets users invoke DeepBach on selected score regions for generation and reharmonization. Interactive versions add note spelling and key-signature metadata, while examples show Bach-like patterns alongside compositional errors.
- 4. Interactive composition: The MuseScore plugin lets users call DeepBach on any rectangular region of a score.Users can generate a chorale from scratch, reharmonize a melody, or regenerate a chord, bar, or other part.
- 4. Interactive composition: The interactive tool changed note encoding from MIDI to full note names to preserve enharmonic spelling.This enables correctly spelled generated notes, which matters when focusing on the written score rather than only its audio rendering.
- 4. Interactive composition: Adding the current key-signature list to metadata allows users to impose modulations and key changes.Each bar’s estimated key records an integer number of sharps from -7 to 7.
- 4. Interactive composition: Example generations covered all four voices and regions longer than one bar without manually setting notes.The examples were intended to demonstrate the quality of solutions produced by the DeepBach plugin.
- 4. Interactive composition: The compositions reproduced characteristic Bach-like cadences, nonchord tones, and correct note spelling despite errors such as parallel octaves.Examples sharing the same metadata could still produce contrasting chorales.
- 4. Interactive composition: The provided extracts were sung by the Wishful Singing choir so they could not be distinguished from actual Bach compositions by the intended presentation.The resulting audio files were made available on the accompanying website.
5. Discussion and future work
DeepBach combines a flexible probabilistic model with an interactive MuseScore plugin, enabling user-guided polyphonic composition. The authors identify interface refinement, faster generation, and support for small corpora as future work.
- DeepBach is described as flexible, efficient, and musically convincing, including to professional listeners.
- The method lets users impose unary constraints, making polyphonic composition accessible through a graphical interface.
- The approach is presented as a constructive dialogue between a human operator and the computer.
- The method is intended to extend beyond Bach chorales to a wider range of polyphonic music.
- Future work targets interface refinement, faster generation, and datasets with small corpora.