tone Playable

Create a musical tone that will play for some amount of time.

music.tonePlayable(262, music.beat(BeatFraction.Whole))

Parameters

  • note: is the note frequency as a number of Hertz (how high or low the tone is, also known as pitch). If note is less or equal to zero, no sound is played.
  • duration: is the number of milliseconds (one-thousandth of a second) that the tone lasts for. If duration is negative or zero, the sound will play continuously.

Returns

  • a playable object that contains the tone.

Example

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

let note = music.noteFrequency(Note.C);
music.play(music.tonePlayable(note, music.beat(BeatFraction.Whole)), music.PlaybackMode.UntilDone)

See also

melody playable, string playable