Gogo:Tronics - Parts and Supplies For Electronic Enthusiasts
Your Cart

Gogo:Tronics

Create Tone Player from Midi

Supply a midi file, an arduino sketch which will play a track from the midi file is created. Should work for any AVR based Arduino that supports tone().

Even works for ATtiny13 if you use my Arduino Core, for ATtiny13, you will probably want to sacrifice millis() to get some extra space by selecting "Tools > Millis, Tone Support > Tone Available, No Millis" which is a feature available only in my Core distribution above, amongst other space saving improvements.

NB: The parsing of the midi file is accomplished using Valentin Schmidt's PHP Midi File Parser, I know very little about Midi, Valentin's work made this pretty easy anyway.

Upload Midi Here

:

Supported: mid, midi

Files are in theory deleted after running the conversion, no data is stored in theory, but usage at your own risk etc...

It doesn't affect the size of the melody you can fit in, just for readability.

Scaling the duration can allow you to fit in more notes, just alter the tempo setting in the generated sketch so it sounds right to "unscale" it as it were. The note durations will keep their relative lengths (if note 1 is 50% longer than note 2, it will still be 50% longer after scaling), however due to rounding some slight differences may creep in.

Especially after scaling some midi files may have notes (or especially silence periods) which are very brief and you probably won't miss, so there's no point wasting a memory slot on them.

Tracks often have long periods of silence during a time that another track (instrument) is probably playing, it's probably good to get rid of them since you are only dealing with one track (melody) at a time.

Notes/Pauses

The maximum number of notes and pauses you can fit in your memory. For large chips like the ATMega328 (Arduino Uno, Pro-Mini) probably you can fit a few thousand, for small chips like the ATtiny13 you can fit a hundred of so.

If you try and compile the resulting sketch and it says it's too big, just reduce this number (or delete some of the notes from the Melody Data in the sketch directly). Conversely if you compile the sketch and you have lots of free space, you might as well increase the number to fit in more of the melody :-)

Midi files almost always will have more than one track, for example a track for each instrument, for our purposes a melody is a single track. The converter will export all the tracks individually, you can then edit the supplied loop() function to specify which one you want to play.