Jump to content
Tuts 4 You

How to play midi music from resource?


alaphate

Recommended Posts

Posted (edited)

I can use mciSendCommand to play midi music from disk.

I'd like to embed midi file into .rc (resource).

How to play midi from resource or memory?

Thank you very much in advance.

// c, cpp languages are preferred.

I have found a example using directX, but I don't want directX in my progam.

http://www.codeguru.com/cpp/g-m/multimedia/print.php/c1573

Edited by alaphate
  • 1 month later...
Posted
I have found a example using directX, but I don't want directX in my progam.

http://www.codeguru.com/cpp/g-m/multimedia/print.php/c1573

Just wondering, I couldn't find any dependancies on DirectSound in the supplied example code,

I did notice the reference to the DirectX examples, though nothing to suggest they're needed for this

code.

Although it uses mmsystem.lib, though this is separate and distinct to DirectSound.

Here's what MS has to say about MIDI: http://msdn.microsoft.com/en-us/library/ms712058(VS.85).aspx

Posted (edited)

enhzflep,

Thank you for great help :)

mciSendCommand() can play midi with ease, but it cannot play midi from resource.

I googled, and found someone suggested using Hook to Windows' OpenFile() API

And provide the midi filename with a plus sign to the end, i.e. "hello.mid+"

However, I don't know how to hook OpenFile().

Again, Thank you very much!

Edited by alaphate
Posted
enhzflep,

Thank you for great help :)

mciSendCommand() can play midi with ease, but it cannot play midi from resource.

I googled, and found someone suggested using Hook to Windows' OpenFile() API

And provide the midi filename with a plus sign to the end, i.e. "hello.mid+"

However, I don't know how to hook OpenFile().

Again, Thank you very much!

Holy f%*!, that seems like a hell of a lot of work to me.

Why don't you give this project a try? It's the source code from the example you linked to - with the MFC dependency removed.

I've compiled this program using minGW and Code::Blocks

Enjoy!

:ph34r:

midi.rar

Posted

enhzflep,

Thank you for the attachment, the problem is resolved.

Hook to OpenFile is very useful, it's used not only for embedding midi, but also for other files,

such as play .swf in resource using ActiveX.

90% of my questions in this forum are resolved by you.

Great thanks!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...