| beep |
API
There are several Windows API which can be used to play
sounds, including the sndPlaySound and WinBeep API.
Both of these are included in the Win32API.inc that is distributed with PowerBASIC, so the declaration statements do not need to be put in the application as long as the #INCLUDE "Win32API.inc" compiler directive is included.
Here is an example of using the WinBeep API.
DECLARE FUNCTION WinBeep LIB "KERNEL32.DLL" ALIAS "Beep" _ (BYVAL dwFreq AS DWORD, BYVAL dwDuration AS DWORD) AS LONG WinBeep 1000, 2000 'play 1000Hz sound for two seconds
And here are several sndPlaySound API example.
Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags as Long) as Long Dim iReturn As Long, SoundFile As String SoundFile = "sound.wav" 'set filename of sound to play iReturn = sndPlaySound(SoundFile, &H1) 'once, in background iReturn = sndPlaySound(SoundFile, &H0) 'once, wait until done iReturn = sndPlaySound(SoundFile, &H8) 'play continuously iReturn = sndPlaySound(vbNullString, False) 'stop playing sound
Not shown here, the mciSendString API can be used to play midi files.
Controls
Unlike Visual Basic, PowerBASIC does not come with a built in
control to play sounds. If the use of API, as discussed above,
doesn't satisfy your need, you have two other choices.
Sound Function Reference
Here's a quick reference of the available sound functions, in alphabetical
order.
Beep 'that's it, just one line of code to get a beep
If you have any suggestions or corrections, please let me know.