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
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
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)