What if you could turn any sentence into music? We wanted to see if we could build a system that takes a string of text and generates an actual musical piece from it—not just random notes, but something with structure, harmony, and emotion. The idea was to treat text as more than just words: use sentiment analysis to pick the key and tempo, and then map the characters to operations on different data structures to generate melodies.
​
We began with a user-provided string and used sentiment analysis to determine the musical key and tempo. From there, we generated melodies by mapping the string to operations on three data structures: a circular buffer, a hash table, and a red-black tree. Each data structure produces a different melodic pattern, allowing us to layer multiple interpretations of the same text into a single piece.
​
To generate harmony, we trained a neural network on positive and negative classical works. The preprocessing pipeline extracted melody–harmony pairs from scores and serialized them for training. Given a sequence of melody measures, the network predicts corresponding harmonies, with temperature scaling and sampling controlling the level of variation. Once harmonies are predicted, we use the music21 library to combine the melody lines with chord progressions into a complete score. The final output is exported both as MusicXML for notation and MIDI for playback, providing a full programmatic composition from a simple string of text.