Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Music from resources in Games

This topic is 5527 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

Hey! I want to load music from a resource and not from a file seperate from the .exe file. I know how to do this with the PlaySound() function but i want to use DSound to do it.... I can''t figure out how to use mmioOpen() to do this... Any tips? Advice? Thanks, TNTGames

Share this post

Link to post
Share on other sites
You can do it like this:

HRSRC hResource;
HGLOBAL hResGlobal;
unsigned long resSize;
void *pData = NULL;

hResource = FindResource(NULL, resName, "WAVE"); // (for wave files)

hResGlobal = LoadResource(NULL, hResource);
// get size of the resource

resSize = SizeofResource(NULL, hResource);
// get pointer to the resource

pData = LockResource(hResGlobal);

/*After this you can use pData to for example, memcpy it into a buffer, check that the data is an appropriate sound file and copy it into a DirectSoundbuffer*/

Share this post

Link to post
Share on other sites

  • 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!