Abstract
We propose Polyffusion, a diffusion model that generates polyphonic music scores by regarding music as image-like piano roll representations. The model is capable of controllable music generation with two paradigms: internal control and external control. Internal control refers to the process in which users pre-define a part of the music and then let the model infill the rest, similar to the task of masked music generation (or music inpainting). External control conditions the model with external yet related information, such as chord, texture, or other features, via the cross-attention mechanism. We show that by using internal and external controls, Polyffusion unifies a wide range of music creation tasks, including melody generation given accompaniment, accompaniment generation given melody, arbitrary music segment inpainting, and music arrangement given chords or textures. Experimental results show that our model significantly outperforms existing Transformer and sampling-based baselines, and using pre-trained disentangled representations as external conditions yields more effective controls.
Introduction
Symbolic music generation—creating structured scores rather than raw audio—presents unique challenges. Unlike images, music is highly discrete and requires strict adherence to harmonic, rhythmic, and structural constraints. Existing methods typically rely on Transformers or Variational Autoencoders (VAEs). While Transformers excel at sequence modeling, they can be difficult to control at a fine-grained level. VAEs offer better control but often produce blurry or incoherent results. Furthermore, most models are specialized for single tasks, such as melody generation, and lack the flexibility for general music inpainting or arrangement without retraining. Polyffusion addresses these gaps by introducing a flexible, high-quality, and controllable diffusion-based framework.
Methodology
Music as Image-like Piano Rolls
Polyffusion treats music as a 2D spatial object (Pitch vs. Time), allowing the model to capture vertical (harmonic) and horizontal (melodic) relationships simultaneously. Specifically, an 8-bar segment is represented as a 2-channel binary tensor: Channel 0 captures note onsets, while Channel 1 captures note sustains.
Architecture and Diffusion Process
The backbone of Polyffusion is a 2D UNet, similar to those employed in state-of-the-art image diffusion models. The model learns to iteratively "denoise" a random field of pixels into a coherent piano roll representation.
Controllable Generation Paradigms
Polyffusion unifies diverse musical tasks through two control paradigms:
- Internal Control (Inpainting): During denoising, specific regions of the piano roll (e.g., the accompaniment) are kept fixed while the model generates the remaining parts (e.g., the melody). This enables tasks like arbitrary segment inpainting.
- External Control (Conditional Generation): The model utilizes a cross-attention mechanism to incorporate external signals. Rather than raw chord names, the authors use pre-trained, disentangled VAEs to encode chords (harmony) and textures (rhythm) into latent vectors. This "latent conditioning" provides semantically rich hints to the diffusion process.
To further refine control, the model employs Classifier-Free Guidance (CFG), allowing users to adjust the trade-off between strict adherence to external conditions and generative creativity.
Experimental Results
The model was trained on the POP909 dataset, comprising approximately 64,000 8-bar segments. Polyffusion was compared against state-of-the-art Transformer and VAE baselines using both objective and subjective metrics:
- Objective Quality: Polyffusion achieved superior scores in pitch and duration distribution similarity ($D_P$ and $D_D$) compared to Transformers, indicating its output more closely resembles human-composed music.
- Controllability: The use of CFG significantly reduced "chord distance," demonstrating that the model effectively follows harmonic constraints.
- Subjective Evaluation: In double-blind listening tests, Polyffusion was rated higher than baselines in Naturalness and Musicality. Notably, for unconditional generation, listeners rated the model's Creativity higher than the original human compositions.
Conclusion and Future Work
Polyffusion demonstrates that diffusion models can be effectively adapted for symbolic music generation by leveraging image-like representations and dual control paradigms. While the current model is limited to grid-aligned (quantized) music and lacks long-term thematic memory over very long sequences, it provides a robust foundation for future work. Potential directions include modeling expressive performance (velocity and micro-timing) and incorporating multimodal controls, such as text-to-music generation.
Summary updated