Jump to content
  • Advertisement
Sign in to follow this  
cwl157

playing midi files in sdl

This topic is 3700 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there a way to play midi files in sdl. I noticed the SDL_mixer only supports wav files. I looked at SDL_Sound on the SDL website but it was like source code and it didnt look like adding it worked the same as adding the SDL_Mixer or SDl_Image libraries. So does anyone know of a good one? thanks.

Share this post


Link to post
Share on other sites
Advertisement
nevermind i guess it plays it on its own. I read that it supports wav i guess thats just one thing the SDL_Mixer supports because midi seems to be working.

Share this post


Link to post
Share on other sites
i am having problems playing the midi sounds. I use the Mix_PlayMusic function to play the music but i want to have 3 different songs. One plays during the title screen, 1 during game play and 1 during the game over screen. I tried just calling each different sound during that game state but it would not work. Then i tried playing each song during that game state and when it was time to switch i would call Mix_HaltMusic to stop the music and then the next sound would start in the next game state. This does not work either i get nothing or maybe some clicking. Then i tried calling Mix_PlayMusic just once inside the main game loop and that didnt work. It seems like you cant call Mix_PlayMusic inside of a loop. I looked into Mix_Chunk but on lazy foo's tutorials it just loads WAV files. Is there a way to load a midi *.mid file using Mix_Chunk?

Share this post


Link to post
Share on other sites
Playing MIDI files on SDL_mixer requires an external MIDI player called Timidity installed. The Mix_Chunk only supports samples because it is intended for use with sound effects only.

A more efficient solution might be to convert your MIDI files to .XM (extended module) format so that you can play them with the internal module player functions. I use ModPlug Tracker on Windows to convert them when I need to do that.

Share this post


Link to post
Share on other sites
ok thanks i'll look into modPlug and yea i saw timidity but it said it had to be in C:\timidity and i tried that and it worked but then i deleted that and the midi still played. Anyway, so thats why i was confused but this .xm will play with SDL_Mixer?

Share this post


Link to post
Share on other sites
ok so i looked at modplug tracker thing and i don't get it. I loaded the mid file and when i select .xm it doesn't even sound right but anyway by doing this i will be able to play a different song at different parts of the game because that is my ultimate goal.

Share this post


Link to post
Share on other sites
ModPlug Tracker is a program for writing MOD and XM files. You can convert a MIDI to a MOD or an XM but you need to provide instruments for each track, so this probably isn't the most effective route. But if you can get such a module file to sound ok, then yes, you can use that file with SDL.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!