Device.errorBeep()

Overview

Plays an error beep through the device's speaker. An error beep is a two-toned beep with the first beep higher than the second beep.

Use cases

You want your script to play an error beep.

You want to override the default beeps using WLEvent.on(“beep”, …) and play a custom error beep(s) instead.

Remarks

Calls to Device.errorBeep() are asynchronous and added to a beep queue, meaning that this call will immediately return.

Format

Device.errorBeep(frequency, durationMilliseconds, trailingSilence, volume);

Parameter Description Type Required Notes
frequency Tone frequency in hertz for the second beep. The first beep will be pitched higher by 400Hz. Number Required Integer between 100 and 2000
durationMilliseconds Duration of a regular beep in milliseconds. An error beep is 4x longer than a regular beep. For example, if you specify 500 ms, the first tone beeps for 1000 ms and the second tone beeps for 1000 ms, making the total duration of the error beep 2000 ms. Number Required Integer between 1 and 100000
trailingSilence Amount of time in milliseconds that no tone should be played after the second beep. Number Required Integer between 0 and 100000
volume Override volume of the generated beep. Number Optional

Number between 0.0 and 1.0 (loudest). If this parameter is undefined, the beep uses the volume set with Device.setBeepVolume().

Added in version 2.1.21

Example 1

Copy
/* The device will beep twice, once at 800Hz and once at 400Hz, for a total duration of 2000
 * milliseconds with a 50 millisecond trailing silence after the second beep.
 */
 
 Device.errorBeep(400,500,50);

Example 2

Copy
/* The device will beep twice at volume 0.2, once at 1600Hz and once at 1200Hz,
 * for a total duration of 1000 milliseconds with a 50 millisecond trailing silence
 * after the second beep.
 */

Device.errorBeep(1200, 250, 50, 0.2);