Free Web Hosting Provider - Web Hosting - E-commerce - High Speed Internet - Free Web Page
Search the Web

The Multimedia Sound API calls

The API calls for sound can be an essential part of any program even more so in any multimedia application or game. In VB 4, you have two choices on including sound into your applications, One choice is to use an ocx add-in such as the multimedia add-in or use an API call. Below you will find source code on making your api calls to play sound.

Before making any sound calls you must first open a new form & module and type in the following sound api constants and declarations.

'Sound api declaration 32-bit (may work for 16-bit)

Declare Function sndplaysound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Declare Function sndStopSound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As Long, ByVal uFlags As Long) As Long

' constants for snyPlaySound

Const SND_SYNC = (0)
Const SND_ASYNC = (1)
Const SND_NODEFAULT = (2)
Const SND_MEMORY = (4)
Const SND_LOOP = (8)
Const SND_NOSTOP = (16)

Public Sub playsound()
Dim rc
rc = sndplaysound(App.Path & "\bb_nuts.wav", SND_NODEFAULT + SND_ASYNC)
End Sub

In the form, create an command button and type the following:

Private Sub Command1_Click()
playsound
End Sub

Later on I will create a more in depth tutorial but for this is it for now. To download this source code download the zip file below.
Music Wav API tutorial(20K)

If you would like to make a tutorial, please e-mail me.


Comments and suggestions are welcome.
Copyright c 1996 Heller Productions