Converting MP3 > MIDI > ArduboyTones

Hoping someone might be able to chip in with their experience converting files from MP3 to MIDI to ArduboyTones. I have converted the file using the tool from @MLXXXp’s website but the result is not recognisable. I cannot verify the MIDI file as I have nothing to play it on.

Are there any secrets to sampling rates, mono or stereo or the conversion process itself (beyond specifying -o2) ?

1 Like

I tried with several tools. After a while I think it is better to go full manual. I was trying to copy the intro melody from my company corporate video:

And the solution was to use Aria Maestrosa and a lot of patience. Then midi2tones to get this result:

const byte score[] PROGMEM = {
 0x90,60,// audio
 0x91,57, 3,155, 0x90,64, 0x91,55, 3,155, 0x90,48, 0x91,57, 3,155, 0x80, 0x81, 2,180, 0x90,57, 0x91,60,
 3,155, 0x90,48, 0x91,64, 3,155, 0x90,57, 0x91,69, 3,155, 0x80, 0x81, 2,180, 0x90,60, 0x91,60, 0,230, 0x90,60,
 0x91,60, 0,230, 0x90,60, 0x91,60, 1,205, 0x90,60, 0x91,60, 1,205, 0x90,64, 0x91,60, 0x92,64, 0x93,60, 1,205,
 0x90,57, 0x91,60, 0x82, 0x83, 1,205, 0x90,60, 0x91,64, 0x92,64, 0,230, 0x91,64, 0x82, 1,205, 0x80, 0x81, 0,230, 0x90,60,
 0x91,60, 0,230, 0x90,60, 0x91,60, 0,230, 0x90,59, 0x91,59, 1,205, 0x90,59, 0x91,59, 1,205, 0x90,64, 0x91,59,
 0x92,59, 1,205, 0x90,57, 0x81, 0x82, 1,205, 0x90,57, 0x91,60, 4,129, 0x80, 0x81, 0,230, 0x90,60, 0x91,60, 0,230,
 0x90,60, 0x91,60, 0,230, 0x90,60, 0x91,60, 1,205, 0x90,60, 0x91,60, 1,205, 0x90,60, 0x91,64, 0x92,60, 0x93,64,
 1,205, 0x90,60, 0x91,57, 0x82, 0x83, 1,205, 0x90,64, 0x91,64, 0x92,60, 0,230, 0x90,64, 0x81, 1,205, 0x80, 0x82, 0,230,
 0x90,60, 0x91,60, 0,230, 0x90,60, 0x91,60, 0,230, 0x90,59, 0x91,59, 1,205, 0x90,59, 0x91,59, 1,205, 0x90,59,
 0x91,59, 0x92,64, 1,205, 0x90,57, 0x81, 0x82, 1,205, 0x90,60, 0x91,57, 5,104, 0x80, 0x81,
// This score contains 257 bytes, and 4 tone generators are used.

Not bad, but it took me several hours. I do not have any musical skills, so I do not know secret “tricks” to identify stuff.


midi2tones works best if the MIDI file has been composed, or at least edited, with a tracker, sequencer or other music composition program or setup that can directly create a MIDI file. This allows the creation of a MIDI file that consists of only one or two channels/voices for optimal conversion.

I suspect that converting MP3 to MIDI would create a fairly complicated MIDI file, which would be difficult to convert to an ArduboyTones or ArduboyPlaytune compatible score, since all the sounds in an analog MP3 file would have to be recognised, and separated into distinct MIDI instruments and tracks.

You could try experimenting with the -c option to restrict the number of MIDI channels that are processed, and the -s option to select the strategy used to map channels to tone generators.

@filmote, Just note that this score is in Playtune format, for use with the ArduboyPlaytune library, so it doesn’t look the same as a score for the ArduboyTones library would.

@eried, Note that your score contains output for 4 tone generators and ArduboyPlaytune only handles 2 tone generators, so some parts of the score will be ignored.

The Aria Maestrosa sequencer that @eried used should allow you to view and play back your MIDI files. A search for “<your OS> MIDI player” will likely turn up others.

Under Linux, I’ve done a bit of experimentation with Rosegarden. It seems fairly capable.

I might give this a go. I have the sheet music for the theme I am after as well. Its a complex piece - when done by an orchestra in my MP3 sample - but can be dumbed down to something that will be recognisable on the Arduboy.

Thanks Scott - I thought that was probably the case. As you point out, my MP3 file is probably way to complex.

I hadn’t noticed so thanks for the heads up!

1 Like

I have had limited success with this and are hoping for some more insight.

I have found a MIDI file which someone else has created for the theme song I am after. I have editted it in Aria Maestrosa and removed most of the ‘orchestra’ but it still has four or five separate channels / instruments. When I convert these I seem to get only the first channel in my output (and you can sort of recognise the tune if I tell you in advance what it is!).

@MLXXXp Scott, does the ArduboyTones have multiple tone generators? Actually, maybe my first questiong should be - are tone generators synonymous with channels??

What’s the best approach here? Should I look at ‘flattening’ the MIDI file to one channel or should I swap to a different library, like ArduboyPlaytune?

ArduboyTones can only play one tone at a time. It only supports one tone generator. Think of it as something like a flute or trumpet, which can only play one note at a time.

In MIDI, a channel usually refers to a specific instrument or voice, such as a piano or violin. That instrument can usually play multiple notes at the same time (polyphony), like pressing and holding multiple keys to play a chord on a piano. So, to fully play even only one channel, you may need multiple tone generators.

On the other hand, it may be possible to map multiple channels to one tone generator, provided that only one note is playing at a time over all of those channels.

Yes, for ArduboyTones, you should try to flatten your MIDI score to a single channel with only one note playing at a time. As you’ve discovered, when producing a score for ArduboyTones, midi2tones will use only the lowest channel of those specified by the -c option, or channel 0 if -c isn’t given. If that channel contains multiple notes playing at a time, you will be given messages, both as terminal output and as a comment in the output file, indicating how many notes had to be skipped.

ArduboyPlaytune supports an additional tone generator, for a total of only 2 tone generators. If you want to use it, it’s best to provide a MIDI file that only ever plays 1 or 2 notes at a time, whether they be on a single or multiple channels. With midi2tones you should specify -t2 to indicate 2 tone generators. You can specify the channels to process by using the -c option but if your score is flattened properly, this shouldn’t be necessary. The -s option can be used to alter the strategy used for mapping channels to the 2 tone generators. If the processed data contains more than 2 notes playing at a time, you will be given messages, both as terminal output and as a comment in the output file, indicating how many notes had to be skipped.

If you desire more than 2 notes playing simultaneously, you could consider using the ATMlib library by Team A.R.G. It can play 4 notes at a time. The format of its scores can’t be created using midi2tones. Team A.R.G has created their own tracker/editor for creating ATMlib scores. @JO3RI may be able to assist you further with this.

Moderator Note:
Links to Team ARG’s website have been removed due to malicious new owners.

1 Like

Thanks for the reply @MLXXXp … I am going to look at flattening the MIDI file to two tracks and give the ArduboyPlaytune library a go.

The trade off between ArduboyTones and ArduboyPlaytune is features vs. code size.

ArduboyTones can only play one tone at a time (a monophonic score), with each tone played at either normal or louder volume.

ArduboyPlaytune can play a score with one or two notes playing at a time (a two voice polyphonic score). Notes are played at a single “normal” volume. It can also play single tone “effects” on tone generator 2, even while a score is playing, by muting either tone generator 2 or both tone generators while an effects tone is playing.

However, ArduboyPlaytune will take up quite a bit more code space, which could be a concern if you end up needing a large amount of code for the rest of the game.

ArduboyPlaytune also interferes with the use of the RGB LED in analog mode, whereas ArduboyTones doesn’t.

Again, thanks @MLXXXp … why does it interfere with the LED?

ArduboyPlaytune takes over the timer that’s used for the pulse width modulation that controls the brightness of two of the LEDs. ArduboyTones only uses one timer, which isn’t the one used to control the LEDs.