SOUNDI/O StatementWindows

A device I/O statement that generates sound through the PC Speaker.

Syntax: SOUND frequency, duration
SOUND 4000, 18

Details:
  • Frequency is a numeric expression whose value is between 37 and 32,767. Frequency is measured in cycles/second, or hertz.
  • Duration is a numeric expression whose value is between 0 and 65,535. There are 18.2s clock ticks per second, so 18 is considered 1 second, etc...
May not be supported in Windows versions later than Win98 unless you:

1) use RapidQ2.inc
2) use this code:
' ---- SoundEx , fix by Jacques Phillipe
Declare Function GetVersion Lib "kernel32" Alias "GetVersion" () As Long
Declare Function Beep Lib "kernel32" Alias "Beep" (ByVal dwFreq As Long,_
 ByVal dwDuration As Long) As Long
DefInt SND_OS_Version = GetVersion And 255

Sub SoundEx (Freq As Long, Duration As Long) ' hz, 1/18 s = ~50 ms
  If SND_OS_Version < 5 Then ' >5 = XP
     Sound Freq, Duration
  Else
    Beep (Freq, Duration * 55) ' hz ms 55 = 1000/18.2 = 54.9
  End If
End Sub
$UNDEF Sound
$DEFINE Sound SoundEx
' ---- End SoundEx ------------------