speaker

Speakers allow playing notes and other sounds.

playSound(name[, volume[, pitch]])Plays a sound through the speaker.
playNote(name[, volume[, pitch]])Plays a note block note through the speaker.
playSound(name[, volume[, pitch]])Source

Plays a sound through the speaker.

This plays sounds similar to the /playsound command in Minecraft. It takes the namespaced path of a sound (e.g. minecraft:block.note_block.harp) with an optional volume and speed multiplier, and plays it through the speaker.

Parameters

  1. name string The name of the sound to play.
  2. volume? number The volume to play the sound at, from 0.0 to 3.0. Defaults to 1.0.
  3. pitch? number The speed to play the sound at, from 0.5 to 2.0. Defaults to 1.0.

Returns

  1. boolean Whether the sound could be played.

Throws

  • If the sound name couldn't be decoded.

playNote(name[, volume[, pitch]])Source

Plays a note block note through the speaker.

This takes the name of a note to play, as well as optionally the volume and pitch to play the note at.

The pitch argument uses semitones as the unit. This directly maps to the number of clicks on a note block. For reference, 0, 12, and 24 map to F#, and 6 and 18 map to C.

Parameters

  1. name string The name of the note to play.
  2. volume? number The volume to play the note at, from 0.0 to 3.0. Defaults to 1.0.
  3. pitch? number The pitch to play the note at in semitones, from 0 to 24. Defaults to 12.

Returns

  1. boolean Whether the note could be played.

Throws

  • If the instrument doesn't exist.