Solved

Rundown on embedding sound into an app please?

Posted on 2002-06-27
3
207 Views
Last Modified: 2010-05-02
I'm familiar with microsoft's sound play technique, wherein you specify the location to a wav file on the local pc, etc.

But i'm looking to embed the wav into the application itself.  I know it's overhead, but the size of the wav file (and app itself) is small enough that I'm able to get away with it.  I'd consider it a plus if the method gave me the capacity to internall adjust the volume and whatnot..

What would be the preferred method of embedding a sound file into an app?  Provide sample code or a web link, please, I'm still a clueless, inept newbie.

Please note that if this is indeed not the "Easy" question I think it is, I can add points accordingly.

Thank you.
0
Comment
Question by:EDStech
3 Comments
 
LVL 3

Accepted Solution

by:
DrMaltz earned 50 total points
ID: 7115635
You'll have to add the wav file to a resource file.  In the example, I've got a wav file with a number 28 and name Sound.  using function from the multimedia api, I'm able to play the wav file. Check out the link..http://www.syix.com/wpsjr1/
Locate code PlayResSound.zip

Private Declare Function sndPlaySoundA& byval "winmm.dll"(lpszSoundName As
Any, ByVal Flag&)
Private Const SND_SYNC = &H0         '  play synchronously (default)
Private Const SND_ASYNC = &H1         '  play asynchronously
Private Const SND_NODEFAULT = &H2         '  silence not default, if sound
not found
Private Const SND_MEMORY = &H4         '  lpszSoundName points to a memory
file

Dim MySound() As Byte

MySound=LoadResData(28, "Sound")
sndPlaySoundA MySound(0), SND_ASYNC OR SND_MEMORY

Good Luck,

DrMaltz
0
 
LVL 17

Expert Comment

by:inthedark
ID: 7115913
Further to DrMaltz comment.

You can play from ordinary files also from system sounds and resource files.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dno97ta/html/msdn_ofcsoundcues.asp

See this link.  

Warning before closing your form in the form terminates aloways place:

PlaSound "",0,0

To avoide a GP Fault if you close while a sound is running.


Here is a better declaration:

Private Declare Function PlaySound Lib "winmm.dll" _
 Alias "PlaySoundA" (ByVal lpszName As String, _
 ByVal hModule As Long, ByVal dwFlags As Long) As Long


Example:

Private Const SND_FILENAME = &H20000     ' Name is a file name.
Private Const SND_ASYNC = &H1            ' Play asyncronously.


PlaySound "c:\MyFolder\MyWave\wav1.wav",SND_Filename,SND_Async

0
 
LVL 2

Author Comment

by:EDStech
ID: 7144806
That should provide the info necessary.. sorry for taking so long, frankly I forgot I had asked this, and this question wasn't showing up in my "Unlocked" question list thing.

Thanks for the info.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question