Skip to main content

Jitter

Jitter functions meant for Volume and Pitch properties of sounds. Can be used in other contexts as well.

INFO

All jitter functions are clamped from 0 to 10.

Functions​

Default​

Jitter.Default(
center: number,--

The central value around which the jitter will occur.

spread: number--

The maximum deviation from the center value.

) → () → number--

Generates the jitter value when called.

Standard Jitter function that randomly varies from the center value +- the spread.

local myJitter = Jitter.Default(1, 0.15)

local sound1 = ...
sound1.PlaybackSpeed = myJitter() -- Sets a random value.

local sound2 = ...
sound2.PlaybackSpeed = myJitter() -- Sets another random value.

Range​

Jitter.Range(
min: number,--

The minimum value for the jitter range.

max: number--

The maximum value for the jitter range.

) → () → number--

Generates the jitter value when called.

Essentially just a random number that requires a specified range.

local myJitter = Jitter.Range(0.85, 1.15)

local sound1 = ...
sound1.PlaybackSpeed = myJitter() -- Sets a random value.

local sound2 = ...
sound2.PlaybackSpeed = myJitter() -- Sets another random value.

Scale​

Jitter.Scale(
spread: number--

The maximum deviation from the center value.

) → () → number--

Generates the jitter value when called.

Very similar to Jitter.Default but the center value is 1.

local myJitter = Jitter.Scale(0.15)

local sound1 = ...
sound1.PlaybackSpeed = myJitter() -- Sets a random value.

local sound2 = ...
sound2.PlaybackSpeed = myJitter() -- Sets another random value.

UnitLog​

Jitter.UnitLog(
center: number,--

The central value around which the jitter will occur.

spread: number--

The maximum deviation from the center value.

) → () → number--

Generates the jitter value when called.

Produces jitter values with a shaped distribution that favors the center value.

local myJitter = Jitter.UnitLog(1, 0.15)

local sound1 = ...
sound1.PlaybackSpeed = myJitter() -- Sets a random shaped value.

local sound2 = ...
sound2.PlaybackSpeed = myJitter() -- Sets another random shaped value.
TIP
This can be used to make more natural repetitious sounds like footsteps.
Show raw api
{
    "functions": [
        {
            "name": "Default",
            "desc": "Standard Jitter function that randomly varies from the center value +- the spread.\n\n```lua\nlocal myJitter = Jitter.Default(1, 0.15)\n\nlocal sound1 = ...\nsound1.PlaybackSpeed = myJitter() -- Sets a random value.\n\nlocal sound2 = ...\nsound2.PlaybackSpeed = myJitter() -- Sets another random value.\n```",
            "params": [
                {
                    "name": "center",
                    "desc": "The central value around which the jitter will occur.",
                    "lua_type": "number"
                },
                {
                    "name": "spread",
                    "desc": "The maximum deviation from the center value.",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "Generates the jitter value when called.",
                    "lua_type": "() -> number"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 39,
                "path": "lib/Api/Jitter.luau"
            }
        },
        {
            "name": "Range",
            "desc": "Essentially just a random number that requires a specified range.\n\n```lua\nlocal myJitter = Jitter.Range(0.85, 1.15)\n\nlocal sound1 = ...\nsound1.PlaybackSpeed = myJitter() -- Sets a random value.\n\nlocal sound2 = ...\nsound2.PlaybackSpeed = myJitter() -- Sets another random value.\n```",
            "params": [
                {
                    "name": "min",
                    "desc": "The minimum value for the jitter range.",
                    "lua_type": "number"
                },
                {
                    "name": "max",
                    "desc": "The maximum value for the jitter range.",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "Generates the jitter value when called.",
                    "lua_type": "() -> number"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 67,
                "path": "lib/Api/Jitter.luau"
            }
        },
        {
            "name": "Scale",
            "desc": "Very similar to `Jitter.Default` but the center value is 1.\n\n```lua\nlocal myJitter = Jitter.Scale(0.15)\n\nlocal sound1 = ...\nsound1.PlaybackSpeed = myJitter() -- Sets a random value.\n\nlocal sound2 = ...\nsound2.PlaybackSpeed = myJitter() -- Sets another random value.\n```",
            "params": [
                {
                    "name": "spread",
                    "desc": "The maximum deviation from the center value.",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "Generates the jitter value when called.",
                    "lua_type": "() -> number"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 94,
                "path": "lib/Api/Jitter.luau"
            }
        },
        {
            "name": "UnitLog",
            "desc": "Produces jitter values with a shaped distribution that favors the center value.\n\n```lua\nlocal myJitter = Jitter.UnitLog(1, 0.15)\n\nlocal sound1 = ...\nsound1.PlaybackSpeed = myJitter() -- Sets a random shaped value.\n\nlocal sound2 = ...\nsound2.PlaybackSpeed = myJitter() -- Sets another random shaped value.\n```\n\n:::tip\n\tThis can be used to make more natural repetitious sounds like footsteps.\n:::",
            "params": [
                {
                    "name": "center",
                    "desc": "The central value around which the jitter will occur.",
                    "lua_type": "number"
                },
                {
                    "name": "spread",
                    "desc": "The maximum deviation from the center value.",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "Generates the jitter value when called.",
                    "lua_type": "() -> number"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 126,
                "path": "lib/Api/Jitter.luau"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Jitter",
    "desc": "Jitter functions meant for Volume and Pitch properties of sounds. Can be used in other contexts as well.\n\n:::info\nAll jitter functions are clamped from 0 to 10.\n:::",
    "source": {
        "line": 17,
        "path": "lib/Api/Jitter.luau"
    }
}