Solved

Rundown on embedding sound into an app please?

Posted on 2002-06-27
3
217 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month3 days, 21 hours left to enroll

630 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