Skip to content

Clojure library that helps with creating data sets from midi files

License

Notifications You must be signed in to change notification settings

jumski/midi-dataset-toolkit

Repository files navigation

jumski.midi-dataset-toolkit

Overview

Clojure library that helps with creating data sets from midi files.

  • only intereseted in midi note on events
  • processes those events per track and outputs all events for each track
  • produces multiline string of 0s and 1s on stdout

Step string

00000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000
^                                                                                                                              ^
bit 127, which corresponds to note G9                                                       bit 0, which corresponds to note C-1
  • each line represents a single step of note on events
  • each "step" lists all notes playin at the same timestamp
  • notes that plays at given step are encoded as 1 and all other are 0 (this allows for encoding chords)
  • each line has 128 characters, which is a binary number, little endian encoded, which means bit 0 is on the right and bit 127 is on the left
  • each bit corresponds to midi note number, from 0 to 127

Example output

The following output will be produced for a step where only one note, C4 plays:

00000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000
                                                                   ^
                                                                   bit 60 is set to true, which corresponds to note C4

The following output corresponds to Cmajor scale played up and down, at 4th octave:

00000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000

Usage

Just download midi2stepfile from latest release and run it, passing path to one or multiple midi files, like this:

midi2stepfile resources/c_major_scale.mid
midi2stepfile some/path/to/*.mid

Each track from each file will be printed to stdout encoded as 0s and 1s.

Testing

Run tests with lein midje.

Building

lein bin

The binary will be put into bin/midi2stepfile

TODO:

  • add time quantization for steps
  • add some way to consume streams (stdin first?)

License

Copyright © 2020 Wojciech Majewski

MIT License