Skip to content
S Stewart edited this page Feb 10, 2019 · 11 revisions

Here is a list of peripherals which have been added or modified.


Speakers

Speakers are a block which allow computers to play music in world. They can be wrapped as peripherals (with name speaker) and used as upgrades for pocket computers and turtles.

Configuration

  • maxNotesPerTick = 8: The maximum number of notes which can be played in a single tick.

Methods

speaker.playNote(instrument: string[, volume:number[, pitch:number]]): boolean

Play a note with the given volume and pitch.

The instrument name corresponds to those provided by Note Blocks. It may be one of the following strings: harp, bass, snare, hat, pling, basedrum And for 1.12 and up the following sounds are also available: bell, chime, flute, guitar and xylophone.

Volume may be any number between 0 and 3 inclusive. 1 is the default, with 3 being the volume of a normal note block. Like note blocks, a higher volume does not imply a louder sound, merely that it can be heard further away.

The pitch may be a number between 0 and 24 inclusive, defaulting to 1. This represents the number of times one has right-clicked a noteblock. 0 representing F♯ and 24 representing F♯ 2 octaves higher.

This will return true if the note could be played or false if too many notes have been played in a single tick.

speaker.playSound(name: string[, volume:number[, pitch:number]]): boolean

Play a sound with the given volume and pitch.

The sound name corresponds to a resource name in Minecraft's sound.json file. For instance minecraft:entity.player.levelup is the sound one hears when leveling up.

Like .playNote, the volume may be any value between 0 and 3 defaulting to 1.

The pitch argument is slightly different. Instead this may be any value between 0 and 2, with a larger value representing a higher pitch. One may convert from .playNote to .playSound pitches with the following equation: 2 ^ ((pitch - 12) / 12).

This will return true if the sound could be played or false if too many sounds were played in a single tick.