Stop overcomplicating sounds, let's keep it simple:
Erika.new():Play( SOUND_ID_HERE )
Better yet, let's add a visualizer too:
Erika.new():Play( SOUND_ID_HERE ):CreateVisualizer2D( GuiObject , {
BarCount = 128,
BarGap = 0,
} )
And, let's have instances groove to the beat:
Erika.new():Play( SOUND_ID_HERE ).OnBeat:Connect(function( Scale: number )
UIScale.Scale = 1 + Scale * 0.5
end)
Tip
Methods are chainable, you can have it all!
- One-line setup from
SoundIdto a playing, analyzable sound - Built-in beat detection with
Tangela.OnBeat, driven by Roblox'sAudioAnalyzer - Fully optional configuration with sensible defaults for everything
- Support for your own
AudioPlayer&AudioAnalyzerinstances
- Insert the Erika library into any client-accessible service (e.g.
ReplicatedStorage,StarterPlayerScripts) - Require Erika:
local Erika = require(<path to Erika>)
- Read the API below to get started
local Tangela = Erika.new( string , {
AudioPlayer = AUDIO_PLAYER_HERE,
AudioAnalyzer = AUDIO_ANALYZER_HERE,
WindowSize = Enum.AudioWindowSize[SIZE_HERE],
} )
Tangela:Set{
SoundId = SOUND_ID_HERE,
Looping = boolean,
PlaybackSpeed = number,
Volume = number,
}
Note
Erika is the class. Tangela is the object created by Erika.new.
Erika.new accepts optional constructor parameters that must be provided when creating the object. These parameters cannot be added after creation. Tangela:Set handles properties that can be configured or changed after the object has been created.
Warning
If you provide custom audio instances, provide both AudioPlayer and AudioAnalyzer together. Erika does not destroy user-provided instances.
Tangela:Destroy()
Stops beat detection, destroys every visualizer, disconnects subscriptions, and destroys only the AudioPlayer and AudioAnalyzer instances created internally. User-provided audio instances remain owned by the caller.
Tangela:Play{ SoundId = SOUND_ID_HERE , Looping = boolean , PlaybackSpeed = number , Volume = number }
Tangela:Play( SOUND_ID_HERE )
Plays the sound, overriding SoundId, Looping, or PlaybackSpeed if provided.
Note
Tangela:Play accepts either a table of options (same syntax as Tangela:Set) or just a SoundId directly.
Tangela:Stop( boolean? )
Stops the sound. If the passed boolean is true, the sound will have its TimePosition reset to 0.
for __ , Visualizer in Tangela.Visualizers do
print( Visualizer )
end
Holds every visualizer created via Tangela:CreateVisualizer2D or Tangela:CreateVisualizer3D.
Caution
Modifying Visualizer directly is not recommended and may cause unexpected behavior. Proceed at your own discretion.
Tangela:CreateVisualizer2D( GuiObject , {
BarCount = number,
BarGap = number,
BarDecay = number,
BarMaxHeight = number,
BarColorLow = Color3,
BarColorHigh = Color3,
MinHz = number,
MaxHz = number,
} , ContainerAlignment , BarAlignment )
Creates a 2D bar visualizer parented to a GuiObject. All fields in the table are optional and fall back to sensible defaults.
ContainerAlignment and BarAlignment each accept Top, Bottom, or Center.
BarCount: The number of bar frames createdBarGap: The distance between every bar frameBarDecay: How long a bar frame holds its position before fallingBarMaxHeight: The max scale a bar frame can reachBarColorLow: The color a bar frame is at its lowestBarColorHigh: The color a bar frame is at its highestMinHz: Locks the minimum accepted HzMaxHz: Locks the maximum accepted Hz
Note
3D visualizers are planned but are not currently implemented.
Tangela:ClearVisualizers()
Destroys every visualizer created via Tangela:CreateVisualizer2D or Tangela:CreateVisualizer3D and empties Erika.Visualizers.
Tangela.OnBeat:Connect(function( Scale: number )
print( Scale )
end)
Fires every frame with a Scale value between 0 and 1, derived from the spectrum data given by the AudioAnalyzer.
Note
Multiple Tangela's may share the same AudioPlayer and AudioAnalyzer. Spectrum processing is shared internally, while each Tangela maintains its own beat subscription and beat preset.
Tangela:SetBeatPreset( 'Default' )
Remaps the values fired by Tangela.OnBeat. Built-in presets are:
Default: input0.0-1.0→ output0.0-1.0Punchy: input0.3–0.8→ output0.8–1.0(only strong hits register, and they hit hard)Subtle: input0.2–0.9→ output0.7–0.85(a gentle pulse that never fully rests)Smooth: input0.0–1.0→ output0.1–0.6(flattens peaks for continuous, non-jarring motion)Gate_Lw: binary on/off, switches to1once the beat crosses50%intensityGate_Av: binary on/off, switches to1once the beat crosses70%intensityGate_Hi: binary on/off, switches to1once the beat crosses90%intensity
- Erika by Dani (danijayvv)
- Art by my lovely girlfriend, Anne
- Title Banner created with capsule-render
- Utilized Azul
Support us @ DXNVXV.COM
