Hello I am Asking If There’s Anyway To Detect Boombox Loud Music’s If So What’s The Required Function’s I Tried To Blacklist The Music’s Id’s But Everyday New One’s Appear
Sound.PlaybackLoudness returns a value from 0 - 1000 determining how loud the song currently is.
Maybe if it is consistently above like 500 or something it can be classified as loud, and you can stop the music, or lower the volume.
There is a property in sound called Volume
, you can use it to get the volume of boom boxes. I’d rather have a table of all the sound id’s that I don’t want to be used in radios for my game.
To put this into perspective, the average song never goes above 230-270 PlaybackLoudness. Based on this, you may want to exponentially decrease the volume of a sound the closer it gets to 1000. A simple formula that would achieve this would be
local dropoffStrength = 4 -- how strongly you want the sound to fall off.
boomboxSound.Volume = (-(boomboxSound.PlaybackLoudness/1000)^dropoffStrength)+1
This is a simple exponential equation. To explain the math:
- A negative base value causes the curve to trend downwards on the Y-axis.
- We’re dividing
PlaybackLoudness
by 1000 to turn it into a value ranging between 0 and 1, i.e. a percentage of the maximum. - The
dropoffStrength
variable is the exponent. A higher value causes the volume to drop off later, but more sharply.
I plotted a few examples in Desmos. The Y axis will be the volume, and the X axis will be the percentage of PlaybackLoudness.
thank you so much for the explanation