<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.figuramc.org/index.php?action=history&amp;feed=atom&amp;title=Tutorials%2FSounds</id>
	<title>Tutorials/Sounds - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.figuramc.org/index.php?action=history&amp;feed=atom&amp;title=Tutorials%2FSounds"/>
	<link rel="alternate" type="text/html" href="https://wiki.figuramc.org/index.php?title=Tutorials/Sounds&amp;action=history"/>
	<updated>2026-04-14T23:48:28Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://wiki.figuramc.org/index.php?title=Tutorials/Sounds&amp;diff=123&amp;oldid=prev</id>
		<title>Manuel: Automated upload of converted .txt file.</title>
		<link rel="alternate" type="text/html" href="https://wiki.figuramc.org/index.php?title=Tutorials/Sounds&amp;diff=123&amp;oldid=prev"/>
		<updated>2024-09-26T20:45:15Z</updated>

		<summary type="html">&lt;p&gt;Automated upload of converted .txt file.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Playing sounds tutorial&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Using Figura you can play custom sounds and sounds from Minecraft itself.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This article assumes you know to avoid calling the player in init.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;playing-a-sound&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Playing A Sound ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The most common way to play a sound is through the &amp;lt;code&amp;gt;playSound&amp;lt;/code&amp;gt; function in the sound API.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;sounds:playSound(soundID, position, volume, pitch, loop)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see this function takes five arguments, the sound ID, the position it will be played, the volume (this dictates how close players need to be to hear the sound, default is 1), its pitch (default is 1), and whether or not it will start playing immediately after it ends (default is false).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For Minecraft sounds the sound ID is the internal name of the sound, you can find these on the [https://minecraft.wiki/w/Sounds.json/Java_Edition_values Minecraft Wiki] under the Sound Event column. It will play one of the sounds associated with that ID at random.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example, note that the id is a string because it’s in quotes:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;sounds:playSound(&amp;quot;entity.bat.ambient&amp;quot;, player:getPos())&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For this example I’m supplying the player position as the location or else it will play at (0,0,0) in the world itself. Because I left out the volume, pitch, and loop, the default values of 1, 1, and false were filled in by Figura. Meaning, it will play with default pitch, default volume, and it won’t loop.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example with the other arguments filled:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;sounds:playSound(&amp;quot;entity.bat.ambient&amp;quot;, player:getPos(), 1, 1, false)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;custom-sounds&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Custom Sounds ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Playing a custom sound is exactly the same as playing a Minecraft sound, except the sound ID is now the name of the sound file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ex: If your file is &amp;lt;code&amp;gt;horn.ogg&amp;lt;/code&amp;gt; then your playSound line would look like this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;sounds:playSound(&amp;quot;horn&amp;quot;, player:getPos())&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Minecraft will only play specific sound files, namely sounds that are .ogg files. Here’s an [https://audio.online-convert.com/convert-to-ogg online OGG converter]. You will want to change the audio channels setting to &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; and the audio codec to &amp;lt;code&amp;gt;Vorbis&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If your custom sound is stored in a subfolder in the avatar, the subfolder name gets added onto the sound name like this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;sounds:playSound(&amp;quot;subfolder.horn&amp;quot;, player:getPos())&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;mono-vs-stereo-sounds&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mono vs Stereo Sounds ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The audio channel type determines if the right and left ear will have two separate channels (meaning that the left and right ears can be different) or if they’ll have the same channel for both ears.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Mono sounds are half the size of stereo when it comes to file size. Mono also acts like your average vanilla sound meaning only people near you will be able to hear the sound.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Stereo sounds are much bigger (and sounds are already quite big when it comes to file size) and will play for &amp;#039;&amp;#039;everyone in the server&amp;#039;&amp;#039; similarly to activating an end portal. There’s no way to get around that other than to swap the audio channels to mono.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;alternative-ways-to-play-sounds&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Alternative Ways To Play Sounds ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you want to make a long or looping sound follow your movement you’re going to need to use a different method for playing sounds.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You have to store a reference to the sound in a variable so you can use it later&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local wDeath = sounds[&amp;quot;entity.wither.death&amp;quot;]&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you have the wither death sound available for your use wherever within that local scope.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;wDeath:play():loop(true)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Will play the sound and make it loop, but without a position it will be at (0,0,0) in the world.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;function events.tick()&lt;br /&gt;
&lt;br /&gt;
    wDeath:pos(player:getPos())&lt;br /&gt;
&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Full example:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local wDeath = sounds[&amp;quot;entity.wither.death&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
wDeath:play():loop(true)&lt;br /&gt;
&lt;br /&gt;
function events.tick()&lt;br /&gt;
&lt;br /&gt;
    wDeath:pos(player:getPos())&lt;br /&gt;
&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can alter the volume, pitch, and loop with this method as well.&lt;/div&gt;</summary>
		<author><name>Manuel</name></author>
	</entry>
</feed>