Solved

Rundown on embedding sound into an app please?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

919 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

17 Experts available now in Live!

Get 1:1 Help Now