local chr = owner.Character
local root = chr.HumanoidRootPart
script.Parent = chr
local sen = 40
local bars = {}
for i = 1, 22 do
local bar = Instance.new("Part")
bar.Size = Vector3.zero
bar.Anchored = true
bar.CanCollide = false
bar.CanQuery = false
bar.Parent = script
table.insert(bars, bar)
end
local remote = Instance.new("RemoteEvent")
remote.Name = "soundRemote"
remote.Parent = root
NLS([[local chr = owner.Character
local root = chr.HumanoidRootPart
local serverSound = root:FindFirstChild("visSound")
local visGui = root:FindFirstChild("visGui")
local remote = root:FindFirstChild("soundRemote")
local sound = Instance.new("AudioPlayer")
sound.Name = "vissong"
sound.AssetId = "rbxassetid://9043887091"
sound.Looping = true
sound.Parent = root
local soundAnalyze = Instance.new("AudioAnalyzer")
soundAnalyze.Parent = sound
local soundAnalyzeWire = Instance.new("Wire")
soundAnalyzeWire.SourceInstance = sound
soundAnalyzeWire.TargetInstance = soundAnalyze
soundAnalyzeWire.Parent = root
function blackman(fftTable)
local windowSize = #fftTable
local windowedData = {}
for i = 1, windowSize do
local a0 = 0.42659
local a1 = 0.49656
local a2 = 0.076849
local windowValue = a0 - a1 * math.cos((2 * math.pi * (i - 1)) / (windowSize - 1)) + a2 * math.cos((4 * math.pi * (i - 1)) / (windowSize - 1))
windowedData[i] = (fftTable[i] * windowValue) * 100
end
return windowedData
end
sound:Play()
serverSound.Changed:Connect(function(p)
if p == "SoundId" then
sound.AssetId = serverSound.SoundId
sound:Play()
elseif p == "PlaybackSpeed" then
sound.PlaybackSpeed = serverSound.PlaybackSpeed
end
end)
local freq = {}
local prevFreq = {}
game:GetService("RunService").PreRender:Connect(function(dt)
local fft = blackman(soundAnalyze:GetSpectrum())
for i, v in pairs(fft) do
if i > 44 then
table.remove(fft, i)
end
end
local prevSum = 0
local sum = 0
for i, v in pairs(prevFreq) do
prevSum = prevSum + v
sum = sum + fft[i]
end
if prevSum - sum < 0 then
freq = fft
end
prevFreq = fft
sound.TimePosition = serverSound.TimePosition
remote:FireServer(freq)
end)]], script)
local freq = {}
remote.OnServerEvent:Connect(function(plr, fft)
freq = fft
end)
local sound = Instance.new("Sound")
sound.Name = "visSound"
sound.SoundId = "rbxassetid://9043887091"
sound.Volume = 2
sound.Looped = true
sound.Parent = root
sound:Play()
owner.Chatted:Connect(function(msg)
if string.sub(msg,1,3) == '/e ' then
msg = msg:sub(4)
end
if msg:sub(1, 5) == "play " then
lastTime = os.clock()
remote:FireClient(owner, {AssetId = "rbxassetid://" .. msg:sub(6)})
sound.SoundId = "rbxassetid://" .. msg:sub(6)
sound:Play()
elseif msg:sub(1, 4) == "vol " then
sound.Volume = msg:sub(5)
elseif msg:sub(1, 4) == "pit " then
remote:FireClient(owner, {PlaybackSpeed = msg:sub(5)})
sound.PlaybackSpeed = msg:sub(5)
elseif msg:sub(1, 4) == "sen " then
sen = msg:sub(5)
end
end)
local radius = 5
local rot = 0
game:GetService("RunService").PostSimulation:Connect(function(dt)
rot += 0.001 * dt * 60
for i, v in bars do
if freq[i] ~= nil then
v.Size = v.Size:Lerp(Vector3.new(1, freq[i * 2] * sen, 1), 0.3 * dt * 60)
end
v.CFrame = root.CFrame * CFrame.new(math.sin((i * 2 * math.pi / #bars) + (rot * 2 * math.pi)) * radius, v.Size.Y / 2, math.cos(i * 2 * math.pi / #bars + (rot * 2 * math.pi)) * radius) * CFrame.Angles(0, i * 2 * math.pi / #bars, 0)
end
end)