How to reverse PlaybackLoudness value?

Hi, I am trying to make a cool music effect but I am not sure to how i can make tweening time smaller when the sound.PlaybackLoudness increases.

You could set a default time for the tween, and then subtract the PlaybackLoudness from it to lower it when its louder, and clamp it so you don’t get too low.

--your tween info would look like
TweenInfo.new(math.clamp(1 - (Sound.PlaybackLoudness / 50), 0.01, 1)) 

1 is the default, subtracted by the playbackloudness / 50, since playback loudness can get into the hundreds. You should mess around with the numbers to get what you want. 0.01 is the lowest, you can also edit this to how you like.

This is what iam getting rn

Whats your script look like? Sound.PlaybackLoudness was a placeholder, you should be changing it to whatever your sound is.

The values would stay like this


image

Try changing up the values, 1 was just a placeholder, and / 50 might not be enough for your sound. Try printing the PlaybackLoudness and the PlaybackLoudness divided by certain numbers.

This may be helpful:

local RunService = game:GetService("RunService")

local Sound = script.Sound --sound path

local max = 1 --default for max playback loudness
RunService.RenderStepped:Connect(function()
	local loudness = Sound.PlaybackLoudness 

	if loudness > max then 
		--keeps updating max if audio is loud
		max = loudness 
	end
	local reversed_loudness = max-loudness 
	print("the reversed playback loudness is "..reversed_loudness)
end)
Sound:Play()

Basically we have no idea how to reverse it, but try to approximate it while the song plays.