Archived

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

tom76

Sound (.wav) in VC++

Recommended Posts

How does sound work in VC++? What I mean is I''m playing with the donuts3D game off the sdk and decided to change the sounds. I replaced the .wav file with another one, and that didn''t work. I then changed the filename completely (say bangbang.wav to blownup.wav) and changed it all in the code itself, no errors etc., but when I play the game THE ORIGINAL SOUND (bangbang.wav) STILL PLAYS!!!!!!!! Even though there isn''t any other file named blownup.wav on my computer!!! Does VC++ store .wav files in hex format and generates them that way? I''ve seen hex relating to sound in the resources folder. HELP!!! "I envy you, who has seen it all" "And I, young sir, envy you, who have yet to see it for the first time..." - Daniel Glenfield 1st October 2001

Share this post


Link to post
Share on other sites
Try deleting all object files. Basicly, anything that isn''t the main project file (don''t know how this works in VC++), or a file with ".h" ".cpp" ".rc" etc. Also try doing a resource build or a full build (again, I am not exactly sure how this works in VC)


ANDREW RUSSELL STUDIOS
Looking for my webpage? Funny that... Me too!
Resist nes8bit :: Bow Down to Linux Communisum

Share this post


Link to post
Share on other sites
If you want to remove all intermediate files, select Clean from under the Build menu.

VC can occasionally be a bit arsey when changing resources - occasionally it will not register any amendments and so not rebuild the resource data. In this case, just change one of the resource properties ( ideally the name ), then change it back to the original.

The easiest way to change resources is to delete the original, remembering the resource ordinal name ( IDR_WAV_BANG ). Then, import the new resource and give it the same ordinal resource ID as the original.

Share this post


Link to post
Share on other sites
I''ll give that a try - thanks!!!!

"I envy you, who has seen it all"
"And I, young sir, envy you, who have yet to see it for the first time..."
- Daniel Glenfield
1st October 2001

Share this post


Link to post
Share on other sites
THANK YOU!!!!!!!!!!!!!!!!! I hit REBUILD ALL and it worked it''s magic. Thank you so much

Daniel

"I envy you, who has seen it all"
"And I, young sir, envy you, who have yet to see it for the first time..."
- Daniel Glenfield
1st October 2001

Share this post


Link to post
Share on other sites
So how do they get the sound to work in that example? I tried to do something similar (using the dsutil stuff) in a simple direct draw app, except it would just play a .wav file when you hit the enter key. Nothing works, the code builds fine but the app doesn''t play any sound. I haven''t found any other examples of using dsound in this type of app (the only other examples are dialog based MFC Apps). Hoping to find an example of this, as opposed to spending too much time reinventing something that''s been done before?

"A man can''t just sit around." ''Lawn Chair'' Larry Walters (1982)

Share this post


Link to post
Share on other sites
Hmmm...not sure if I fully understand. Donuts uses the PlaySound function, which you can insert all over the place (it''s easy enough).
If you''re trying to put sound in, make sure it''s in the right part of the code. Maybe at the start of a function.

If that''s not helpful ask again lol

"I envy you, who has seen it all"
"And I, young sir, envy you, who have yet to see it for the first time..."
- Daniel Glenfield
1st October 2001

Share this post


Link to post
Share on other sites
tom76-The version of that demo I''ve got uses DirectSound and dsutil.h, dsutil.c. After reading your post I looked up something in a book and saw an App that used PlaySound(). Couldn''t believe it was that simple! Why would I bother with DirectSound?

"A man can''t just sit around." ''Lawn Chair'' Larry Walters (1982)

Share this post


Link to post
Share on other sites
Glad I could help - Now I''m having trouble with getting sounds to play!!!
I copied the source code across to a brand new project, but the sound won''t play (there are no errors reported, but the sound just doesn''t play). It''s annoying me very much!!!

"I envy you, who has seen it all"
"And I, young sir, envy you, who have yet to see it for the first time..."
- Daniel Glenfield
1st October 2001

Share this post


Link to post
Share on other sites
Unfortunately, no errors in compilation rarely means everything is gonna be fine come runtime. You should get in the habit of checking HRESULTS from all Win32 function calls - chances are the problem will manifest itself in these. VC++ tip of the day : If you, as nearly everyone does, return HRESULTs to hr ( although I guess any variable name will work ), you can get the text description of the HRESULT by typing hr,hr into the watch window when debugging - can be very useful.

When you copied the source across, did you also copy all the resources? And maintain the directory structure? Could be that the resource can''t be located in the new project file tree. I''d have thought that VC++ would have picked this up, but you never know ...

Share this post


Link to post
Share on other sites
Thanks - I''ll take your advice on board.

It seems to be my lucky day today - got almost all xmas shopping done, got some cheap pokemon cards - no doubles, 1 rare hologram, and best of all THE SOUND NOW WORKS!!!

Here''s what I did.
In the resources I hit INSERT, called my Custom type "WAV" and created a blank file.
I imported a sound (flamethrower.wav) and it came under "WAVE". I copied the hex code into my blank file, renamed it "FLAMETHROWER" (with the "") and deleted the other file. And it works!!!!

Amazing!

"I envy you, who has seen it all"
"And I, young sir, envy you, who have yet to see it for the first time..."
- Daniel Glenfield
1st October 2001

Share this post


Link to post
Share on other sites
Sorry I've notice that you've been posting alot of request about
sound programming.

If you got the money maybe you should get a book call:
"A Programmer's Guide to Sound" by Tim Kientzle

It gots some sound theory as will has a bunch of source code in
C++ for loading and playing *.wav, *.mpeg, *.iff etc..., wave
samples and information on Fourier's mathically tranformations.


Anyways I'm finish saying whatever I had to say so continue about your business. whAHAHAHAHA!!!!!

Edited by - black marq on November 12, 2001 5:19:19 PM

Share this post


Link to post
Share on other sites
Found a good tutorial on DirectSound programming at:
http://www.gametutorials.com/default.asp
Just what I was looking for, nothing complicated just something to use as a starting point.

"A man can''t just sit around." ''Lawn Chair'' Larry Walters (1982)

Share this post


Link to post
Share on other sites