Play tones generated by Midi2tones with ArduboyTones

I have a generated code from a midi file with midi2tones, but now how can I use it?


Add / ensure the following lines are at the top of your main .ino file:

#include <Arduboy2.h>
#include <ArduboyTones.h>

Arduboy2 arduboy;
ArduboyTones sound(;

Add your sound code into the project. I typically add them to a second file but you can simply paste it under the above code to make sure it works.

In your setup(), if you are not using arduboy.begin() then add the following line after arduboy.boot(). Normally you will use arduboy.begin() so you can probably skip this.;

Then when you want to play your sound …

sound.tones(  .. whatever you sound is called ..);



It worked, thanks. Do you know how to stop the sound and start from the beginning?

Do you mean stop it half way? In which case you can execute a sound.noTone();

Docs are here >

1 Like

@Jose_Fabio the library has functions to do this, to reload the song from the beginning I think I usually reload song.