Things to do: Music time stamp controller - the long line
How can I control the speedrate of the progress bar based from the maxTime of the music.
They can click the gray lines to a specific timestamp
maxTime
– I think i know this one… which is the Sound.TimeLength
Music Name
– i’ll just send the sound.Name and change text to it
My plan in doing this
I will use :FireServer(soundName,timeLength) to send information
and send it back to the local script where as it updates the texts. something like this
I have an advanced sound script so Ive done a lot of this before.
For the progress bar you just need to have the current song time / song length and put that onto a bar, then from the gui if you wanted to skip through using the bar you would want to get the point where the mouse is clicked and calculate the distance from the start of the bar to the point where you clicked. As a full bar would be the full length of the song you would just do Distance/MaxBarLength * SongLength to get the point you would be skipping to.
To get the name you just need to use the marketplace service.
-- GetSoundName
function SoundMod.GetSoundName(SoundId)
local MS = game:GetService("MarketplaceService")
local NumbId = SoundMod.GetNumbSoundId(SoundId)
local Asset = MS:GetProductInfo(NumbId)
return Asset.Name
end
1st:I would like to do this but some music has weird names but bop musics.
But the script you provided. I will use that in the future
2nd: This is my first time doing this kind of things so i do not have much knowledge on how I can calculate the distance from the start of the bar to the point the player clicks on…
can you give an example whereas the concept you gave is used? and if possible include the script…
So if the start of the bar is at say {0,0} and it goes to {0,10} meaning it is 10 long. if you click at {0,5} that means you would be clicking the middle of the bar
I was working on getting sound stats and recording them into a datastore to make epic looking disco lights that sync up perfectly.
My Script
local SoundMod = {}
-- AddSound
function SoundMod.AddSound(ID,Name,WhereToAdd)
local NewSound = Instance.new("Sound",WhereToAdd)
NewSound.SoundId = ID
NewSound.Name = Name
end
-- Play
function SoundMod.Play(Sound)
Sound:Play()
end
-- Stop
function SoundMod.Stop(Sound)
Sound:Stop()
end
-- Resume
function SoundMod.Resume(Sound)
Sound:Resume()
end
-- Pause
function SoundMod.Pause(Sound)
Sound:Pause()
end
-- GetNumbSoundId
function SoundMod.GetNumbSoundId(SoundId)
local Split = string.split(SoundId,"/")
local NumbId = tonumber(Split[3])
return NumbId
end
-- GetSoundName
function SoundMod.GetSoundName(SoundId)
local MS = game:GetService("MarketplaceService")
local NumbId = SoundMod.GetNumbSoundId(SoundId)
local Asset = MS:GetProductInfo(NumbId)
return Asset.Name
end
-- GetSoundStats (Loudness Is Based Off Scripts Position)
function SoundMod.GetSoundStats(Sound)
-- Log Properties That Will Be Changed
local BPlaying = Sound.Playing
local BTimePos = Sound.TimePosition
local BMaxD = Sound.MaxDistance
local BLooped = Sound.Looped
local BEmitterSize = Sound.EmitterSize
-- PrepForQuickPlay
Sound.Playing = false
Sound.TimePosition = 0
Sound.Volume = 0
Sound.PlaybackSpeed = 1
Sound.EmitterSize = 99999
Sound.Looped = false
-- Running Test
Sound.Playing = true
local LoundessLog = {}
local SampleCount = 0
while Sound.Playing == true do
SampleCount = SampleCount + 1
table.insert(LoundessLog,1,Sound.PlaybackLoudness)
wait(1/200)
end
-- GetAverageLoudness and HighestLoudness
local AcumulatedLoudness = 0
local HighestLoudness = 0
for i = 1,#LoundessLog do
AcumulatedLoudness = AcumulatedLoudness + LoundessLog[i]
if LoundessLog[i] > HighestLoudness then
HighestLoudness = LoundessLog[i]
end
end
-- Data
local SoundId = Sound.SoundId
local Name = SoundMod.GetSoundName(Sound.SoundId) --
local HighestLoudness = HighestLoudness --
local AverageLoudness = AcumulatedLoudness / SampleCount --
local Duration = Sound.TimeLength --
local Data = {SoundId,Name,Duration,AverageLoudness,HighestLoudness}
return Data
end
-- SaveSoundData
function SoundMod.SaveSoundData(Data)
local DataStoreService = game:GetService("DataStoreService")
local NewStore = DataStoreService:GetDataStore("Minimic2002SoundData")
-- Makes It Into 1 String As You Cant Save Arrays
local NewData = ""
for i = 1,#Data do
NewData = NewData .. ";" .. tostring(Data[i])
end
NewStore:SetAsync("Sound " ..Data[1],NewData) -- Sets All the Data To SoundId
end
-- GetSoundData
function SoundMod.GetSoundData(SoundId)
local DataStoreService = game:GetService("DataStoreService")
local NewStore = DataStoreService:GetDataStore("Minimic2002SoundData")
local Result = NewStore:GetAsync("Sound " ..SoundId)
-- Turn Data Back Into An Array
local Split = string.split(Result,";")
local Data = {}
for i = 1,#Split do
local ToN = tonumber(Split[i])
if ToN == nil then
table.insert(Data,Split[i])
else
table.insert(Data,ToN)
end
end
return Data
end
-- SoundData
function SoundMod.SoundData(Sound)
local SoundId = Sound.SoundId
-- AttemptToGetData
local SoundData = GetSoundData(SoundId)
if SoundData == nil then
-- Log Sound As There Is No Data On It
local Clone = Sound:Clone() -- Clone It So Original Uneffected
Clone.Parent = Sound.Parent -- Play From Same Location
local SoundStats = GetSoundStats(Sound)
SaveSoundData(SoundStats) -- Saves Data From Stats
Clone:Destroy()
else
return SoundData -- Found Data And Is Returning It
end
end
-- PlaylistFunctions
-- AddToPlaylist()
function SoundMod.AddToPlaylist(Playlist,SoundId)
local DataStoreService = game:GetService("DataStoreService")
local NewStore = DataStoreService:GetDataStore("Minimic2002PlaylistData")
local Result = NewStore:GetAsync("Playlist " ..Playlist)
if Result == nil then -- Nothing There Yet
-- Starts A New Store For That Playlist
NewStore:SetAsync("Playlist " ..Playlist,SoundId)
else
-- Add Onto String
local PlaylistData = Result .. ";" .. SoundId
NewStore:SetAsync("Playlist " ..Playlist,PlaylistData)
end
end
-- GetPlaylistData
function SoundMod.GetPlaylistData(Playlist)
local DataStoreService = game:GetService("DataStoreService")
local NewStore = DataStoreService:GetDataStore("Minimic2002PlaylistData")
local Result = NewStore:GetAsync("Playlist " ..Playlist)
local Split = string.split(Result,";")
local NewPlaylistData = {}
for i = 1,#Split do
table.insert(NewPlaylistData,Split[i])
end
return NewPlaylistData
end
-- RemoveFromPlaylist
function SoundMod.RemoveFromPlaylist(Playlist,SoundId)
local PlaylistData = SoundMod.GetPlaylistData(Playlist)
for i = 1,PlaylistData do
if PlaylistData[i] == SoundId then
-- Found Song
PlaylistData[i] = nil
end
end
local DataStoreService = game:GetService("DataStoreService")
local NewStore = DataStoreService:GetDataStore("Minimic2002PlaylistData")
NewStore:SetAsync("Playlist " ..Playlist,PlaylistData)
end
function SoundMod.CheckForBan(SoundId)
local DataStoreService = game:GetService("DataStoreService")
local NewStore = DataStoreService:GetDataStore("Minimic2002SoundBanData")
local Bans = NewStore:GetAsync("SoundBans")
local BanList = string.split(Bans,",")
local Banned = false
for i = 1,#BanList do
if tostring(SoundId) == BanList[i] then
local Banned = true
end
end
return Banned
end
function SoundMod.Ban(SoundId)
local DataStoreService = game:GetService("DataStoreService")
local NewStore = DataStoreService:GetDataStore("Minimic2002SoundBanData")
local Bans = NewStore:GetAsync("SoundBans")
local NewBans = Bans .. tostring(SoundId) .. ","
NewStore:SetAsync("SoundBans",NewBans)
end
return SoundMod
so if you know what a full bar is, the bar size wont change regardless of the song length. This means that you can just change the size of the gui frame by whatever fraction of completion the song is at.