freq vis test

Run Settings
LanguageLua
Language Version
Run Command
local chr = owner.Character local root = chr.HumanoidRootPart script.Parent = chr local visGui = Instance.new("BillboardGui") visGui.Name = "visGui" visGui.Adornee = root visGui.Size = UDim2.new(8, 0, 4, 0) visGui.StudsOffsetWorldSpace = Vector3.new(0, 1.5, 0) visGui.Parent = root local bg = Instance.new("Frame") bg.Size = UDim2.new(0.8, 0, 1.4, 0) bg.Position = UDim2.new(0.5, 0, -1.2, 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 barTemplate = Instance.new("Frame") barTemplate.Size = UDim2.new(0.25, 1) barTemplate.BorderSizePixel = 0 barTemplate.BackgroundColor3 = Color3.fromRGB(99, 254, 147) barTemplate.ZIndex = 1 local sen = 20 local bars = {} for i = 1, 44 do local bar = barTemplate:Clone() bar.Size = UDim2.new(0.0125, 0, 0, 0) bar.Position = UDim2.new(0.1875 + i / 70, 0, 0, 0) bar.ZIndex = 1 bar.Parent = visGui 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 hamming(fftTable) local windowSize = #fftTable local windowedData = {} for i = 1, windowSize do local windowValue = 0.54 - 0.46 * math.cos(2 * math.pi * i / windowSize + 1) windowedData[i] = (fftTable[i] * windowValue) end return windowedData end function hanning(fftTable) local windowSize = #fftTable local windowedData = {} for i = 1, windowSize do local windowValue = 0.5 * (1 - math.cos(2 * math.pi * i / windowSize + 1)) windowedData[i] = (fftTable[i] * windowValue) end return windowedData end function triangle(fftTable) local windowSize = #fftTable local windowedData = {} for i = 1, windowSize do local windowValue = 1 - math.abs((2 * i) / windowSize - 1) windowedData[i] = (fftTable[i] * windowValue) * 2 end return windowedData end function nuttall(fftTable) local windowSize = #fftTable local windowedData = {} 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) * 3 end return windowedData end 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) end return windowedData end function blackmanNuttall(fftTable) local windowSize = #fftTable local windowedData = {} local a0 = 0.3635819 local a1 = 0.4891775 local a2 = 0.1365995 local a3 = 0.0106411 local pi = math.pi for i = 1, windowSize do local windowValue = a0 - a1 * math.cos(2 * pi * i / windowSize) + a2 * math.cos(4 * pi * i / windowSize) - a3 * math.cos(6 * pi * i / windowSize) windowedData[i] = (fftTable[i] * windowValue) * 3 end return windowedData end function blackmanHarris(fftTable) local windowSize = #fftTable local windowedData = {} for i = 1, windowSize do local a0 = 0.35875 local a1 = 0.48829 local a2 = 0.14128 local a3 = 0.01168 local pi = math.pi local windowValue = a0 - a1 * math.cos(2 * pi * i / windowSize) + a2 * math.cos(4 * pi * i / windowSize) - a3 * math.cos(6 * pi * i / windowSize) windowedData[i] = (fftTable[i] * windowValue) end return windowedData end function flattop(fftTable) local windowSize = #fftTable local windowedData = {} for i = 1, windowSize do local a0 = 0.21557895 local a1 = 0.41663158 local a2 = 0.277263158 local a3 = 0.083578947 local a4 = 0.006947368 local pi = math.pi local windowValue = a0 - a1 * math.cos(2 * pi * i / windowSize) + a2 * math.cos(4 * pi * i / windowSize) - a3 * math.cos(6 * pi * i / windowSize) + a4 * math.cos(8 * pi * i / windowSize) windowedData[i] = (fftTable[i] * windowValue) 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 windows = { ["none"] = function(fft) return fft end, ["hamming"] = hamming, ["hanning"] = hanning, ["triangle"] = triangle, ["nuttail"] = nuttall, ["blackman"] = blackman, ["blackmannuttall"] = blackmanNuttall, ["blackmanharris"] = blackmanHarris, ["flattop"] = flattop } local currentWindow = "none" remote.OnClientEvent:Connect(function(windowType) if windows[windowType] ~= nil then currentWindow = string.lower(windowType) end end) game:GetService("RunService").PreRender:Connect(function() local fftOut = soundAnalyze:GetSpectrum() local fft = {} table.move(fftOut, 1, 44, 1, fft) fft = windows[currentWindow](fft) sound.TimePosition = serverSound.TimePosition remote:FireServer(fft) end)]], owner.Character) 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 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 sound.PlaybackSpeed = msg:sub(5) elseif msg:sub(1, 4) == "sen " then sen = msg:sub(5) elseif msg:sub(1, 7) == "window " then remote:FireClient(owner, msg:sub(8)) end end) game:GetService("RunService").PostSimulation:Connect(function(dt) for i, v in ipairs(bars) do if freq[i] ~= nil then v.Size = v.Size:Lerp(UDim2.new(0.0125, 0, math.clamp(freq[i] * sen, 0, 1), 0), 0.3 * dt * 60) end v.Position = UDim2.new(0.175 + i / 70, 0, -v.Size.Height.Scale / 1.000001, 0) end end)
Editor Settings
Theme
Key bindings
Full width
Lines