Controllable Music Production with Diffusion Models and Guidance Gradients

Mark Levy, Bruno Di Giorgi, Floris Weers, Angelos Katharopoulos, Tom NicksonarXiv 2023

Abstract

We demonstrate how conditional generation from diffusion models can be used to tackle a variety of realistic tasks in the production of music in 44.1kHz stereo audio with sampling-time guidance. The scenarios we consider include continuation, inpainting and regeneration of musical audio, the creation of smooth transitions between two different music tracks, and the transfer of desired stylistic characteristics to existing audio clips. We achieve this by applying guidance at sampling time in a simple framework that supports both reconstruction and classification losses, or any combination of the two. This approach ensures that generated audio can match its surrounding context, or conform to a class distribution or latent representation specified relative to any suitable pre-trained classifier or embedding model.

Introduction

While AI models have become remarkably good at generating music from text prompts, they often lack the "surgical" control required for professional music production. Tasks such as extending a drum loop, inpainting a vocal track, or creating a harmonically perfect transition between songs require precise constraints. Most existing systems require task-specific training on paired data. This paper proposes a method to use a single pre-trained generative model and apply constraints on-the-fly via "guidance gradients."

Methodology

The authors explore two diffusion architectures: Waveform Diffusion (raw audio) and Latent Diffusion (LDM) (compressed VAE representation). The core mechanism is Guidance Gradients, which formalizes conditional sampling as a multi-objective optimization. At each denoising step, the model balances a prior objective (realism) with a constraint objective (e.g., matching surrounding audio).

By calculating the gradient of the constraint and using it to "nudge" the audio at every step, the model generates content that satisfies specific production needs, such as matching the rhythm and key of a surrounding track.

Key Results

Smooth Transitions

A key application is the creation of musical transitions. Unlike standard crossfades, this method generates new content that bridges the harmonic and rhythmic gap between tracks. Analysis of Mel-spectrogram distances shows that the distance increases linearly, implying smooth transitions, although ML-generated transitions start at a non-zero distance due to imperfect reconstruction by the VAE.

Average mel-spectrogram distance of generated transitions, showing linear increase and non-zero start due to VAE reconstruction.

Subjective Evaluation

In blind head-to-head preference tests, the Latent model was preferred over the Waveform model and baselines by a significant margin across all tasks (Infill, Regenerate, Continuation, Transition, and Guidance).

Subjective evaluation results showing the number of wins for each model class across various music production tasks.

Discussion and Limitations

The Latent Diffusion Model consistently outperformed the Waveform model, likely because its compressed representation better captures high-level musicality. However, the VAE introduces a slight loss in quality, preventing bit-perfect reconstruction. Additionally, the Waveform model is highly sensitive to guidance step sizes, and the iterative gradient calculation adds computational cost compared to standard generation.

Conclusion

This research demonstrates a versatile, zero-shot framework for controllable music production. By applying guidance gradients to pre-trained diffusion models, researchers have enabled professional-grade audio editing tasks—like seamless transitions and style transfer—without the need for specialized training data.

Summary updated

BibTeX
@misc{levy2023controllable,
  author = {Mark Levy and Bruno Di Giorgi and Floris Weers and Angelos Katharopoulos and Tom Nickson},
  title = {{Controllable Music Production with Diffusion Models and Guidance Gradients}},
  year = {2023},
  eprint = {2311.00613},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2311.00613},
}
Figure