Abstract
Automatic melody generation for pop music has been a long-time aspiration for both AI researchers and musicians. However, learning to generate euphonious melody has turned out to be highly challenging due to a number of factors. Representation of multivariate property of notes has been one of the primary challenges. It is also difficult to remain in the permissible spectrum of musical variety, outside of which would be perceived as a plain random play without auditory pleasantness. Observing the conventional structure of pop music poses further challenges. In this paper, we propose to represent each note and its properties as a unique 'word,' thus lessening the prospect of misalignments between the properties, as well as reducing the complexity of learning. We also enforce regularization policies on the range of notes, thus encouraging the generated melody to stay close to what humans would find easy to follow. Furthermore, we generate melody conditioned on song part information, thus replicating the overall structure of a full song. Experimental results demonstrate that our model can generate auditorily pleasant songs that are more indistinguishable from human-written ones than previous models.
Introduction
Generating "euphonious" or pleasant-sounding music is a complex task for artificial intelligence. Unlike natural language processing, where a word is a discrete unit, a musical note is inherently multivariate, defined by its pitch, start time, duration, and intensity. Previous approaches often utilized "frame-level" predictions, where models determine the state of a song at every 1/16th of a beat. This frequently results in two significant failures: overfitting on silence (leading to repetitive, stagnant melodies) and a lack of macro-structure, where the generated sequence fails to follow the logical progression of a song (e.g., Verse to Chorus).
Methodology
Musical "Words" Representation
To address the limitations of frame-based models, we draw inspiration from image captioning architectures. We represent each note as a unique "word" tuple: (pitch, position, length). By treating a melody as a sentence of these discrete events, the model can skip over empty intervals and focus on the sequence of musical events themselves. This reduces the complexity of the learning task and prevents the model from falling into the "repetition trap."
Structural Conditioning
Music is defined by its structure. To replicate this, our model is conditioned on the current chord and the song part (e.g., verse, chorus, bridge). We utilize a Multinomial Hidden Markov Model (HMM) to first generate these structural sequences. The resulting two-hot vectors then serve as conditioning inputs for a Long Short-Term Memory (LSTM) network, which generates the final melody. This ensures that the generated notes are contextually appropriate for the specific section of the song.
Singability Regularization
To ensure the generated melodies are natural for human performance, we implemented a "singability" constraint. A custom loss function penalizes notes that fall outside the standard human vocal range (C4 to C5). This regularization policy encourages the model to produce melodies that are easy to follow and auditorily pleasant.
Experimental Setup
We trained our model on a curated dataset of 46 pop songs in MIDI format. All songs were transposed to C Major to simplify learning and avoid scale mismatches, resulting in a vocabulary of 2,082 unique "words." We compared our model against two state-of-the-art baselines: a hierarchical model (Chu et al., 2017) and an RL-tuned model (Jaques et al., 2017).
Results and Discussion
Evaluation was conducted via Amazon Mechanical Turk, where listeners compared generated melodies in a blind "Turing Test."
- User Preference: Our model was preferred over baselines in terms of melody, structure, and overall pleasantness. Specifically, 69.1% of listeners preferred our model's melody over the hierarchical baseline.
- Deception Rate: The model achieved a 68% deception rate (listeners believing the music was human-written), significantly outperforming the baselines (~60-62%) and approaching the human baseline of 77.7%.
- Training Dynamics: We identified a "safe zone" for training between 5 and 20 epochs. Training beyond this point led to musical plagiarism, while training below it resulted in dissonant outputs.
Conclusion
By treating musical notes as words and incorporating structural conditioning, we have developed a model capable of generating high-quality pop melodies. While currently limited to single-track major-scale music, future work will focus on multi-track coordination and expanding the musical vocabulary to include minor scales and expressive properties like vibrato. Our goal is to further refine the loss function to penalize plagiarism and enhance true algorithmic creativity.
Summary updated