Audio
The audio functions make use of the Audio and Speech Synthesis APIs in most modern browsers. It is important to note that most browsers will only play audio after the user has interacted with the page through a mouse click or key pressed.
Functions
beep()
Makes a simple beep sound.
frequency(frequency, duration = 0.25)
Play a frequency for a specified duration of time.
Parameters
- frequency Number Frequncy in hz.
- duration Number Duration of time in seconds.
Returns
Nothingnote(note, beats = 1)
Play a note for the specified number of beats. The length of a single beat is set by the tempo property.
Parameters
- note String Note to play (e.g. "c", "c5", "c5#", etc.)
- duration Number Number of beats to play the note.
Returns
Nothingsong(note1, beats1, note2, beats2, ...)
Play a song made up of the specified notes for the specified number of beats. If the beats value is left out, the default of 1 beat will be used.
Parameters
- note1..noten String Note to play (e.g. "c", "c5", "c5#", etc.)
- beats1..beatsn Number Number of beats to play the note.
Returns
Nothingsound(file)
Play the audio file at the specified path. This file must be on hosted on the same domain. Formats supported by most browsers include .mp3, .wav, and .ogg.
Parameters
- file String Path to audio file.
- beats1..beatsn Number Number of beats to play the note.
Returns
Nothingspeak(text)
Use speech synthesis to say the specified text.
Parameters
- text String Text to say.
Returns
NothingProperties
tempo
A Number
defining the number of beats per minute.