Epson
*

How to play sounds in SPEL+

Purpose
The purpose of this Technical Support Note is to describe how to play wave files from a SPEL+ program.

Procedure
You can call several functions in the Windows API from SPEL+.  To play sounds, you can use the PlaySound API call.  Of course, your system must have a sound card installed.

Create a program called sound.prg.
Include the following code:

SPEL Code Example
 
Declare PlaySound, "winmm.dll", "PlaySound", (name$ As String, module As Long, dwFlags As Long) As Long
 
#define SND_FILENAME &h20000
 
Function PlayWaveFile(fileName$ As String)
 
   PlaySound fileName$, 0, SND_FILENAME
Fend

Now you can call PlayWaveFile from anywhere in your project.  For example:

Function main
 
   PlayWaveFile "c:\winnt\media\tada.wav"
Fend