Click or drag to resize

Tone Function

X#
Sound a speaker tone for a specified frequency and duration. Note:
Tone() is a compatibility function and is no longer recommended.
It is superseded by the Windows API MessageBeep(), SndPlaySound(), and the MCI family of functions. MessageBeep() is defined in the System Library, whereas the other functions are defined in the Win32 API library. In order to use these functions, you must include the Win32 API library in your application's search path.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.19
Syntax
 FUNCTION Tone(
	wFrequency AS DWORD,
	wDuration AS DWORD
) AS USUAL
Request Example View Source

Parameters

wFrequency
Type: DWord
The frequency of the tone to sound.
wDuration
Type: DWord
The duration of the tone measured in increments of 1/18 of a second.
For example, an wDuration value of 18 represents one second.
For both arguments, noninteger values are truncated — not rounded — to their integer portion.

Return Value

Type: Usual
Remarks
Tone() is a sound function that indicates various program states to the user.
These can be error states, boundary conditions, or the end of a time-consuming process.
For example, an error state would sound an error tone before alerting the user with a message or interactive dialog box.
A boundary condition might indicate that the user is attempting to cursor past the top or bottom of a column in a TBrowse object.
A batch process also might indicate its completion with a sound to alert the user, in case the user has turned away from the screen. Tone() works by sounding the speaker at the specified frequency for the specified duration.
The duration is measured in increments of 1/18 of a second.
The frequency is measured in hertz (cycles per second). Frequencies of less than 20 are inaudible.
The table below shows the frequencies of standard musical notes. Note:
Tone() works only on IBM PC and 100% compatible computers. Pitch Frequency Pitch Frequency C 130.80 mid C 261.70 C# 138.60 C# 277.20 D 146.80 D 293.70 D# 155.60 D# 311.10 E 164.80 E 329.60 F 174.60 F 349.20 F# 185.00 F# 370.00 G 196.00 G 392.00 G# 207.70 G# 415.30 A 220.00 A 440.00 A# 233.10 A# 466.20 B 246.90 B 493.90 C 523.30
Examples
This example is a beep function that indicates that a batch operation has completed:
X#
1FUNCTION DoneBeep()
2    Tone(300, 1)
3    Tone(100, 1)
4    Tone(300, 1)
5    Tone(100, 1)
This example is a tone sequence that indicates invalid keystrokes or boundary conditions:
X#
1FUNCTION ErrorBeep()
2    Tone(100, 3)
See Also