How to make GUI audio visualizer

I want to visualize the audio but all the things I find are for the live audio I want something like in the roblox moments game:

basically get the level of audio at certain time periods (NOT the live audio)

2 Likes

sound.PlaybackLoudness should help you, however i’m not into acoustic coding so someone who’s more experienced in it can probably help you in a more in-depth explanation.

Yeah I saw that but am not sure how to integrate it 100%

roblox themselves provided a solid example, not sure if it’s what you’re going for but should put you in the right direction

-- to be placed in StarterPlayer > StarterPlayerScripts

local Players = game:GetService("Players")

-- wait for local player PlayerGui
local LocalPlayer = Players.LocalPlayer
local playerGui = LocalPlayer:WaitForChild("PlayerGui")

-- create a ScreenGui
local screenGui = Instance.new("ScreenGui")
screenGui.Parent = playerGui

-- create a holder for our bar
local frame = Instance.new("Frame")
frame.AnchorPoint = Vector2.new(0.5, 0.5)
frame.Position = UDim2.new(0.5, 0, 0.5, 0)
frame.Size = UDim2.new(0.3, 0, 0.05, 0)
frame.Parent = screenGui

-- create a bar
local bar = Instance.new("Frame")
bar.Position = UDim2.new(0, 0, 0, 0)
bar.Size = UDim2.new(1, 0, 1, 0)
bar.BackgroundColor3 = Color3.new(0, 1, 0)
bar.Parent = frame

-- create a sound
local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://9120386436"
sound.Looped = true
sound.Parent = screenGui
sound:Play()

-- define a max loudness
local maxLoudness = 30

-- animate the amplitude bar
while true do
	local amplitude = math.clamp(sound.PlaybackLoudness / maxLoudness, 0, 1)
	bar.Size = UDim2.new(amplitude, 0, 1, 0)
	wait(0.05)
end

basically it gives you a value from 0-1000 on how loud the current sound is based on what time position you called it from.

3 Likes

okay i did some stuff but it still takes a while to show as it has to get the volume of the sound at each point… takes like 10 seconds at 20x playback speed

2 Likes

reason is that roblox doesn’t load the sounds as soon as the game starts, so it might take some time as soon as you start playing it. this won’t be a problem since you aren’t going to be using this a lot buut just so you know, you may want to consider preloading if you want to actually use this, just to make it seamless.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.