I decided to make an audio visualizer module again. I just really like audio visualizers. They’re neat.
This time, I made it more user friendly and I’m open sourcing it!
The usage is super easy. The module takes care of basically everything for you. You specify a bar amount, and the module will automatically determine the sampling rate and bar falloff for you.
API:
function VisualizerModule.new(Frame, BarCount)
Creates a new visualizer
Frame: Instance
The GuiObject the bars will be put in
BarCount: number
How many bars the visualizer should use
returns a Visualizer
.
property Visualizer.Color
The color of the visualizer bars
Can be a Color3 for a constant color for all bars, or a ColorSequence where 0 is the silence and 1 is the loudest
.
function Visualizer:LinkToSound(Sound)
Makes the visualizer display the given Sound
SoundObject: Instance
The sound to visualize
returns void
.
function Visualizer:UnlinkFromSound()
Makes the visualizer stop displaying the currently linked sound
returns void
.
function Visualizer:Destroy()
Cleans up the visualizer
returns void
Usage:
APIs are sometimes hard to understand without an example, so here you go. It really is simple.
local VisualizerModule = require(script.Visualizer)
local Visualizer = VisualizerModule.new(GuiFrame, 80)
Visualizer:LinkToSound(script.Music)
script.Music:Play()
Demo:
Here’s a demo of various bar counts: (YouTube cuz file is way too large to embed directly)
It was designed for voicelines, but it can handle any audio.
You can call :LinkToSound()
without even unlinking and just rapidly hotswap between audios with no problem.