I am looking for an example  or help on  how to embed a small wav file in my program.
(Can a mp3 be used since it's smaller ?)
It's for a game for my class to play while it's going on.

I found this, but it uses an external file.


invoke sndPlaySound ,ADDR SpecialEffectNoise,SND_ASYNC
Posted on 2007-05-05 10:15:30 by skywalker

I have done something similar to what you are trying. Not sure if this would help: In the Masm package there is a small utility called bintodb that will take your .wav file and turn it into .DB statements that you can include in your data segment. When your program is run, you would write out the Wav file to the hard drive and then play the music. When your program closes, you can leave the Wav file intact or delete it.

Posted on 2007-05-05 11:06:01 by SideSwipe
Thanks. I have the file converted. I need help with learning how to write out the file to disk.

Posted on 2007-05-05 15:41:04 by skywalker
Gee, you can just include the wav file into your resources by writing inside your resource file:

MyWave WAVE "song.wav"

Then you load it via, LoadResource & LockResource and Play it with sndPlaySound.
Posted on 2007-05-05 16:06:57 by JimmyClif
Also, note that .wav files are a in a container-format. So, you can put mp3 data in a .wav file (but you just need software that can do it - VirtualDub can with "export to wav").
All Windows since w2k come with preinstalled mp3 codecs, and can handle the playback via sndPlaySound ;)

P.S just tried VirtualDub's feature.. well, it can output such compressed .wav files only if you rip them from a videofile ^^".
P.P.S turned out in the newest version, they replaced "export to .wav" with "Save wav",... and turn the compression off >_< . Anyway, there are programs like GoldWave, that can handle compression via ACM into a .wav container file.
Posted on 2007-05-05 16:55:53 by Ultrano
Thanks, I will study the material from the last 2 posts.
Posted on 2007-05-05 20:15:26 by skywalker
Note: Directories are set to f:

Posted on 2007-05-05 22:20:26 by skywalker

Note: Directories are set to f:

Set up INCLUDE and LIB environment variables, and you won't have to use the ugly hardcoded x:\masm32\ locations.
Posted on 2007-05-06 03:37:03 by f0dder
I had those dirs in my path, not sure why I had to hard code the f:. I was tired.

Posted on 2007-05-06 06:00:36 by skywalker

JimmyClif offered the best solution, put your sound file in your resource script.
Posted on 2007-05-07 12:22:26 by Vortex
I am not familar with LoadResource etc. and the code I found did what I wanted.
The code is a little old but does drive in the nail.

Posted on 2007-05-07 13:08:10 by skywalker