Finding out a audios BPM (Beats Per Minute) using PlaybackLoudness?

Well I did it for the fun of it when my friend was making Audio Visualizers, but basically here’s what I did:

On heartbeat I’d check the PlaybackLoudness, I have a table where I save the value on heartbeat in so I can “Average” it between all the values, that way we can see what the average of “beats” will be and I just render anything that’s higher than that as a “beat”.

(Of course if you want something more advanced then I’d suggest looking more into sound frequencies)
so basically :

local loudnessValues = {}
game:GetService("RunService").Heartbeat:Connect(function()
   local average = 0
   for _,v in ipairs(loudnessValues) do
        average = average + v
   end

   average = average / #loudnessValues
   local isBeat = sound.PlaybackLoudness >= average
   
    --visualizing code basted on isBeat etc.

    loudnessValues[#loudnessValues + 1] = sound.PlaybackLoudness
end)

Probably not the best way to approach this but that’s basically what I did, yes it’s “real time” and if you’d like to see the output then :
Audio Visualizer - Roblox (open devconsole if you’d like to see isbeat or not)

16 Likes