Abstract
We propose an application of sequence generative adversarial networks (SeqGAN), which are generative adversarial networks for discrete sequence generation, for creating polyphonic musical sequences. Instead of a monophonic melody generation suggested in the original work, we present an efficient representation of a polyphony MIDI file that simultaneously captures chords and melodies with dynamic timings. The proposed method condenses duration, octaves, and keys of both melodies and chords into a single word vector representation, and recurrent neural networks learn to predict distributions of sequences from the embedded musical word space. We experiment with the original method and the least squares method to the discriminator, which is known to stabilize the training of GANs. The network can create sequences that are musically coherent and shows an improved quantitative and qualitative measures. We also report that careful optimization of reinforcement learning signals of the model is crucial for general application of the model.
Introduction
Generating music with AI typically involves either continuous audio waveforms or discrete symbolic sequences like MIDI. While Generative Adversarial Networks (GANs) have seen immense success in image generation, they struggle with discrete data. The non-differentiable nature of discrete tokens prevents the standard backpropagation of gradients from a discriminator to a generator. Furthermore, most existing symbolic music models focus on monophonic melodies. This research addresses these challenges by adapting the Sequence GAN (SeqGAN) framework to polyphonic music, where melodies and chords interact dynamically.
Data Representation and Preprocessing
A core contribution of this work is the "musical word" representation. Rather than treating MIDI as a simple stream of notes, the researchers developed a tokenization scheme that condenses duration, octave, and pitch for both the melody and accompanying chords into a single vector. This allows the model to process complex polyphonic moments as individual tokens in a sequence, similar to words in a sentence.
The Nottingham database, containing 1,200 folk tunes, served as the training set. Using the music21 library, MIDI files were parsed into start times, durations, octaves, and pitches, resulting in a vocabulary of 3,216 unique musical tokens.
Methodology: The SeqGAN Framework
The model employs a SeqGAN architecture, treating music generation as a reinforcement learning problem to bypass the discrete data gradient issue.
- Generator: A Recurrent Neural Network (RNN) with LSTM cells predicts the next musical token in a sequence.
- Discriminator: A Convolutional Neural Network (CNN) distinguishes between real human-composed samples and those produced by the generator.
- Training Loop: Because the output is discrete, the generator is updated via policy gradients. To evaluate the quality of a partial sequence, the model uses Monte Carlo (MC) rollouts to simulate potential completions of the piece.
To stabilize training, the authors implemented Least Squares GAN (LS-GAN) loss. A key finding was that a discriminator that is too powerful can hinder learning; reducing the CNN's complexity (from 10 to 5 layers) provided more useful reward signals to the generator.
Results and Evaluation
The model's performance was evaluated using both quantitative metrics and human qualitative assessment. Quantitatively, the LS-SeqGAN (Unconditional) model achieved a BLEU-4 score of 0.6852, significantly outperforming the standard Maximum Likelihood Estimation (MLE) baseline of 0.5335.
Qualitatively, in a Mean Opinion Score (MOS) study with 42 participants, adversarial sequences were rated higher for being "pleasant," "real," and "interesting" compared to pre-trained models. The adversarial model achieved a "Realness" score of 3.81/5.0, approaching the human sample score of 4.31/5.0. Conversely, models suffering from mode collapse were rated significantly lower (1.67/5.0), highlighting the importance of training stability.
Discussion and Future Work
While successful, the model faces challenges such as mode collapse, where the generator repeats specific patterns that successfully fool the discriminator. Additionally, the current hashing method for embeddings does not inherently account for music theory (e.g., harmonic relationships across octaves). Future research will explore consonance-aware embeddings and hybrid CNN-RNN architectures to better capture the underlying structural harmony of polyphonic music.
Summary updated