Pages: [1] 2   Go Down
Author Topic: Read and Play MIDI file in arduino  (Read 11006 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm starting with Arduino and I need developer a project for read and  play a MIDI file in Arduino UNO.

If anypeople can help me, I'll make me feel very happy! :-)

Best Regards
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 632
Posts: 34510
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What do you mean by:-
Quote
read and  play a MIDI file in Arduino UNO.
Where is the MIDI file to be stored and are you expecting the arduino to generate the sound?
If so you will be disappointed as the arduno can't produce many tones let alone anything approaching the MIDI GM sound set.
Logged

Newcastle, England
Offline Offline
Sr. Member
****
Karma: 3
Posts: 489
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Although you cannot generate any quality audio with the UNO alone, it is possible to use something else - the midi shield!
http://www.skpang.co.uk/catalog/midi-shield-p-669.html

That should sort out the issues of bad sound quality.

Onions.
Logged

My website: http://www.harryrabbit.co.uk/electronics/home.html Up and running now! (Feel free to look round!) smiley-grin

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Grumpy_Mike and Oniosn :-)

My ideia is: read a MIDI file maybe in my computer (I started with arduino in few weeks :S) and after play in piezo buzzer.

Example of OUTPUT: http://www.youtube.com/watch?feature=player_embedded&v=mAG3W4RwNl0

But I don't undertand how Interpret the Structure of MIDI file and if I can put my MIDI file in my computer.

Best Regards
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 632
Posts: 34510
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You need something on your PC that reads MIDI files and outputs MIDI data. You also need a MIDI interface on your PC.
Then you need a MIDI interface on the Arduino and some software.
This project:-
http://www.thebox.myzen.co.uk/Hardware/Glockenspiel.html
fires solenoids when it receives MIDI data but you can modify it so that it generates a tone instead using the tone function.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Maybe this project http://www.varal.org/ttymidi/

But I don't understand how send the mid music

smiley-sad
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 632
Posts: 34510
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
But I don't understand how send the mid music
That is what I said at the start, you need an application on your computer to read a MIDI file and output it. There are lots around most MIDI musics apps allow you to do this.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, I have timidity (it's works), but in tutorial don't show that send the MIDI file (messages).

Code:
# start ttymidi
ttymidi -s /dev/ttyUSB0 &

# start some ALSA compatible MIDI
# program (timidity, in this case)
timidity -iA &                   

# list available MIDI input clients
aconnect -i                       

# list available MIDI output clients
aconnect -o                       

# connect
aconnect 128:0 129:0

# ...where 128 and 129 are the client
# numbers for ttymidi and timidity,
# found with the commands above

But where is the MIDI file?
example: timidity abba.mid (with tty already connected com arduino)
and after my buzzer in arduino singing abba :-)

Thanks smiley
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 632
Posts: 34510
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Timidity does not do anything with MIDI files, it acts as a conduit for you to put MIDI data through. You need an application that handles MIDI files and you point it at timidity an tell it to play the file.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Some idea how to do this?

I just want:
1 - Create a program in arduino that understand MIDI music file and reproduce.
2 - A way to put(send) MIDI file (messages, bytes, WHETEVER) to arduino.
3 - My piezo buzzer singing simple sound.

:S
I will go cry!!!

This is very difficulty
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 632
Posts: 34510
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
2 - A way to put(send) MIDI file (messages, bytes, WHETEVER) to arduino.
I use Garage Band, do you have that?
No well you need to get a program on your PC to do this. I am sorry but you haven't even said what operating system you are using.
You need to search and find a MIDI sequencer or other sort of file player.
I am not sure how many time I have to tell you?

Quote
This is very difficulty
You are making it difficult for your self by not reading my replies.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
You are making it difficult for your self by not reading my replies.
Ok, sorry and thanks a lot about your help.

Quote
No well you need to get a program on your PC to do this. I am sorry but you haven't even said what operating system you are using.
My O.S. is ubuntu 11.10.

I thought that timitidy is a file player
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 632
Posts: 34510
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

My O.S. is ubuntu 11.10
That makes all the difference, sorry but I know little about Linux.

Quote
I thought that timitidy is a file player
The link you posted is for ttymidi, the first sentence says
Quote
ttymidi is a GPL-licensed program that allows external serial devices to interface with ALSA MIDI applications.

What you need is an ALSA MIDI applications, that is the thing that reads the file. Sorry but I can't find one for you due to my lack of experience with you operating system.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I tried to use this http://lau.linuxaudio.org/TiMidity-howto.html.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I just finished a project that might be do something similar to what you are asking here.
It takes a midi file (saved as musicxml) and allows you to select up to three parts that will be played on the arduino using the three timers.

This post has more information: http://jarv.org/2011/11/arduino-music-from-a-midi-file/
I also used this lib to protype creating a cheap musical greeting card using an attiny - http://jarv.org/2011/11/custom-musical-greeting-card-for-less-than-5/

How a midi conversion turned out for the SMB theme -


« Last Edit: November 20, 2011, 08:09:53 pm by jarv » Logged

Pages: [1] 2   Go Up
Jump to: