Solved

Rundown on embedding sound into an app please?

Posted on 2002-06-27
3
181 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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 process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now