A GRU1-based RNN2 for rhythmic pattern generation. The RNN model is a char-rnn that gets trained on an input MIDI file encoded as a sequence of unit vectors
Run $ wolframscript -configure
and set the variable WOLFRAMSCRIPT_KERNELPATH
to your local WolframKernel
address
-
Run
$ wolframscript -f encodeAndTrain.wl
Type the input filename5
*.mid
The trained net and decoding parameters are saved in data/
.
-
Run
$ wolframscript -f generateAndDecode.wl
Generated
*.mid
is saved indata/
.
In general, a MIDI file is not defined on a time-grid; MIDI events might be defined by machine-precision digits. The first script will take care of time-quantization by fitting every MIDI event on a time-grid the resolution of which is equal to the minimum distance between two consecutive events that are found in the input MIDI file. The generated MIDI inherits this time-quantization.
The dimension of the unit vectors is equal to the number of different "notes" found in the input MIDI, e.g. the chromatic scale would be encoded with 12-dimensional unit vectors. Polyphony is encoded by vector addition of simultaneous events.
Similarly to LSTMetallica, the encoded input MIDI is riffled with "BAR" every 16 unit vectors for segmentation of measures. These "BAR" markers are deleted once the nerual net output is decoded to MIDI format.
1Gated Recurrent Unit
2Recurrent Neural Network
3Musical Instrument Digital Interface
4Full address or local address.