local chr = owner.Character
local root = chr.HumanoidRootPart
local sen = 10
local bars = {}
local visGui = Instance.new("BillboardGui")
visGui.Name = "visGui"
visGui.Adornee = root
visGui.Size = UDim2.new(5, 0, 5, 0)
visGui.StudsOffsetWorldSpace = Vector3.new(0, 5, 0)
visGui.Parent = root
local bg = Instance.new("Frame")
bg.Size = UDim2.new(1, 0, 1, 0)
bg.Position = UDim2.new(0.5, 0, 0, 0)
bg.BorderSizePixel = 0.5
bg.BackgroundColor3 = Color3.fromRGB(47, 47, 47)
bg.AnchorPoint = Vector2.new(0.5, 0)
bg.ZIndex = 0
bg.Parent = visGui
local nameText = Instance.new("TextBox")
nameText.Size = UDim2.new(0.75, 0, 0.125, 0)
nameText.Position = UDim2.new(0.125, 0, 0.85, 0)
nameText.BackgroundTransparency = 1
nameText.TextStrokeTransparency = 0
nameText.TextScaled = true
nameText.TextWrapped = true
nameText.Font = "Gotham"
nameText.TextColor3 = Color3.new(1, 1, 1)
nameText.TextStrokeColor3 = Color3.new()
nameText.ZIndex = 2
nameText.Parent = visGui
for i = 1, 64 do
local bar = Instance.new("Frame")
bar.BorderSizePixel = 0
bar.BackgroundColor3 = Color3.fromRGB(99, 254, 147)
bar.ZIndex = 1
bar.Parent = visGui
table.insert(bars, bar)
end
local soundIds = {
1835520403,
1835520668,
1835644015,
1835520536,
1836602312,
1836602354,
16902661577,
16902726075,
16902692212,
16902698837,
16523894935
}
local song = Instance.new("Sound")
song.Name = "serverSound"
song.SoundId = "rbxassetid://".. soundIds[math.random(1, #soundIds)]
song.Volume = 2
song.Looped = false
song.Parent = root
song:Play()
nameText.Text = game:GetService("MarketplaceService"):GetProductInfo(song.SoundId:sub(14))["Name"]
local remote = Instance.new("RemoteEvent")
remote.Name = "visRemote"
remote.Parent = owner.PlayerGui
NLS([[
local chr = owner.Character
local root = chr.HumanoidRootPart
local serverSound = root:FindFirstChild("serverSound")
local remote = owner.PlayerGui:FindFirstChild("visRemote")
local sound = Instance.new("AudioPlayer")
sound.AssetId = serverSound.SoundId
sound.Parent = root
sound:Play()
local soundAnalyze = Instance.new("AudioAnalyzer")
soundAnalyze.Parent = sound
local soundAnalyzeWire = Instance.new("Wire")
soundAnalyzeWire.SourceInstance = sound
soundAnalyzeWire.TargetInstance = soundAnalyze
soundAnalyzeWire.Parent = sound
local windowFuncs = {
["none"] = function(fftTable)
return fftTable
end,
["triangular"] = function(fftTable)
local windowedData = {}
local windowSize = #fftTable
for i = 1, windowSize do
local windowValue = 1 - math.abs((2 * i) / windowSize - 1)
windowedData[i] = (fftTable[i] * windowValue) * 4
end
return windowedData
end,
["hann"] = function(fftTable)
local windowedData = {}
local windowSize = #fftTable
for i = 1, windowSize do
local windowValue = 0.5 * (1 - math.cos(2 * math.pi * i / windowSize))
windowedData[i] = (fftTable[i] * windowValue) * 4
end
return windowedData
end,
["hamming"] = function(fftTable)
local windowedData = {}
local windowSize = #fftTable
for i = 1, windowSize do
local windowValue = 0.54 - 0.46 * math.cos(2 * math.pi * i / windowSize)
windowedData[i] = (fftTable[i] * windowValue) * 4
end
return windowedData
end,
["nuttall"] = function(fftTable)
local windowedData = {}
local windowSize = #fftTable
local a0 = 0.355768
local a1 = 0.487396
local a2 = 0.144232
local a3 = 0.012604
for i = 1, windowSize do
local windowValue = a0 -
a1 * math.cos(2 * math.pi * i / windowSize) +
a2 * math.cos(4 * math.pi * i / windowSize) -
a3 * math.cos(6 * math.pi * i / windowSize)
windowedData[i] = (fftTable[i] * windowValue) * 4
end
return windowedData
end,
["blackman"] = function(fftTable)
local windowedData = {}
local windowSize = #fftTable
local a0 = 0.42659
local a1 = 0.49656
local a2 = 0.076849
for i = 1, windowSize do
local windowValue = a0 -
a1 * math.cos(2 * math.pi * i / windowSize) +
a2 * math.cos(4 * math.pi * i / windowSize)
windowedData[i] = (fftTable[i] * windowValue) * 4
end
return windowedData
end,
["blackman-nuttall"] = function(fftTable)
local windowedData = {}
local windowSize = #fftTable
local a0 = 0.3635819
local a1 = 0.4891775
local a2 = 0.1365995
local a3 = 0.0106411
for i = 1, windowSize do
local windowValue = a0 -
a1 * math.cos(2 * math.pi * i / windowSize) +
a2 * math.cos(4 * math.pi * i / windowSize) -
a3 * math.cos(6 * math.pi * i / windowSize)
windowedData[i] = (fftTable[i] * windowValue) * 4
end
return windowedData
end,
["blackman-harris"] = function(fftTable)
local windowedData = {}
local windowSize = #fftTable
local a0 = 0.35875
local a1 = 0.48829
local a2 = 0.14128
local a3 = 0.01168
for i = 1, windowSize do
local windowValue = a0 -
a1 * math.cos(2 * math.pi * i / windowSize) +
a2 * math.cos(4 * math.pi * i / windowSize) -
a3 * math.cos(6 * math.pi * i / windowSize)
windowedData[i] = (fftTable[i] * windowValue) * 4
end
return windowedData
end,
["astral"] = function(fftTable)
local windowedData = {}
for i = 1, #fftTable do
if fftTable[i - 1] and fftTable[i + 1] then
windowedData[i] = (fftTable[i] + fftTable[i - 1] + fftTable[i + 1]) / 3
else
windowedData[i] = fftTable[i]
end
end
return windowedData
end
}
local windowType = "none"
local astral = false
remote.OnClientEvent:Connect(function(window)
window = string.lower(window)
if window ~= "astral" then
if windowFuncs[window] then
windowType = window
else
windowType = "none"
end
else
astral = not astral
end
end)
local fft = {}
game:GetService("RunService").PreRender:Connect(function()
sound.TimePosition = serverSound.TimePosition + owner:GetNetworkPing()
if sound.IsPlaying == false then
sound.TimePosition = 0
sound:Play()
end
sound.AssetId = serverSound.SoundId
sound.PlaybackSpeed = serverSound.Pitch
local fftOut = soundAnalyze:GetSpectrum()
table.move(fftOut, 1, 64, 1, fft)
fft = windowFuncs[windowType](fft)
fft = astral and windowFuncs["astral"](fft) or fft
remote:FireServer(fft)
end)
]])
local fft = {}
remote.OnServerEvent:Connect(function(plr, fftOut)
fft = fftOut
end)
local chatFuncs = {
["play"] = function(param)
song.SoundId = "rbxassetid://".. param
song.TimePosition = 0
song:Play()
if pcall(game:GetService("MarketplaceService").GetProductInfo, game:GetService("MarketplaceService"), song.SoundId:sub(14)) then
nameText.Text = game:GetService("MarketplaceService"):GetProductInfo(song.SoundId:sub(14))["Name"]
else
nameText.Text = "Not Playing"
end
end,
["vol"] = function(param)
song.Volume = param or 1
end,
["pit"] = function(param)
song.Pitch = param or 1
end,
["seek"] = function(param)
song.TimePosition = param or 1
end,
["sen"] = function(param)
sen = param
end,
["window"] = function(param)
remote:FireClient(owner, param)
end,
}
owner.Chatted:Connect(function(msg)
msg = msg:sub(1, 3) == "/e " and msg:sub(4) or msg
msg = msg:sub(1, 1) == "/" and msg:sub(2) or msg
local cmd, param = table.unpack(msg:split(" "))
if chatFuncs[cmd] then
chatFuncs[cmd](param)
end
end)
game:GetService("RunService").PostSimulation:Connect(function(dt)
if song.Playing == false or song.SoundId == "rbxassetid://0" then
song.SoundId = "rbxassetid://".. soundIds[math.random(1, #soundIds)]
song.TimePosition = 0
song.Playing = true
nameText.Text = game:GetService("MarketplaceService"):GetProductInfo(song.SoundId:sub(14))["Name"]
end
for i, v in next, bars do
if song.Playing and nameText.Text ~= "Not Playing" then
if fft[i] ~= nil then
v.Size = v.Size:Lerp(UDim2.new(0.5 / #bars, 0, 0.5 / #bars + math.clamp(fft[i] * sen, 0, 0.75), 0), 0.3 * dt * 60)
v.BackgroundColor3 = Color3.fromRGB(99 + fft[i] * sen * 100, 254 + fft[i] * sen * 100, 147 + fft[i] * sen * 100)
end
v.Position = UDim2.new(i / (#bars * 1.25) + #bars / (#bars * 10), 0, 0.8375 - v.Size.Height.Scale / 1.000001, 0)
else
v.Size = v.Size:Lerp(UDim2.new(0.5 / #bars, 0, 0.5 / #bars, 0), 0.3 * dt * 60)
v.BackgroundColor3 = Color3.fromRGB(99, 254, 147)
v.Position = UDim2.new(i / (#bars * 1.25) + #bars / (#bars * 10), 0, 0.8375 - v.Size.Height.Scale / 1.000001, 0)
end
end
end)