This tool reads raw MIDI output and generates Arduino programs that allow an Arduino to play the notes from the MIDI file. The tool currently works for an Arduino connected to a Zumo robot with a buzzer enabled.
The tool is written in Python and has been tested to work under Linux on Python versions 2.7 and 3.4. No additional Python packages are required.
The tool reads plain text format files that are generated by the
midicomp program. It is necessary to use
this program to generate these files, as we do not yet support reading standard
MIDI files directly. Follow the instructions for midicomp
to retrieve and
install it.
To compile and transfer the Arduino programs, download and extract/install the Arduino IDE. Additionally, the Arduino must be powered and connected to the machine running the IDE during these steps. You can use a USB (to type B) cable or TTL interface.
In case you want to use the Zumo versions of the output programs, you must also
download the Zumo library. Move the
directories from the Zumo library to the libraries
subdirectory in your
Arduino IDE sketchbook, except for the examples (you can put those in the
sketchbook itself, if you want).
The tool currently reads the plain text MIDI files from standard input, which
allows chaining the necessary commands to run them in one go. The pipeline is
as follows: midicomp
generates a text dump for a given MIDI file, the Python
script reads the dump stream and collects the necessary track and note
information. Then, for each track, it generates a program that plays these
notes in an approximate manner.
Thus the following command, after replacing the <MIDI file>
with a path to
a file, creates Arduino programs for all tracks in that file:
midicomp <MIDI file> | python midi.py
The tool is licensed under the MIT license. See the LICENSE
file for more
information.