Wednesday, January 10, 2018

Generate Music using Machine learning


The Google Brain team has a very cool project called Magenta.  It can be used for music and art generation.

I tried out a simple way to generate music using their Machine Learning models.

Steps taken on OS X:
1) install Docker and launch it, if it's not already running
2) launch a Terminal window
3) run the following command to start the Docker container
docker run -it -p 6006:6006 -v /tmp/magenta:/magenta-data tensorflow/magenta
4) After the Docker container is started, run the following command to generate 10 midi files (you can repeat this command to generate more)
melody_rnn_generate \
  --config=lookback_rnn \
  --bundle_file=/magenta-models/lookback_rnn.mag \
  --output_dir=/magenta-data/lookback_rnn/generated \
  --num_outputs=10 \
  --num_steps=128 \
  --primer_melody="[60]"
5) Open Finder and choose go to folder and enter /tmp/magenta for the folder
6) Copy the midi files to somewhere like your desktop to save the files
7) You can play the files in GarageBand or another music program like Ableton
8) If you'd like to use the files in a song that you create I would suggest using them as background percussion or something that fits with the sort of random nature of the notes in the midi files

Note: you can probably do far more interesting things than this if you tweak the command and / or model.

Hope that you enjoy.  Cheers.

Kristian

P.S. Here's something from the news that might serve as further inspiration - https://www.marketwatch.com/story/nvidia-taught-ai-to-compose-a-star-wars-song-like-john-williams-2018-01-08 .

No comments:

Post a Comment