Martin Wepner

making.cool.stuff

Computer learns to generate music by LSTM-RNNs

Inspired by carykh’s Youtube channel specifically this video, the purpose of this project was to generate music by Long short-term memory Neural Networks (LSTM). I play the piano since quite a few years, so I have at least an above average understanding of music notation. The cool thing about LSTMs is: It learns patterns in text and after a little bit of training it can imitate this patterns and output new text, that looks like the learned one.

So what I did was converting a midi file to a text file, that contains all the musical information needed. I then trained an LSTM using Torch on Ubuntu by feeding it with the text. Then I let the LSTM spit new text out, which I then converted back to a midi file. You can listen to some results in the gallery section.

Unfortunately, I did not know much about overfitting at the time I worked on this project. So the results may be overfitted.

FEATURES

  • generate music by a neural network!

TECHNOLOGIES

  • Python (converting midi to text and back)
  • torch (training)

TEAM

  • Martin Wepner

GALERIE

You can clearly hear, that it overfit the training data. Also, the quality is pretty poor, because I recorded it with my smartphone, to show it some friends. But still, very interesting to listen and hear some extra nuances the LSTM generated for the pieces

Beethoven:
Moonlight Sonata inspired:

other:

note the high pitch notes the LSTM added:

Here is some overfitted but quite interesting Amelié music:

Weiter Beitrag

Zurück Beitrag

© 2025 Martin Wepner

Thema von Anders Norén