How could i set a image transparency based on music loudness?

How could i set a image label transparency based on the loudness of a music?

Take measurements of the Sound.PlaybackLoudness property as the music plays at specific small intervals. Then divide that value(or perform any math you like) to normalize it from a large value(that is often between 100 and 300) to a transparency value(that must be between 0 and 1). You first need an equation to normalize between 0 and 1, then if you want to invert the result just do 1-result as the final equation. I also suggest you use functions such as math.min to ensure the value can’t pass 1.

For example a simple equation would be:

image.ImageTransparency = 1-math.min(music.PlaybackLoudness/250, 1)

You may want to make the equation dynamic so it depends on average loudness, etc.

1 Like

Thank you so much!, Do you recommend this to be on a render stepped or stepped?, also, what do you mean by dynamic exactly?

the “1” means that the max transparency will be 1?

Put it inside a loop that frequently updates, just don’t use PropertyChangedSignal because it doesn’t work for PlaybackLoudness.

The divider here is a constant, the value 250, we assume that’s the average loudness for the song. But each song is different, another may have a different average(be less or more loud). So you may want to derive the divider through some sort of sample calculation, where for example you store the last 200 playback loudness values, and you derive the divider by doing totalSum/200.

The 1 means that the max value math.min can give us is 1, we do that on purpose because it’s the max transparency value. Then when we invert the minimum is 0, that is the smallest transparency value.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.