If I want to store a wave file in my program, how would I write it out to a file?
in resources like icons.
may be anyone get an example code?
If you already have the wav file, it's easiest (and best in terms of memory usage) to add it as a resource - from where it can be played directly too.
Example Attached.
Hi,
FindResource, SizeofResource, LoadResource, LockResource, CreateFile, WriteFile, CloseHandle, could work.
Wave Resource must defined as RCDATA:
mySound RCDATA test.wav
Thanks to everyone.
Quote from: Tedd on September 11, 2010, 07:52:22 PM
If you already have the wav file, it's easiest (and best in terms of memory usage) to add it as a resource - from where it can be played directly too.
Example Attached.
Thanks Tedd.
I found that no delay is necessary if SND_ASYNC is not used.
Why MS included this is one of those mysteries. :-)
SND_ASYNC
The sound is played asynchronously and PlaySound returns immediately after beginning the sound.
Quote from: Coma on September 11, 2010, 07:53:42 PM
Hi,
FindResource, SizeofResource, LoadResource, LockResource, CreateFile, WriteFile, CloseHandle, could work.
Wave Resource must defined as RCDATA:
mySound RCDATA test.wav
any more?
what about MIDI files?
Hi,
myMidi RCDATA test.mid
myPng RCDATA test.png
myPdf RCDATA test.pdf
(http://i068.radikal.ru/0811/0b/7c7c611ce687.gif)
Quote from: Magnum on September 11, 2010, 09:57:10 PM
I found that no delay is necessary if SND_ASYNC is not used.
Why MS included this is one of those mysteries. :-)
If you don't use SND_ASYNC then your program will block waiting for the sound to finish; for short sounds this isn't very noticeable, for longer ones it is - especially if you have other things to do following the sound, e.g. repaint the window.
So yes, it's not 'necessary' but it's generally better, which is why I demonstrated it that way (hence the delay, which you wouldn't otherwise use since there wouldn't normally be an exit immediately afterwards.)
If you just want a sound to play in your program (to signal some event) use async (no delay required.)
Thanks for the explanation.