Skip to main content

SoundPresets

Presets are functions that you can apply to your sounds to quickly change reoccuring property values.

INFO
  • Presets are closures that get passed to your fetching functions.
  • You can create your own presets and combine them with the built in ones.
  • When a preset runs everything should be cleaned up before exiting the function block.
TIP

You can also make your own presets and store them in a module for easy access.

local CustomPresets = {}

function CustomPresets.DoSomething(doTheThing: boolean): (Sound) -> ()
	return function(sound: Sound)
		if doTheThing then
			sound.Volume = 0.5
		else
			sound.Volume = 1
		end
	end
end

return CustomPresets

Functions​

Combine​

SoundPresets.Combine(
...: (Sound) → ()--

Your Preset Closures to combine.

) → (Sound) → ()--

Closure of the combined presets.

Combines presets together into 1 reusable preset.

INFO

Presets are applied in sequence from first to last.

local myCombinedPreset = SoundPresets.Combine(
	SoundPresets.NaturalPlaybackJitter(0.8, 0.1),
	SoundPresets.NaturalVolumeJitter(0.7, 0.15)
)

local myCombinedPreset2 = SoundPresets.Combine(
	myCombinedPreset,
	SoundPresets.Parent(workspace.Sounds)
)

local sound1 = VluxySF.Fetch("mySound1", nil, myCombinedPreset)
local sound2 = VluxySF.Fetch("mySound2", nil, myCombinedPreset)

local sound3 = VluxySF.Fetch("mySound3", nil, myCombinedPreset2)
local sound4 = VluxySF.Fetch("mySound4", nil, myCombinedPreset2)

Parent​

SoundPresets.Parent(
parent: Instance--

The parent to set the sound too.

) → (Sound) → ()--

Closure of the preset.

Sets the parent of a sound.

local myPreset = SoundPresets.Parent(workspace.Sounds)

local sound1 = VluxySF.Fetch("mySound1", nil, myPreset)
local sound2 = VluxySF.Fetch("mySound2", nil, myPreset)
local sound3 = VluxySF.Fetch("mySound3", nil, myPreset)

Volume​

SoundPresets.Volume(
volume: number--

The volume to set the sound too.

) → (Sound) → ()--

Closure of the preset.

Sets the volume of a sound.

local myPreset = SoundPresets.Volume(0.1)

local sound1 = VluxySF.Fetch("mySound1", nil, myPreset)
local sound2 = VluxySF.Fetch("mySound2", nil, myPreset)
local sound3 = VluxySF.Fetch("mySound3", nil, myPreset)

PlaybackSpeed​

SoundPresets.PlaybackSpeed(
speed: number--

The playback speed to set for the sound too.

) → (Sound) → ()--

Closure of the preset.

Sets the playback speed of a sound.

local myPreset = SoundPresets.PlaybackSpeed(1.3)

local sound1 = VluxySF.Fetch("mySound1", nil, myPreset)
local sound2 = VluxySF.Fetch("mySound2", nil, myPreset)
local sound3 = VluxySF.Fetch("mySound3", nil, myPreset)

NaturalVolumeJitter​

SoundPresets.NaturalVolumeJitter(
center: number?,--

The central value of the jitter.

spread: number?--

The spread of the jitter.

) → (Sound) → ()--

Closure of the preset.

Uses Jitter.UnitLog to apply a natural jitter to the volume of the sound.

local myPreset = SoundPresets.NaturalVolumeJitter(0.8, 0.1)

local sound1 = VluxySF.Fetch("mySound1", nil, myPreset)
local sound2 = VluxySF.Fetch("mySound2", nil, myPreset)
local sound3 = VluxySF.Fetch("mySound3", nil, myPreset)

NaturalPlaybackJitter​

SoundPresets.NaturalPlaybackJitter(
center: number?,--

The central value of the jitter.

spread: number?--

The spread of the jitter.

) → (Sound) → ()--

Closure of the preset.

Uses Jitter.UnitLog to apply a natural jitter to the playback speed of the sound.

local myPreset = SoundPresets.NaturalPlaybackJitter(1, 0.1)

local sound1 = VluxySF.Fetch("mySound1", nil, myPreset)
local sound2 = VluxySF.Fetch("mySound2", nil, myPreset)
local sound3 = VluxySF.Fetch("mySound3", nil, myPreset)

RandomVolumeJitter​

SoundPresets.RandomVolumeJitter(
center: number?,--

The central value of the jitter.

spread: number?--

The spread of the jitter.

) → (Sound) → ()--

Closure of the preset.

Uses Jitter.Default to apply a random jitter to the volume of the sound.

local myPreset = SoundPresets.RandomVolumeJitter(0.8, 0.1)

local sound1 = VluxySF.Fetch("mySound1", nil, myPreset)
local sound2 = VluxySF.Fetch("mySound2", nil, myPreset)
local sound3 = VluxySF.Fetch("mySound3", nil, myPreset)

RandomPlaybackJitter​

SoundPresets.RandomPlaybackJitter(
center: number?,--

The central value of the jitter.

spread: number?--

The spread of the jitter.

) → (Sound) → ()--

Closure of the preset.

Uses Jitter.Default to apply a random jitter to the playback speed of the sound.

local myPreset = SoundPresets.RandomPlaybackJitter(1, 0.1)

local sound1 = VluxySF.Fetch("mySound1", nil, myPreset)
local sound2 = VluxySF.Fetch("mySound2", nil, myPreset)
local sound3 = VluxySF.Fetch("mySound3", nil, myPreset)
Show raw api
{
    "functions": [
        {
            "name": "Combine",
            "desc": "Combines presets together into 1 reusable preset.\n\n:::info\nPresets are applied in sequence from first to last.\n:::\n\n```lua\nlocal myCombinedPreset = SoundPresets.Combine(\n\tSoundPresets.NaturalPlaybackJitter(0.8, 0.1),\n\tSoundPresets.NaturalVolumeJitter(0.7, 0.15)\n)\n\nlocal myCombinedPreset2 = SoundPresets.Combine(\n\tmyCombinedPreset,\n\tSoundPresets.Parent(workspace.Sounds)\n)\n\nlocal sound1 = VluxySF.Fetch(\"mySound1\", nil, myCombinedPreset)\nlocal sound2 = VluxySF.Fetch(\"mySound2\", nil, myCombinedPreset)\n\nlocal sound3 = VluxySF.Fetch(\"mySound3\", nil, myCombinedPreset2)\nlocal sound4 = VluxySF.Fetch(\"mySound4\", nil, myCombinedPreset2)\n```",
            "params": [
                {
                    "name": "...",
                    "desc": "Your Preset Closures to combine.",
                    "lua_type": "(Sound) -> ()"
                }
            ],
            "returns": [
                {
                    "desc": "Closure of the combined presets.",
                    "lua_type": "(Sound) -> ()"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 73,
                "path": "lib/Api/Presets.luau"
            }
        },
        {
            "name": "Parent",
            "desc": "Sets the parent of a sound.\n\n```lua\nlocal myPreset = SoundPresets.Parent(workspace.Sounds)\n\nlocal sound1 = VluxySF.Fetch(\"mySound1\", nil, myPreset)\nlocal sound2 = VluxySF.Fetch(\"mySound2\", nil, myPreset)\nlocal sound3 = VluxySF.Fetch(\"mySound3\", nil, myPreset)\n```",
            "params": [
                {
                    "name": "parent",
                    "desc": "The parent to set the sound too.",
                    "lua_type": "Instance"
                }
            ],
            "returns": [
                {
                    "desc": "Closure of the preset.",
                    "lua_type": "(Sound) -> ()"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 103,
                "path": "lib/Api/Presets.luau"
            }
        },
        {
            "name": "Volume",
            "desc": "Sets the volume of a sound.\n\n```lua\nlocal myPreset = SoundPresets.Volume(0.1)\n\nlocal sound1 = VluxySF.Fetch(\"mySound1\", nil, myPreset)\nlocal sound2 = VluxySF.Fetch(\"mySound2\", nil, myPreset)\nlocal sound3 = VluxySF.Fetch(\"mySound3\", nil, myPreset)\n```",
            "params": [
                {
                    "name": "volume",
                    "desc": "The volume to set the sound too.",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "Closure of the preset.",
                    "lua_type": "(Sound) -> ()"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 126,
                "path": "lib/Api/Presets.luau"
            }
        },
        {
            "name": "PlaybackSpeed",
            "desc": "Sets the playback speed of a sound.\n\n```lua\nlocal myPreset = SoundPresets.PlaybackSpeed(1.3)\n\nlocal sound1 = VluxySF.Fetch(\"mySound1\", nil, myPreset)\nlocal sound2 = VluxySF.Fetch(\"mySound2\", nil, myPreset)\nlocal sound3 = VluxySF.Fetch(\"mySound3\", nil, myPreset)\n```",
            "params": [
                {
                    "name": "speed",
                    "desc": "The playback speed to set for the sound too.",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "Closure of the preset.",
                    "lua_type": "(Sound) -> ()"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 149,
                "path": "lib/Api/Presets.luau"
            }
        },
        {
            "name": "NaturalVolumeJitter",
            "desc": "Uses `Jitter.UnitLog` to apply a natural jitter to the volume of the sound.\n\n```lua\nlocal myPreset = SoundPresets.NaturalVolumeJitter(0.8, 0.1)\n\nlocal sound1 = VluxySF.Fetch(\"mySound1\", nil, myPreset)\nlocal sound2 = VluxySF.Fetch(\"mySound2\", nil, myPreset)\nlocal sound3 = VluxySF.Fetch(\"mySound3\", nil, myPreset)\n```",
            "params": [
                {
                    "name": "center",
                    "desc": "The central value of the jitter.",
                    "lua_type": "number?"
                },
                {
                    "name": "spread",
                    "desc": "The spread of the jitter.",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "Closure of the preset.",
                    "lua_type": "(Sound) -> ()"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 175,
                "path": "lib/Api/Presets.luau"
            }
        },
        {
            "name": "NaturalPlaybackJitter",
            "desc": "Uses `Jitter.UnitLog` to apply a natural jitter to the playback speed of the sound.\n\n```lua\nlocal myPreset = SoundPresets.NaturalPlaybackJitter(1, 0.1)\n\nlocal sound1 = VluxySF.Fetch(\"mySound1\", nil, myPreset)\nlocal sound2 = VluxySF.Fetch(\"mySound2\", nil, myPreset)\nlocal sound3 = VluxySF.Fetch(\"mySound3\", nil, myPreset)\n```",
            "params": [
                {
                    "name": "center",
                    "desc": "The central value of the jitter.",
                    "lua_type": "number?"
                },
                {
                    "name": "spread",
                    "desc": "The spread of the jitter.",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "Closure of the preset.",
                    "lua_type": "(Sound) -> ()"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 201,
                "path": "lib/Api/Presets.luau"
            }
        },
        {
            "name": "RandomVolumeJitter",
            "desc": "Uses `Jitter.Default` to apply a random jitter to the volume of the sound.\n\n```lua\nlocal myPreset = SoundPresets.RandomVolumeJitter(0.8, 0.1)\n\nlocal sound1 = VluxySF.Fetch(\"mySound1\", nil, myPreset)\nlocal sound2 = VluxySF.Fetch(\"mySound2\", nil, myPreset)\nlocal sound3 = VluxySF.Fetch(\"mySound3\", nil, myPreset)\n```",
            "params": [
                {
                    "name": "center",
                    "desc": "The central value of the jitter.",
                    "lua_type": "number?"
                },
                {
                    "name": "spread",
                    "desc": "The spread of the jitter.",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "Closure of the preset.",
                    "lua_type": "(Sound) -> ()"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 229,
                "path": "lib/Api/Presets.luau"
            }
        },
        {
            "name": "RandomPlaybackJitter",
            "desc": "Uses `Jitter.Default` to apply a random jitter to the playback speed of the sound.\n\n```lua\nlocal myPreset = SoundPresets.RandomPlaybackJitter(1, 0.1)\n\nlocal sound1 = VluxySF.Fetch(\"mySound1\", nil, myPreset)\nlocal sound2 = VluxySF.Fetch(\"mySound2\", nil, myPreset)\nlocal sound3 = VluxySF.Fetch(\"mySound3\", nil, myPreset)\n```",
            "params": [
                {
                    "name": "center",
                    "desc": "The central value of the jitter.",
                    "lua_type": "number?"
                },
                {
                    "name": "spread",
                    "desc": "The spread of the jitter.",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "Closure of the preset.",
                    "lua_type": "(Sound) -> ()"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 255,
                "path": "lib/Api/Presets.luau"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "SoundPresets",
    "desc": "Presets are functions that you can apply to your sounds to quickly change reoccuring property values.\n\n:::info\n- Presets are closures that get passed to your fetching functions.\n- You can create your own presets and combine them with the built in ones.\n- When a preset runs everything should be cleaned up before exiting the function block.\n:::\n\n:::tip\nYou can also make your own presets and store them in a module for easy access.\n```lua\nlocal CustomPresets = {}\n\nfunction CustomPresets.DoSomething(doTheThing: boolean): (Sound) -> ()\n\treturn function(sound: Sound)\n\t\tif doTheThing then\n\t\t\tsound.Volume = 0.5\n\t\telse\n\t\t\tsound.Volume = 1\n\t\tend\n\tend\nend\n\nreturn CustomPresets\n```\n:::",
    "source": {
        "line": 38,
        "path": "lib/Api/Presets.luau"
    }
}