Abstract
Recent advances in text-to-music generation models have opened new avenues in musical creativity. However, the task of editing these generated music remains a significant challenge. This paper introduces a novel approach to edit music generated by such models, enabling the modification of specific attributes, such as genre, mood, and instrument, while maintaining other aspects unchanged. Our method transforms text editing to the latent space manipulation, and adds an additional constraint to enforce consistency. It seamlessly integrates with existing pretrained text-to-music diffusion models without requiring additional training. Experimental results demonstrate superior performance over both zero-shot and certain supervised baselines in style and timbre transfer evaluations. We also show the practical applicability of our approach in real-world music editing scenarios.
Introduction
In professional music production, the creative process is inherently iterative. A producer might generate a compelling melody but decide that the timbre of a piano should be replaced by an acoustic guitar, or that a jazz arrangement would better suit a rock aesthetic. While current text-to-music models like AudioLDM 2 can generate high-quality audio from scratch, they struggle with precise editing. Changing a single word in a prompt often results in a completely different composition, losing the original's structural and melodic integrity.
Existing solutions typically rely on supervised learning with paired datasets (e.g., the same song played on different instruments), which are difficult to scale and limited by their training data. MusicMagus addresses this by introducing a zero-shot framework for "intra-stem" editing, allowing for attribute modification without additional training or paired data.
Methodology
MusicMagus operates within the latent space of a pre-trained diffusion model. The framework relies on two primary innovations: robust semantic direction finding and structural preservation through attention constraints.
Finding the Editing Direction (Δ)
To modify a musical attribute, the model must identify the correct "direction" in the latent embedding space. Rather than relying on a simple word swap, which can be noisy, MusicMagus utilizes a large language model (InstructGPT) to generate a diverse set of captions for both the source and target attributes. By calculating the mean difference between these embedding sets using a text encoder (FLAN-T5), the system derives a robust delta vector (Δ) that represents the desired edit.
Cross-Attention Constraints
The core challenge of music editing is maintaining structural consistency—ensuring the notes and rhythm remain the same while the timbre or style changes. MusicMagus achieves this by leveraging cross-attention maps, which act as a spatial-temporal blueprint for the audio. During the denoising process of the edited track, the model enforces an L2 loss constraint between the new cross-attention maps and those recorded from the original generation. This "pins" the structural elements of the music in place.
For real-world audio not originally generated by the model, the system employs DDIM inversion to map the recording back into the model's latent starting point, enabling the same editing techniques to be applied to existing files.
Evaluation and Results
The researchers evaluated MusicMagus against both zero-shot (AudioLDM 2) and supervised baselines (Transplayer for timbre, MusicGen for style).
- Structural Consistency: In timbre transfer tasks, MusicMagus achieved a Structural Consistency (CON) score of 66.6, nearly doubling the performance of the supervised Transplayer (34.6).
- Semantic Relevance: The model significantly outperformed standard AudioLDM 2 editing in relevance (76.2 vs 15.7), proving that the Δ vector and attention constraints are more effective than simple latent interpolation.
- Ablation Studies: Removing the L2 attention constraint led to a sharp decline in consistency, confirming that cross-attention maps are the critical component for preserving melody and rhythm.
Conclusion and Future Work
MusicMagus demonstrates that a well-constrained zero-shot model can outperform supervised alternatives by leveraging the vast, diverse knowledge of large-scale pre-trained diffusion models. While highly effective for intra-stem editing, the model currently faces limitations in handling complex, multi-instrument arrangements and is capped at a 16kHz sampling rate. Future research will focus on increasing audio fidelity to professional standards (44.1kHz+) and expanding the framework to handle inter-stem editing, such as adding or removing entire instruments from a mix.
Summary updated