Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 224
  • Last Modified:

Rundown on embedding sound into an app please?

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
EDStech
Asked:
EDStech
1 Solution
 
DrMaltzCommented:
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
 
inthedarkCommented:
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
 
EDStechAuthor Commented:
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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now