Skip to content

Instantly share code, notes, and snippets.

@tryashtar
Last active November 25, 2023 15:56
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tryashtar/95383f0da9ce282a90e56188a936c641 to your computer and use it in GitHub Desktop.
Save tryashtar/95383f0da9ce282a90e56188a936c641 to your computer and use it in GitHub Desktop.
How sounds work in Bedrock Edition

sound_definitions.json

There are two different ways to format this file:

  • All the sound event keys in the root
  • Sound event keys in an object called sound_definitions, with an additional key format_version set to 1.14.0

You should always use the latter, as using the former prevents fields like pitch from working.

You can reference sounds in OGG or FSB format. FSB sounds do not fade properly with distance, so prefer OGG unless the sound is intended to be global like music.

volume:

  • Sets actual audible volume, making the sound louder or quieter.
  • 1.0 = unchanged volume.

pitch:

  • Sets pitch and tempo.
  • 1.0 = unchanged pitch.
  • Larger values are higher and faster, lower values are deeper and slower.

is3D:

  • Defaults to true. If set to false, the sound will work like music: playing directly to the device, never attenuating or panning.
  • This is forced to false automatically if category is set to ui.

min_distance / max_distance:

  • Using one of these determines which attenuation formula Minecraft will use.
  • If you use min_distance, the sound has exponential attenuation that quickly decays but never reaches zero. The number provided will be the radius in blocks the sound will be at full volume before attenuation begins. It defaults to 1.
  • If you use max_distance, the sound has linear attenuation, from full volume down to zero. The number provided is the full audible radius in blocks.
  • If you use both together, and max_distance is greater than or equal to min_distance, exponential attenuation will be used, but with a volume minimum: the sound will never go quieter than it is at max_distance blocks away.
  • A particular sound file can only be assigned to one event that uses these keys, otherwise it will "leak" to others and only one will work properly.
  • You must include the decimal point when specifying these. If you just use an integer, they will be silently ignored.

/playsound

position:

  • If this is left off, all selected players will play the sound at their own position. If this is included, the sound is played at the provided location.

volume:

  • If less than 1.0, reduces actual volume.
  • By default, sounds will only be sent to players within 16 blocks of the sound origin, even if the audible range of the sound is higher.
  • If greater than 1.0, multiplies that 16 block range. This does not affect the volume or attenuation of the sound, it only changes which players will be sent a packet.
  • In effect, this argument is indistinguishable from a r= check in the selector.

pitch:

  • Changes the pitch, just like above.

minimumVolume:

  • If this is specified, any players outside of the range set by volume will play the sound at their own position with the specified volume between 0 and 1.
  • The separate sound is still positional and attenuates like normal.
  • In effect, this argument is indistinguishable from a second /playsound command with no position specified, and a rm= check in the selector.

sounds.json

volume:

  • Works exactly the same as volume in /playsound above.
  • If specified in an individual event, overrides the value used for the mob overall.
  • Can be specified as [min, max] for a random value.

pitch:

  • Changes the pitch of the played sound.
  • If specified in an individual event, overrides the value used for the mob overall.
  • Can be specified as [min, max] for a random value.

Animations

Sounds only play if the mob is being rendered at the time (on-screen and 70 blocks away or closer), or if you enable should_update_effects_offscreen in the client entity file.

Unlike the other two sound sources that have a 16-block packet cutoff point by default, animation sounds play at any distance. Since by default sounds never attenuate to zero, it's recommended to use max_distance for sounds used here.

Attenuation formula

Here I have a more visual resource for how sounds attenuate with distance when using different parameters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment