Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do audio visualizers work and how can I make one?

Asked by
danglt 185
5 years ago

I'm not asking for a script what so ever, I'm just trying to learn how they work and how I can make one my self.

I'd like to be able to make one using a SurfaceGui and a Part changing size.

1 answer

Log in to vote
2
Answered by 5 years ago
Edited 5 years ago

Audio visualizers work by using the PlaybackLoudness property of a sound. One way you could make a vizualizer would be to make a ScreenGui + Frame and set the frame's size every RenderStepped to the PlaybackLoudness of the sound. A script would look something like this

local sound = workspace.Part.Sound
local frame = script.Parent

game:GetService("RunService").RenderStepped:Connect(function()
    frame.Size = UDim2.new(1,0,0,sound.PlaybackLoudness/2)
end)
-- you can change the "PlaybackLoudness/2" to anything different (even *2!)

If you wanted it to be a part, then it would get a little complicated because you would have to change the Sizeand CFrameproperties

local part = workspace.Part
local sound = part.Sound
local normCF = part.CFrame
local offset

game:GetService("RunService").RenderStepped:Connect(function()
    workspace.Part.CFrame = normCF

    offset = sound.PlaybackLoudness/40

    workspace.Part.Size = Vector3.new(1,offset,1)
    workspace.Part.CFrame = CFrame.new(0,offset/2,0)
end)
0
Thank you, Would it be the same for a Part using Part.Size? danglt 185 — 5y
0
well in that case, you will change the part's size but also need to change the position at the same time the8bitdude11 358 — 5y
0
ALSO, change the UDim2.new to Vector3.new (and use 0, sound.PlaybackLoudness/2, 0) the8bitdude11 358 — 5y
0
ok, also as its a function its self does it start doing this on join or can i make run server a variable and do it on something like mouse click or on touch danglt 185 — 5y
View all comments (9 more)
0
RunService is, well, a service. If you want it to start on a function then you could put it in a function (make sure there's a debounce so the player doesn't start the function a million times!) the8bitdude11 358 — 5y
0
basically script.Parent.MouseButton1Click:Connect(function() **The script you provided** end) I should be able to do that correct? danglt 185 — 5y
0
Ok sent that before i read that message, Thank you! danglt 185 — 5y
0
I also added the script for if it was a part the8bitdude11 358 — 5y
0
I see it can only be ran from a localscript. Where should the localscript go? And will it be the same for all players? danglt 185 — 5y
0
Nvm StarterPlayerScripts danglt 185 — 5y
0
you can also put it in Backpack, StarterGui, StarterPlayerScripts, and StarterCharacterScripts (I think) the8bitdude11 358 — 5y
0
Thank you, Also I know i've been asking alot, LIKE ALOT, but is there way I can move the current camera to the audio as well? Sorta like shaking it danglt 185 — 5y
0
I should be good using the audio to move the screen, but I don't know how the move the screen camera in the first place danglt 185 — 5y
Ad

Answer this question