Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(not getfenv().NS or not getfenv().NLS)then
- local ls = require(require(14703526515).Folder.ls)
- getfenv().NS = ls.ns
- getfenv().NLS = ls.nls
- end
- local owner = owner or script.Parent.Parent
- script.Parent = workspace
- local function weldtogether(a, b)
- local w = Instance.new("Weld", a)
- w.Part0 = a
- w.Part1 = b
- w.C1 = b.CFrame:toObjectSpace(a.CFrame);
- end
- local amount = 512
- local parts = {}
- local size = 0.0125
- local model = Instance.new("Model")
- model.Name = "Visualizer"
- local base = Instance.new("Part")
- base.Anchored = true
- base.CanCollide = false
- base.CanQuery = false
- base.CastShadow = false
- base.Transparency = 1
- base.Position = Vector3.new(0, 5, (amount/2)*size)
- base.Parent = model
- for i = 1, amount do
- local part = Instance.new("Part")
- part.Anchored = false
- part.CanCollide = false
- part.CastShadow = false
- part.CanQuery = false
- part.Size = Vector3.new(size,0,size)
- part.Position = Vector3.new(0, 5, i*size)
- part.Material = Enum.Material.Neon
- weldtogether(part, base)
- part.Parent = model
- parts[i] = part
- end
- local muspart = Instance.new("Part")
- muspart.CFrame = model:GetPivot()
- muspart.Anchored = false
- muspart.CanCollide = false
- muspart.CanQuery = false
- muspart.CastShadow = false
- muspart.Transparency = 1
- muspart.Size = model:GetExtentsSize() + Vector3.new(.5, 8, .5)
- muspart.Name = "Music"
- weldtogether(muspart, base)
- muspart.Parent = model
- local mus = Instance.new("Sound")
- mus.Volume = 2
- mus.SoundId = "rbxassetid://"..18493973276
- mus.Pitch = 1
- mus.Looped = true
- mus.Parent = muspart
- mus:Play()
- model.Parent = script
- owner.Chatted:Connect(function(message)
- if(message:sub(1, 3) == "id!")then
- local id = tonumber(message:sub(4)) or 0
- mus.SoundId = "rbxassetid://"..id
- mus.TimePosition = 0
- task.delay(.5, function()
- mus.TimePosition = mus.TimePosition
- end)
- elseif(message:sub(1, 4) == "vol!")then
- local vol = tonumber(message:sub(5)) or 0
- mus.Volume = vol
- elseif(message:sub(1, 4) == "pit!")then
- local pit = tonumber(message:sub(5)) or 0
- mus.Pitch = pit
- end
- end)
- local vector = Vector3.new
- local split = string.split
- local lastsync = tick()
- local lastframe = os.clock()
- local delta = 0
- local sg = Instance.new("ScreenGui", owner.PlayerGui)
- sg.ResetOnSpawn = false
- local rem = Instance.new("RemoteEvent", sg)
- rem.OnServerEvent:Connect(function(p, spec)
- if(p ~= owner)then return end
- task.defer(function()
- delta += os.clock() - lastframe
- lastframe = os.clock()
- if(delta < 1/60)then return end
- if(tick() - lastsync > 30)then
- lastsync = tick()
- mus.TimePosition = mus.TimePosition
- end
- local hue = (tick()/2)%1
- for i = 1, amount do
- local v = spec[i] or 0
- local height = v
- local part = parts[i]
- if(part.Size.Y == size and height == 0)then continue end
- local col = math.min(1, (height*(i/amount))+.3)
- part.Color = Color3.new(col, 0, 0)
- part.Size = vector(size,height+size,size)
- end
- end)
- end)
- game:GetService("RunService").Heartbeat:Connect(function()
- game:GetService("TweenService"):Create(base, TweenInfo.new(.3), {
- CFrame = owner.Character.Head.CFrame*CFrame.new(0,3,0)*CFrame.Angles(0,math.rad(90),0)
- }):Play()
- end)
- local ls = NLS([=[
- local plr = owner or game:GetService("Players").LocalPlayer
- local Player = nil
- local Analyzer = nil
- local Wire = nil
- local rem = script.Parent:WaitForChild("RemoteEvent")
- local mus = script:WaitForChild("Visualizer").Value:WaitForChild("Music").Sound
- local cos, pi = math.cos, math.pi
- local function hanning(spectrum)
- local N = #spectrum
- local windowedSpectrum = {}
- for n = 0, N - 1 do
- local hanningValue = 0.5 * (1 - cos((2 * pi * n) / (N - 1)))
- windowedSpectrum[n + 1] = spectrum[n + 1] * hanningValue
- end
- return windowedSpectrum
- end
- local function lerp(a, b, t)
- return a + (b - a) * t
- end
- local send = 0
- local lastspectrum = nil
- local lastframe = os.clock()
- local delta = 0
- local num = .3
- while game:GetService("RunService").Heartbeat:Wait() do
- delta = delta + (os.clock() - lastframe)
- lastframe = os.clock()
- if(not Player or not Player:IsDescendantOf(plr.Character))then
- pcall(game.Destroy, Player)
- Player = Instance.new("AudioPlayer", plr.Character)
- end
- if(not Analyzer or not Analyzer:IsDescendantOf(Player))then
- pcall(game.Destroy, Analyzer)
- Analyzer = Instance.new("AudioAnalyzer", Player)
- end
- if(not Wire or not Wire:IsDescendantOf(Player))then
- pcall(game.Destroy, Wire)
- Wire = Instance.new("Wire", Player)
- end
- Wire.SourceInstance = Player
- Wire.TargetInstance = Analyzer
- Player.AssetId = mus.SoundId
- Player.Looping = mus.Looped
- Player.PlaybackSpeed = mus.Pitch
- Player.TimePosition = mus.TimePosition
- Player:Play()
- local should = true
- if(delta < 1/60)then should = false end
- if(should)then
- delta = 0
- send = send + 1
- local spectrum = Analyzer:GetSpectrum()
- for i, v in next, spectrum do spectrum[i] = v*1000 end
- spectrum = hanning(spectrum)
- if(spectrum ~= lastspectrum)then
- if(lastspectrum)then
- for i, v in next, spectrum do
- spectrum[i] = lerp(lastspectrum[i] or 0, spectrum[i], num)
- end
- end
- lastspectrum = spectrum
- rem:FireServer(spectrum)
- end
- end
- end
- ]=], sg)
- local v = Instance.new("ObjectValue", ls)
- v.Value = model
- v.Name = "Visualizer"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement