Skip to content

Latest commit

 

History

History
40 lines (27 loc) · 1.14 KB

File metadata and controls

40 lines (27 loc) · 1.14 KB

play Tone

Play a musical tone on the speaker for some amount of time.

music.playTone(Note.C, 10)

#simnote

~hint

Simulator: ||music:play tone|| works on the @boardname@. It might not work in the simulator on every browser.

~

Parameters

  • frequency is the number of Hertz (how high or low the tone is, also known as pitch).
  • ms is the number of milliseconds (one-thousandth of a second) that the tone lasts for.

Special handling of values

  • If frequency is less or equal to zero, the sound is stopped.
  • If ms is negative or zero, the sound is not stopped and will keep beeping.

Example #example

Store the musical note 'C' in the variable freq and play that note for 1000 milliseconds (one second).

let freq = music.noteFrequency(Note.C);
music.playTone(freq, 1000)

See also #seealso

rest, ring tone , tempo, set tempo, change tempo by

music