Play .midi file in game

Is there a way to play a midi file for music in game?

I am making a really music heavy game and this would cut the size more than half.

I wish.

They should put midi support in the next version of blender… I would be very :slight_smile:

i think some development is needed for the blender sound engine to support other compressed file types as well.

if i want to play an mp3 music file on bge i have to convert it to a wav file (which is gigantic in size and the entire file occupies the memory,which is not very cool)

it would be better if blender supports other compressed audio file types as well:spin:

If your midi file is very simple, you could write a python script to do it, for example (pseudocode follows):

for i in midifile:
 playsound("sound"+i.pitch)

Please do not just copy and paste this code it will not work. it is just a guideline. It assumes that you have many sounds named “sound01”, “sound02”, “sound03” and so on which correspond to different pitches. Or you could use the sound.setPitch() function. I may be able to post a blend later this week.

No i am talking about very complex midi files that sound like professional music.

Well, there may be a way to do it, there may not.

2.5 has a recoded sound system which can play a number of filetypes. NexYon is also getting prepared to bring back the python sound functions for the BGE.

Of all major filetypes you can play then .ogg is the best bet if you want high quality and a small size.

I recently did some googling and found this thing called Python Midi Package. I haven’t tried it, and am not even sure if it works with Blender… but it may be worth a try.

-> http://www.mxm.dk/products/public/pythonmidi

i tried your link and i was able to run scripts in it using python and certain midi files were created according to the script. i am not so sure that it can be used for playing midi files