Nov.18
To convert MIDI files into Arduino sketches
The intention of this experiment to play MIDI tones by using Arduino. This is very easy with some resistors and one speaker.
The components which used are:
1. Arduino UNO
2. Three 470 Ohm Resistors
3. one speaker/buzzer
First thing we need to take some midi sound files .eg: http://www.midiworld.com/download/3826 This is James Bond movie tone.Next thing we need to convert it into Arduino Sketch. For that we need one special software called Miditones. Download latest MidiTones .exe file. This is a command line utility. create one folder and copy-paste Miditones.exe and .midi file which we downloaded earlier .
Nextstep is to convert MIDI file to Sketch.Run the below command from DOS prompt. CD to the new directory.
lmiditonesV1.6.exe -t3 Movie_Themes_-_James_Bond |
Note that we need to give MIDI file name without .midi extension. the above command will generate Movie_Themes_-_James_Bond.c file on the same directory. Open this file on any texteditor, that will be our Arduino Sketch.
Next part is to install Playtune library to Arduino IDE. For that create a directory “Playtunes” under “C:\Program Files (x86)\Arduino\libraries“. Then download “Playtune.cpp & Playtune.h” and paste it into Playtunes directory.Now your IDE is able to process playtune library.
Next step is to wire the circuit. connect 470 Ohm resistors to 10,11 & 12 pins of Arduino and the other end of resistor connect together . Take one wire from GND , connect to one speaker lead and the other lead connect to resistor .I am not going to show the circuit as this is very simple to wire.
Next part is coding. Open Arduino IDE and paste below code.
#include <Playtune.h>
//copy paste content of converted midi file here.ie: Movie_Themes_-_James_Bond.c
Playtune pt; void setup() { void loop () { |
replace the second line with output of .c file from miditones and upload to Arduino. That’s it.
xargs
Nice to see this. Very useful. All the info in one place
Dedicated server
Is it possible to play midi files with the arduino and a speaker? If so, how would I go about doing it?
bentech4u
HI,
yes it’s possible and connection method also i mentioned above.
”
connect 470 Ohm resistors to 10,11 & 12 pins of Arduino….
“
Luis
i already cd to my folder and try to use the command but it says that “lmiditonesV1.6.exe”
isn’t an internal or external command….what should i do?
Jacob Jarick
Hello, thanks for the guide.
To ensure this works with Arduino 1.6.X edit playtune.cpp
change:
#include
to :
#include “arduino.h”
bentech4u
HI
thanks for your update
bentech4u
@Luis
please check the programe name you entered
TheUltimateAbsol
I got this error:
MIDI:7: error: variable ‘score’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’
kjoelby
Sweet, nice simplified instructions, thanks for posting this!
Author Len Shustek’s github page has compatible vs for Arduino IDE 1.6:
https://github.com/LenShustek/arduino-playtune
bentech4u
HI kjoelby
Thanks for your update.
Regards,
Ben
bentech4u
@TheUltimateAbsol
hoep this helps
https://github.com/arduino/Arduino/wiki/1.6-Frequently-Asked-Questions
Smithc775
Totally pent subject matter, appreciate it for selective information. kddcbbbdgecaddbg
Braiden
@bentech4u
I followed the link you gave @TheUltimateAbsol, and I still can’t figure out how to get it to compile. Please update your guide or leave a reply
Teleputer
Your Technically a System Engineer but your Systematically a technical Engineer =)
praveen kumar r
Can you please guide how to create midi file of my custom mp3 file.I have tried with lot of tools.Can you suggest me few more?
david
hi, there is no actual way to do that since a midi file are just note and a mp3 file is audio, i would recommend you check out musescore.com , there is a huge collection of midis
luis
it’s possible with arduino nano?
Edwardo Annen
I’m still learning from you, but I’m improving myself. I definitely enjoy reading everything that is posted on your site.Keep the stories coming. I enjoyed it!