News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Write out a file that is in my program

Started by Magnum, September 11, 2010, 04:37:01 PM

Previous topic - Next topic

Magnum

If I want to store a wave file in my program, how would I write it out to a file?

Have a great day,
                         Andy

bomz

in resources like icons.
may be anyone get an example code?

Tedd

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.
No snowflake in an avalanche feels responsible.

Coma

Hi,
FindResource, SizeofResource, LoadResource, LockResource, CreateFile, WriteFile, CloseHandle, could work.
Wave Resource must defined as RCDATA:
mySound         RCDATA      test.wav
Coma Homepage 20:00-23:00 GMT+2 --- http://ge2001.dyndns.org:44792

Magnum

Have a great day,
                         Andy

Magnum

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.

Have a great day,
                         Andy

bomz

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?

Coma

Hi,
myMidi         RCDATA      test.mid
myPng         RCDATA      test.png
myPdf          RCDATA      test.pdf
Coma Homepage 20:00-23:00 GMT+2 --- http://ge2001.dyndns.org:44792


Tedd

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.)
No snowflake in an avalanche feels responsible.

Magnum

Have a great day,
                         Andy