Pivaenist is a random piano music generator with a VAE architecture.
By the use of the aforementioned autoencoder, it allows the user to encode piano music pieces and to generate new ones.
Model Description
Pivaenist's architecture.
Developed by: TomRB22
Model type: Variational autoencoder
License: MIT
Sources
Code: Some of the code of this repository includes modifications (not the entire code, due to the differences in the architecture) or implementations from the following sites:
There might be acknowledgments missing. If you find some other resemblance to a site's code, please notify me and I will make sure of including it.
Using pivaenist in colab
If you preferred directly using or testing the model without the need to install it, you can use this colab notebook (stored in this repository as well) and follow its instructions. Moreover, this serves as an example of use.
Installation
To install the model, you will need to change your working directory to the desired installation location and execute the following commands:
The first one will clone the repository. Then, fluidsynth, a real-time MIDI synthesizer, is also set up in order to be used by the pretty-midi library. With the last line, you will make sure to have all dependencies on your system.
Training Details
Pivaenist was trained on the midi files of the MAESTRO v2.0.0 dataset. Their preprocessing involves splitting each note in pitch, duration and step, which compose a column of a 3xN matrix (which we call song map), where N is the number of notes and a row represents sequentially the different pitches, durations and steps. The VAE's objective is to reconstruct these matrices, making it then possible to generate random maps by sampling from the distribution, and then convert them to a MIDI file.
Convert "song map" to midi file (reverse process with respect to
midi_to_notes) and (optionally) save it, generating a PrettyMidi object in the process.
Parameters:
song_map (pd.DataFrame): 3xN matrix where each column is a note, composed of pitch, duration and step.
out_file (str): Path or file to write .mid file to. If None, no saving is done.
velocity (int): Note loudness, i. e. the hardness a piano key is struck with.
Returns:
pretty_midi.PrettyMIDI: PrettyMIDI object containing the song's representation.