Is there a way to find the maximum loudness number of a music?

Recently, I was trying to make a radio with some advanced stuff.
I am stuck because I can’t calculate the maximum loudness a song/music will give before it plays.
I was wondering if there is a constant number, do I have to assume it? or is there a tool?

I tried to use CompressorSoundEffect and control the threshold but it didn’t get the max loudness number of a song/music.

has a read aroud theres something called playbackloudness in the sound instance
perhaps this is what u are looking for

local Loudness = SoundInstance.PlaybackLoudness

found it here
https://developer.roblox.com/en-us/api-reference/class/Sound
this is it
https://developer.roblox.com/en-us/api-reference/property/Sound/PlaybackLoudness

strong note
" reflects the amplitude of the Sound ’s playback in the instance of time it is read"

so it will only give you the loudness at the given time loudness is read so if you want to cancel out loud songs u are probably going to use a loop to monitor the loudness and then you can adjust the volume and even better you could cache it into a table along with its loudness so if its played again u can adjust the volume straight away before it gets loud

2 Likes

Sorry, I don’t think you got me well.
I mean, the number I want to get is the highest loudness of music can reach without graphing it to know.

yeah there is no way to just get that value of the bat there is no sound.MaxLoudness

there is just this and its been covered before in a post here

local run = game:GetService("RunService")

local function getHighestPlaybackLoudness(sound)
	local highestPlaybackLoudness = 0
	sound:Play()
	
	local connection do
		connection = run.RenderStepped:Connect(function()
			if not sound.IsPlaying then
				connection:Disconnect()
			end
			
			if sound.PlaybackLoudness > highestPlaybackLoudness then
				highestPlaybackLoudness = sound.PlaybackLoudness
			end
		end)
	end
	
	sound.Ended:Wait()
	return highestPlaybackLoudness
end

local sound = script:WaitForChild("Sound") --Sample sound.
local highestPlaybackLoudness = getHighestPlaybackLoudness(sound)
print(highestPlaybackLoudness) --244, sample result.

As suggested, you’d check the sound’s PlaybackLoudness property every frame (as frequently as possible), if its current value exceeds the highest recorded value then you set the highest recorded value to that value and continue until the sound finishes.