NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

MusicMagus: Zero-Shot Text-to-Music Editing via Diffusion Models

Yixiao Zhang, Yukara Ikemiya, Gus Xia, Naoki Murata, Marco A. Martínez-Ramírez, Wei-Hsiang Liao, Yuki Mitsufuji, Simon Dixon

TL;DR

MusicMagus is a zero-shot framework that enables precise, text-based editing of music—such as changing a piano to an acoustic guitar or jazz to classical—without requiring any additional model training. By combining a robust latent-space "editing direction" with cross-attention constraints, it preserves the original melody and rhythm while successfully transforming the musical style or timbre.

What Problem Does This Paper Address?

While text-to-music generation has seen massive leaps recently, editing that music remains a significant hurdle. If you generate a beautiful melody played on a piano but decide it would sound better on an organ, most current models require you to start from scratch, likely losing the original composition in the process.

Existing editing approaches generally fall into two camps:

  1. Supervised Models: These are trained on specific pairs of data (e.g., "piano version" vs. "guitar version"). They are effective but inflexible, limited only to the specific transformations they were trained on.
  2. Zero-Shot Diffusion: You can try to "re-generate" audio with a new prompt using the same random seed, but diffusion models are notoriously sensitive. Even a one-word change in a prompt can lead to a completely different structural output, destroying the original melody.

MusicMagus tackles intra-stem editing—modifying attributes like genre, mood, and instrument within a track—while maintaining "structural integrity" (the notes and timing) without needing specialized training data.

Methods

MusicMagus acts as a sophisticated wrapper around a pre-trained Latent Diffusion Model (LDM), specifically AudioLDM 2. Its workflow consists of two main innovations:

1. Finding the Editing Direction ($\Delta$)

Instead of simply swapping the word "piano" for "guitar" in a prompt—which can be brittle due to how language models embed single words—the authors use a "mean difference" approach.

  • They use InstructGPT to generate dozens of diverse captions for both the original concept and the target concept.
  • These captions are embedded using a FLAN-T5 encoder.
  • The difference between the average embeddings of these two sets defines a robust editing vector, $\Delta$.

As shown in Figure 2, this vector is added to the original text embedding to guide the diffusion process toward the new attribute.

Figure 2: The pipeline of finding the editing direction ∆. We first use InstructGPT to generate a large number of captions and then calculate the mean difference between the two embedding sets.

2. Cross-Attention Constraints

To ensure the melody doesn't drift, the authors look at the cross-attention maps—the internal mechanism that tells the model which parts of the audio "latent" correspond to which parts of the text prompt.

  • They first record the attention maps from the original generation.
  • During the editing process, they calculate an $L_2$ loss between the new attention maps and the original ones.
  • They then perform a gradient-based optimization step at every denoising interval to force the new generation to maintain the same structural "layout" as the original.

This process is visualized in the workflow diagram in Figure 3.

Figure 3

Datasets

Because MusicMagus is zero-shot, it does not require a training dataset. For evaluation, the authors curated two specific test sets:

  • Timbre Transfer: 60 samples generated by AudioLDM 2, focusing on pairs like (piano $\rightarrow$ organ) and (viola $\rightarrow$ piano).
  • Style Transfer: 50 samples covering conversions like (jazz $\rightarrow$ classical) and (country $\rightarrow$ metal).

They also demonstrated the pipeline on real-world audio using DDIM inversion (mapping real audio back into the model's latent space), utilizing the MU-LLaMA model to generate initial captions for the real audio clips.

Key Insights and Ideas

  • Semantic Robustness via Averaging: A single word swap is often insufficient for complex latent spaces. By averaging many GPT-generated descriptions of a concept, the model captures a "purer" semantic direction for the edit.
  • Attention as a Structural Anchor: The paper reinforces the idea that in diffusion models, cross-attention maps are the "blueprints" of the output. By pinning these blueprints down, you can swap the "building materials" (timbre/style) without changing the "architecture" (melody/rhythm).
  • Training-Free Versatility: Because it leverages the latent capabilities of a pre-trained model, MusicMagus can theoretically perform any edit the base model understands, bypassing the need for expensive, paired musical datasets.

Key Results

The authors compared MusicMagus against baselines like AudioLDM 2 (zero-shot) and Transplayer (supervised).

  • Timbre Transfer: In subjective tests, MusicMagus achieved a Structural Consistency (CON) score of 66.6, vastly outperforming the supervised Transplayer (34.6). It also maintained much higher relevance to the new text prompt than the base AudioLDM 2. (See Table 1).
  • Objective Metrics: Using Chromagram Similarity (a measure of pitch/rhythm preservation), MusicMagus scored 0.76 in timbre transfer, compared to 0.56 for the supervised baseline. (See Table 3).
  • Style Transfer: The model successfully maintained melodic polyphony during style shifts, a task where even supervised models like MusicGen often struggle with stability.
Table 1
Table 3

Limitations and Future Work

  • Multi-Instrument Complexity: The model currently struggles with complex, multi-instrument arrangements where stems overlap significantly.
  • Audio Fidelity: The output is currently capped at a 16kHz sampling rate, which is below professional production standards and can result in audible artifacts.
  • Edit Scope: The system is best at "intra-stem" changes. It currently cannot reliably add or remove instruments entirely without risking the structural integrity of the piece.
  • Stability: As with many zero-shot methods, there are occasional "failure cases" where the $\Delta$ vector doesn't trigger the intended change effectively.

Summary updated

BibTeX
@inproceedings{zhang2024musicmagus,
  author = {Yixiao Zhang and Yukara Ikemiya and Gus Xia and Naoki Murata and Marco A. Martínez-Ramírez and Wei-Hsiang Liao and Yuki Mitsufuji and Simon Dixon},
  title = {{MusicMagus: Zero-Shot Text-to-Music Editing via Diffusion Models}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2024},
  url = {https://openreview.net/forum?id=YO9s7haPzV},
}
Figure