Pregenerated table of "PlaybackLoudness" values

I’m creating a script that determines whether a music asset is too loud for playback in-game and how much it has to be silenced to reach comfortable volume levels. To achieve this, I need a table of loudness samples of a music asset - at least 5 per second to get the most accurate results.

The problem is that the only way to get the volume samples is to play the music file and read the “PlaybackLoudness” property every script step which may not be a consistent 60 FPS - it ends up taking quite the time and the only way to speed things up is to create more instances of a sound playing at the same time at different “TimePosition”, but that causes significant lag EVEN on high end PC’s. On mobile it can result in a full second freeze.

I want a method that allows me to get a table of the same “PlaybackLoudness” value through the whole sound without the long wait (from a second to 10 seconds) and without lagging up any machine that runs it.


I agree this is a good use case – I’m not sure the requested feature solves the problem. Someone could upload a sound that is really loud for four seconds and then quiet for the fifth second. This would be especially easy for anyone who understood the API of sounds. Instead, I think it’d be great to have a SoundEfffect which would equalize the volume of a sound to a certain PlaybackLoudness within a certain amount. i.e. Set average PlaybackLoudness to 50 with a margin of an additional 25 so min PlaybackLoudness could be 25 and max PlaybackLoudness could be 75.

Edit: Looks like the CompressorSoundEffect gkku posted does this.


Am I missing something or do you guys not know about CompressorSoundEffect?

(don’t take these settings too seriously, I just messed with it for a few minutes until it killed the loud music without messing up the normal music)