music-generation-DL
Contributers: Siddharth Venkatesan, Nick Adams, David Zhang, and Spencer Vagg
MusicRNN
This program generates music depending on the genre desired by using a Vanilla RNN. There are three RNN layers, two Fully Connected layers, and a Softmax Activation function at the end. To train the model, you can run the command
python MusicRNN.py genre_of_music num_epochs
The three genres to choose from are title_screen, battle, and piano. Each epoch the model's weights are saved, so training can stop at any point, and songs will still be able to be generated. To then generate a new song using these trained weights, you can run the command
python Generate.py genre_of_music num_notes_to_generate
FCE
- Download .mid/.midi files and use the convert_to_npy.py script to convert them into simple numpy arrays
- Create a data directory containing 3 subdirectories: title, battle, piano. Place .npy files in their proper location.
- Confirm you have the Python packages PyTorch, music21, and mido installed.
- Run
music.py
. Make sure it is at the same level as the data/ directory.
HVAE
- Download and install Anaconda. We use anaconda as our environment manager
- Assuming you are on a linux machine, you can download and set up the magenta environmnet using
curl https://raw.githubusercontent.com/tensorflow/magenta/master/magenta/tools/magenta-install.sh > /tmp/magenta-install.sh
bash /tmp/magenta-install.sh
- Open a new terminal window so that the changes take effect
- Run 'source activate magenta' to enter the magenta environment
- Change the BASE_DIRECTORY in vae_train.sh to your base directory
- Run the vae_train.sh script to start the process of data formatting, training, and sample generation
GAN
- Download MuseGAN from https://github.com/salu133445/musegan.
- Run gen_train.py to preprocess the MIDI files and save them into an npz file, which stores the data as a sparse matrix.
- Create an experiment in museGAN. Set the training data name and other parameters. (See the documentation of MuseGAN.)
- Train the network and obtain generated music.
- Run play_npz.sh to post-process the musical phrases and convert them into a single MIDI file.