Hello, I wanted to know if any of you knew a good MaxPlaybackLoudness integer for detecting loud/bypassed audios. Ask questions if you need me to elaborate on anything, please.
math.huge()
Jokes aside, I believe this is the property you’re referring to:
https://developer.roblox.com/en-us/api-reference/property/Sound/PlaybackLoudness
The property accepts any double precision floating point number between 0 and 1,000 inclusively, I believe if an attempt is made to set a value higher than 1,000 then 1,000 is used instead, as such 1,000 is likely a good place to start.
So you want to have sounds that are really loud to be played quieter?
No, I want to know a good MaxPlaybackLoudness integer. I’m making a script that detects loud audios, and I would like to know a good MaxPlaybackLoudness integer value to compare each audio to.
for example:
- create new song via script
- get maxplaybackloudness of song created
- if the song’s maxplaybackloudness > (integer im asking for) then delete the audio
this integer im looking for is going to be used for a boundary between loud and tolerable. I’m looking to see if you or anyone would know a good integer for that.
I made a script a while ago that clamped sounds to a specific playback loudness by lowering the volume when it exceeds a loudness threshold, I can probably pull it if I find it.
It means the sound isn’t deleted but is lowered if it’s excessively loud
It only works on the client since PlaybackLoudness requires the client
I would just find a sound from the library that fits your case perfectly. Add a setting for the player to adjust it. By default set it to that comfort zone you find.
is there a way to iterate thru the entire sound and find the highest point of loudness instantly?
Unfortunately, no, its not possible to get raw loudness data from an audio file.
You could, however, stream through the audio really quickly using pitch 10 at volume 0 and scan the loudness that way. PlaybackLoudness is how loud the audio is if the volume were 1. It would take up to 70 seconds since thats the maximum length for audio files on Roblox
do you have a short example? I’d be inclined to see. I’m a bit new to sound manipulation/properties.
local function ScanSoundForAverageLoudness(sound)
local MockSound = sound:Clone()
MockSound.Looped = false
MockSound.PlaybackSpeed = 10
MockSound.Volume = 0
local score = 0
local timesChecked = 0
local isScanning = true
MockSound.Ended:Connect(function()
isScanning = false
MockSound:Destroy()
end)
MockSound.Parent = workspace
MockSound:Play()
repeat
score += MockSound.PlaybackLoudness
timesChecked += 1
task.wait()
until not isScanning
MockSound:Destroy()
return score / timesChecked
end
returns the average audio loudness over the entire clip
There’s no way to make it quicker?
PlaybackSpeed 10 is the fastest you can make it.
Yikes, thanks. It did solve my issue, but i just wish there was a faster way haha
You can maybe use renderStepped to automaticlly change the volume so it’s changed before it’s noticable/rendered.