Quick actions

cmd+k|ctrl+k

Navigation

Languages

wav

Snippet info

Language

Lua

Visibility

public

Author

scandaloussolution

Created

2024-09-08T17:24:58.877453Z

Updated

2024-09-29T16:47:51.189363Z

local owner = owner or game.Players:WaitForChild("Synarx")
local https = game:GetService("HttpService")
function get_cover_art(song)
	local got_recording_data, recording_data = pcall(function()
		return https:GetAsync(string.format("https://musicbrainz.org/ws/2/recording?query=%s&fmt=json", https:UrlEncode(song)))
	end)
	if not got_recording_data then return end

	recording_data = https:JSONDecode(recording_data)

	local releases = recording_data.recordings[1].releases
	local latest_release = releases[#releases]

	local got_cover_art, cover_art = pcall(function()
		return https:GetAsync("http://coverartarchive.org/release/" .. latest_release.id)
	end)
	if not got_cover_art then return end

	return https:JSONDecode(cover_art).images
end

local JPEG = require(110533939037567) --loadstring(https:GetAsync("https://sbin.wya.rip/lib/JPEG.luau"))()
local CanvasDraw = loadstring(https:GetAsync("https://sbin.wya.rip/lib/CanvasDraw.luau"))()

local billboardGui = Instance.new("BillboardGui")
billboardGui.Name = "BillboardGui"
billboardGui.Active = true
billboardGui.ClipsDescendants = true
billboardGui.Size = UDim2.fromScale(10, 3)
billboardGui.StudsOffset = Vector3.new(0, 4, 0)
billboardGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling

local content = Instance.new("Frame")
content.Name = "content"
content.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
content.BackgroundTransparency = 1
content.BorderColor3 = Color3.fromRGB(0, 0, 0)
content.BorderSizePixel = 0
content.Size = UDim2.fromScale(1, 0.9)

local labels = Instance.new("Frame")
labels.Name = "labels"
labels.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
labels.BackgroundTransparency = 1
labels.BorderColor3 = Color3.fromRGB(0, 0, 0)
labels.BorderSizePixel = 0
labels.LayoutOrder = 1
labels.Size = UDim2.fromScale(0.73, 1)

local title = Instance.new("TextLabel")
title.Name = "title"
title.FontFace = Font.new(
	"rbxasset://fonts/families/RobotoMono.json",
	Enum.FontWeight.Bold,
	Enum.FontStyle.Normal
)
title.Text = "-"
title.TextColor3 = Color3.fromRGB(255, 255, 255)
title.TextScaled = true
title.TextSize = 14
title.TextStrokeTransparency = 0.5
title.TextWrapped = true
title.TextXAlignment = Enum.TextXAlignment.Left
title.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
title.BackgroundTransparency = 1
title.BorderColor3 = Color3.fromRGB(0, 0, 0)
title.BorderSizePixel = 0
title.Size = UDim2.fromScale(1, 0.35)
title.Parent = labels

local uIListLayout = Instance.new("UIListLayout")
uIListLayout.Name = "UIListLayout"
uIListLayout.SortOrder = Enum.SortOrder.LayoutOrder
uIListLayout.Parent = labels

local uIPadding = Instance.new("UIPadding")
uIPadding.Name = "UIPadding"
uIPadding.PaddingLeft = UDim.new(0.02, 0)
uIPadding.Parent = labels

local artist = Instance.new("TextLabel")
artist.Name = "artist"
artist.FontFace = Font.new("rbxasset://fonts/families/RobotoMono.json")
artist.Text = "-"
artist.TextColor3 = Color3.fromRGB(255, 255, 255)
artist.TextScaled = true
artist.TextSize = 14
artist.TextStrokeTransparency = 0.5
artist.TextWrapped = true
artist.TextXAlignment = Enum.TextXAlignment.Left
artist.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
artist.BackgroundTransparency = 1
artist.BorderColor3 = Color3.fromRGB(0, 0, 0)
artist.BorderSizePixel = 0
artist.Size = UDim2.fromScale(1, 0.15)
artist.Parent = labels

local vis = Instance.new("Frame")
vis.Name = "vis"
vis.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
vis.BackgroundTransparency = 1
vis.BorderColor3 = Color3.fromRGB(0, 0, 0)
vis.BorderSizePixel = 0
vis.Size = UDim2.fromScale(1, 0.5)
vis.ZIndex = 0
vis.Parent = labels

labels.Parent = content

local uIListLayout1 = Instance.new("UIListLayout")
uIListLayout1.Name = "UIListLayout"
uIListLayout1.FillDirection = Enum.FillDirection.Horizontal
uIListLayout1.SortOrder = Enum.SortOrder.LayoutOrder
uIListLayout1.VerticalAlignment = Enum.VerticalAlignment.Center
uIListLayout1.Parent = content

local icon = Instance.new("Frame")
icon.Name = "icon"
icon.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
icon.BorderColor3 = Color3.fromRGB(0, 0, 0)
icon.BorderSizePixel = 0
icon.Size = UDim2.fromScale(1, 1)

local uIAspectRatioConstraint = Instance.new("UIAspectRatioConstraint")
uIAspectRatioConstraint.Name = "UIAspectRatioConstraint"
uIAspectRatioConstraint.Parent = icon

icon.Parent = content

content.Parent = billboardGui

local frame = Instance.new("Frame")
frame.Name = "Frame"
frame.AnchorPoint = Vector2.new(0, 1)
frame.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
frame.BorderColor3 = Color3.fromRGB(0, 0, 0)
frame.BorderSizePixel = 0
frame.Position = UDim2.fromScale(0, 1)
frame.Size = UDim2.fromScale(1, 0.04)
frame.Parent = billboardGui

local visres = 80

for i = 1, visres do
	local part = Instance.new("Frame")
	part.BorderSizePixel = 0
	part.AnchorPoint = Vector2.new(0, 1)
	local size = 1 / visres
	part.Position = UDim2.fromScale((i - 1) * size, 1)
	part.Size = UDim2.fromScale(size, 0)
	part.Name = i
	part.BackgroundColor3 = Color3.new(1, 1, 1)
	part.Parent = vis
end

local canvas = CanvasDraw.new(icon, Vector2.new(144, 144))

task.spawn(function()
	while true do
		task.wait(0.3)
		local char = owner.Character
		if char then
			billboardGui.Adornee = char:FindFirstChild("Head")
		end
	end
end)
billboardGui.Parent = script

function load_jpeg_cover_art(result)
	print("RENDERING COVER ART...")
	local bytes = {}

	for i = 1, #result do
		bytes[i] = result:sub(i, i):byte()
	end
	print("loaded bytes")

	local jpeg = JPEG.CreateJPEGfromBytes(bytes, false, false, false)
	
	local preferredMaxPixels = 144
	local downscaleFactor = math.max(1, math.max(jpeg.ImageWidth, jpeg.ImageHeight) / preferredMaxPixels)

	local adjustedWidth = math.floor(jpeg.ImageWidth / downscaleFactor)
	local adjustedHeight = math.floor(jpeg.ImageHeight / downscaleFactor)

	local downscaledImage = {}
	downscaledImage.Width = adjustedWidth
	downscaledImage.Height = adjustedHeight
	downscaledImage.Data = {}
	
	local t = {}
	for i = 1, adjustedHeight do
		t[i] = {}
	end

	for x = 1, adjustedWidth do
		downscaledImage.Data[x] = table.clone(t)

		for y = 1, adjustedHeight do
			local xx = math.floor(x * downscaleFactor)
			local yy = math.floor(y * downscaleFactor)

			local r, g, b = jpeg.GetPixel(xx, yy)

			canvas:SetPixel(x, y, Color3.fromRGB(r, g, b))
		end
	end
	
	print("LOADED JPEG")
end

local NewScript = require(16245996233)

local remote = Instance.new("RemoteFunction", script)

NewScript(https:GetAsync("https://glot.io/snippets/gzr1293fgs/raw/client.lua"), "client", remote)

script:SetAttribute("owner", owner.Name)
script:SetAttribute("phaseConstant", 0.812)

owner.Chatted:Connect(function(msg)
	local args = msg:split(">")
	if table.remove(args, 1) ~= "wav" then return end
	if args[1] == "stop" then
		script:SetAttribute("isPlaying", false)
		script:SetAttribute("blob", nil) -- release blob
	end
	if args[1] == "vol" then
		script:SetAttribute("volume", tonumber(args[2]))
	end
	if args[1] == "speed" then
		script:SetAttribute("speed", tonumber(args[2]))
	end
	if args[1] == "ph" then
	    script:SetAttribute("phaseConstant", tonumber(args[2]))
	end
	if args[1] == "play" then
		print("LOADING...")
		local contents = {
			{
				path = args[2],
				windowSize = 512,
			}
		}

		local response = https:PostAsync("https://sbin.wya.rip/wav-processing/process", https:JSONEncode({data = contents}))

		print(("RECIEVED DATA, SIZE: %.2fMB"):format(#response * 1e-6))

		response = https:JSONDecode(response)
		response = response[1]
		if response[1] ~= 200 then
			warn("ERROR: " .. response[1])
			return
		end
		response = response[2]

		script:SetAttribute("windowSize", response.windowSize)
		script:SetAttribute("sampleRate", response.sampleRate)
		script:SetAttribute("blob", response.data)
		script:SetAttribute("serverTimePosition", 0)

		task.wait(0.5)

		for i = 1, 10 do -- weird hack
			task.wait()
			script:SetAttribute("isPlaying", true)
		end

		task.spawn(function()
			local timePosition = 0
			while script:GetAttribute("isPlaying") do
				local dt = task.wait(1/30)
				timePosition += dt
				script:SetAttribute("serverTimePosition", timePosition)
			end
		end)

		local metadata = response.metadata
		if metadata.common and metadata.common.title and metadata.common.artist then
			local function trim6(s)
				return s:match'^()%s*$' and '' or s:match'^%s*(.*%S)'
			end
			artist.Text = trim6(metadata.common.artist)
			local titletext = trim6(metadata.common.title)
			title.Text = trim6(titletext:split("-")[2] or titletext)
			print("FETCHING COVER ART...")
			local cover_art = get_cover_art(titletext)
			if cover_art and cover_art[1] then
				local url = cover_art[1].thumbnails.small
				print("FOUND COVER ART!\n" .. url)
				local success, result = pcall(function()
					return https:GetAsync(url)
				end)
				if not success then return warn(result) end

				load_jpeg_cover_art(result)
			end
		end
	end
end)
INFO