🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #13100

Re: Play wav file from code

#13100
From: Ed Mulroy [TeamB]
Date: Mon, 27 Oct 2003 02:50
55 lines
2392 bytes
How you do that depends upon if it is an external *.wav file or one you have
built into your program as a resource.


If you want to play the sound contained in an external file, FILENAME.WAV

PlaySound("filename.wav", NULL, SND_FILENAME);


If you want to play a sound that you have built into your program as a
resource.

Put this declaration at the top of your source file to tell it of this
variable which was created by the compiler's startup code.

  -----------------
  extern HINSTANCE _hInstance;
  -----------------

Create a resource file, we'll call it SOUND.RC, containing this and add that
file name to the project.
  -----------------
  #include "sound.rh"

  BIG_SOUND WAVE "filename.wav"
  -----------------


You have created a header file named SOUND.RH containing this
  -----------------
  #define BIG_SOUND 1 /* or whatever number you want to give it */
  -----------------

Your source file should include SOUND.RH so that it knows of the #define for
BIG_SOUND

You can then give this command to play the wav file you have built into your
program.

  -----------------
  PlaySound(MAKEINTRESOURCE(BIG_SOUND),
     _hInstance, SND_RESOURCE);

  -----------------

For more things you can do with PlaySound, look in the compiler-supplied
help on Windows.

.  Ed

> Martin C wrote in message
> news:3f9c7595@newsgroups.borland.com...
>
> How I can play wave file programmatically ?
Technical Details
Message-ID: <3f9c8805$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3f9c7595@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,1888f9f1253de96f
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-10-26 19:09:14 PST
From: "Ed Mulroy [TeamB]" <dont_email_me@bitbuc.ket>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3f9c7595@newsgroups.borland.com>
Subject: Re: Play wav file from code
Date: Sun, 26 Oct 2003 21:50:39 -0500
Lines: 57
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 24.74.175.102
Message-ID: <3f9c8805$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1067223045 24.74.175.102 (26 Oct 2003 18:50:45 -0700)
X-Authenticated-User: edmulroy
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail