Page 1 of 1

how to play .mid file

Posted: Tue Jun 29, 2010 6:49 am
by fancyivan
hello, does anyone know how to play a midi file?

I want to play a .mid as the backgournd music of my application, but i have no idea about how to do it.... pls help me. thanks.

I tried to use wxMediaCtrl(with param: wxMEDIABACKEND_DIRECTSHOW) to play a midi, and it works. but..., there is a windows media player logo on my application. how can I hidden this logo, or is there any other ways to play midi without using quartz.dll (I mean, we must write a new midi decoder or not)? and as I know, we can use other decoder of the third party to finish it, e.g. libmpg123, an open source decoder.

ps: windows xp + C::B + wxWidgets + MinGW(gcc4.4.0)

Posted: Tue Jun 29, 2010 4:36 pm
by Auria
As far as I know there is no cross-platform library for MIDI playback (and no capability inside wxWidgets itself), even though I may have missed something because when I was searching for MIDI librairies for my app (http://ariamaestosa.sf.net) I also wanted editing capabilities.
I ended up writing code for each supported platform

Posted: Wed Jun 30, 2010 5:01 am
by fancyivan
Auria wrote:As far as I know there is no cross-platform library for MIDI playback (and no capability inside wxWidgets itself), even though I may have missed something because when I was searching for MIDI librairies for my app (http://ariamaestosa.sf.net) I also wanted editing capabilities.
I ended up writing code for each supported platform
Thanks for yor reply, Auria.

I used the wav file instead of midi file. therefore, I can use wxSound to play wav file, and it works fine.


btw: I can not play the wav file which is embedded in the resource.

Code: Select all


//in resource:

  wav_test WAV  ".\\res\\wav\\test.wav"

//code
wxSound* snd;
snd= wxSournd(wxT("wav_test"), true);
if(snd->IsOK()) // snd->IsOK returns true.
{ snd->Play();} //but there is no sound in fact.
snd->IsOK returns true, It means that it loads wav from resource successfully. but there is no sound in fact...

my compiler is: MinGW(gcc4.4.0), may be 'windres.exe' does not support WAV in resource. i'm not sure about it. but if do not support wav, why does snd->IsOK return true...

Posted: Sun Jul 04, 2010 3:27 pm
by T-Rex
There is wxMidi project. Maybe it will fit your needs. http://wxcode.sourceforge.net/showcomp.php?name=wxMidi

Posted: Tue Jul 06, 2010 9:10 pm
by qgranfor
Note sure what kind of license you're using in your program, but you might want to check out FMod lib which is free for smaller projects.

http://www.fmod.org/ is cross-platform and supports many sound files and I've embedded it into a few wxGTK projects without issue so far.