how to play .mid file Topic is solved

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
Post Reply
fancyivan
Experienced Solver
Experienced Solver
Posts: 80
Joined: Wed May 26, 2010 8:42 am
Location: Beijing, China
Contact:

how to play .mid file

Post 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)
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post 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
"Keyboard not detected. Press F1 to continue"
-- Windows
fancyivan
Experienced Solver
Experienced Solver
Posts: 80
Joined: Wed May 26, 2010 8:42 am
Location: Beijing, China
Contact:

Post 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...
User avatar
T-Rex
Moderator
Moderator
Posts: 1248
Joined: Sat Oct 23, 2004 9:58 am
Location: Zaporizhzhya, Ukraine
Contact:

Post by T-Rex »

There is wxMidi project. Maybe it will fit your needs. http://wxcode.sourceforge.net/showcomp.php?name=wxMidi
qgranfor
Experienced Solver
Experienced Solver
Posts: 89
Joined: Sun Aug 29, 2004 7:32 pm
Location: ND...USA
Contact:

Post 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.
Post Reply