Introducing and preprocessing music MIDI files

In this recipe, we will read a repository of Musical Instrument Digital Interface (MIDI) files and preprocess them into a suitable format for an RBM. MIDI is one of the formats of storing musical notes, which can be converted to other formats such as .wav, .mp3, .mp4, and so on. MIDI file formats store various kinds of events such as Note-on, Note-off, Tempo, Time Signature, End of track, and so on. However, we will primarily be focusing on the type of note--when it was turned on, and when it was turned off.

Each song is encoded into a binary matrix, where rows represent time, and columns represent both turned on and turned off notes. At each time, a note is turned on and the same note is turned off. Suppose that, out of n notes, note i is turned on and turned off at time j, then positions Mji = 1 and Mj(n+i) = 1, and the rest Mj = 0.

All the rows together form a song. Currently, in this chapter, we will be leveraging Python codes to encode MIDI songs into binary matrices, which can later be used in a Restricted Boltzmann Machine (RBM).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset