Skip to main content

Presets

Presets are functions that adjust a Sound as it is fetched, before it is parented, for property values you set over and over.

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.
  • A built-in preset never throws. A builder given a bad argument warns right away and returns a preset that does nothing, so the sounds that use it still play.
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​

Presets.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. An argument that is not a function warns and is left out.

local myCombinedPreset = VluxySF.Presets.Combine(
	VluxySF.Presets.NaturalPlaybackJitter(1, 0.1),
	VluxySF.Presets.NaturalVolumeJitter(0.7, 0.15)
)

local myCombinedPreset2 = VluxySF.Presets.Combine(
	myCombinedPreset,
	VluxySF.Presets.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​

Presets.Parent(
parent: Instance--

The parent to set the sound too.

) → (Sound) → ()--

Closure of the preset.

Sets the parent of a sound.

local myPreset = VluxySF.Presets.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​

Presets.Volume(
volume: number--

The volume to set the sound too.

) → (Sound) → ()--

Closure of the preset.

Sets the volume of a sound.

local myPreset = VluxySF.Presets.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​

Presets.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 = VluxySF.Presets.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​

Presets.NaturalVolumeJitter(
center: number?,--

The central value of the jitter. Default is 0.5.

spread: number?--

The spread of the jitter. Default is 0.1.

) → (Sound) → ()--

Closure of the preset.

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

local myPreset = VluxySF.Presets.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​

Presets.NaturalPlaybackJitter(
center: number?,--

The central value of the jitter. Default is 1.

spread: number?--

The spread of the jitter. Default is 0.1.

) → (Sound) → ()--

Closure of the preset.

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

local myPreset = VluxySF.Presets.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​

Presets.RandomVolumeJitter(
center: number?,--

The central value of the jitter. Default is 0.5.

spread: number?--

The spread of the jitter. Default is 0.1.

) → (Sound) → ()--

Closure of the preset.

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

local myPreset = VluxySF.Presets.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​

Presets.RandomPlaybackJitter(
center: number?,--

The central value of the jitter. Default is 1.

spread: number?--

The spread of the jitter. Default is 0.1.

) → (Sound) → ()--

Closure of the preset.

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

local myPreset = VluxySF.Presets.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. An argument that is not a function warns and is left out.\n:::\n\n```lua\nlocal myCombinedPreset = VluxySF.Presets.Combine(\n\tVluxySF.Presets.NaturalPlaybackJitter(1, 0.1),\n\tVluxySF.Presets.NaturalVolumeJitter(0.7, 0.15)\n)\n\nlocal myCombinedPreset2 = VluxySF.Presets.Combine(\n\tmyCombinedPreset,\n\tVluxySF.Presets.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": 107,
                "path": "lib/Api/Presets.luau"
            }
        },
        {
            "name": "Parent",
            "desc": "Sets the parent of a sound.\n\n```lua\nlocal myPreset = VluxySF.Presets.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": 151,
                "path": "lib/Api/Presets.luau"
            }
        },
        {
            "name": "Volume",
            "desc": "Sets the volume of a sound.\n\n```lua\nlocal myPreset = VluxySF.Presets.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": 187,
                "path": "lib/Api/Presets.luau"
            }
        },
        {
            "name": "PlaybackSpeed",
            "desc": "Sets the playback speed of a sound.\n\n```lua\nlocal myPreset = VluxySF.Presets.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": 214,
                "path": "lib/Api/Presets.luau"
            }
        },
        {
            "name": "NaturalVolumeJitter",
            "desc": "Uses `Jitter.Natural` to apply a natural jitter to the volume of the sound.\n\n```lua\nlocal myPreset = VluxySF.Presets.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. Default is 0.5.",
                    "lua_type": "number?"
                },
                {
                    "name": "spread",
                    "desc": "The spread of the jitter. Default is 0.1.",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "Closure of the preset.",
                    "lua_type": "(Sound) -> ()"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 244,
                "path": "lib/Api/Presets.luau"
            }
        },
        {
            "name": "NaturalPlaybackJitter",
            "desc": "Uses `Jitter.Natural` to apply a natural jitter to the playback speed of the sound.\n\n```lua\nlocal myPreset = VluxySF.Presets.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. Default is 1.",
                    "lua_type": "number?"
                },
                {
                    "name": "spread",
                    "desc": "The spread of the jitter. Default is 0.1.",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "Closure of the preset.",
                    "lua_type": "(Sound) -> ()"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 277,
                "path": "lib/Api/Presets.luau"
            }
        },
        {
            "name": "RandomVolumeJitter",
            "desc": "Uses `Jitter.Uniform` to apply a random jitter to the volume of the sound.\n\n```lua\nlocal myPreset = VluxySF.Presets.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. Default is 0.5.",
                    "lua_type": "number?"
                },
                {
                    "name": "spread",
                    "desc": "The spread of the jitter. Default is 0.1.",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "Closure of the preset.",
                    "lua_type": "(Sound) -> ()"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 312,
                "path": "lib/Api/Presets.luau"
            }
        },
        {
            "name": "RandomPlaybackJitter",
            "desc": "Uses `Jitter.Uniform` to apply a random jitter to the playback speed of the sound.\n\n```lua\nlocal myPreset = VluxySF.Presets.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. Default is 1.",
                    "lua_type": "number?"
                },
                {
                    "name": "spread",
                    "desc": "The spread of the jitter. Default is 0.1.",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "Closure of the preset.",
                    "lua_type": "(Sound) -> ()"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 345,
                "path": "lib/Api/Presets.luau"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Presets",
    "desc": "Presets are functions that adjust a `Sound` as it is fetched, before it is parented, for property values you set\nover and over.\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- A built-in preset never throws. A builder given a bad argument warns right away and returns a preset that does\n  nothing, so the sounds that use it still play.\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": 72,
        "path": "lib/Api/Presets.luau"
    }
}