An audio "beat detection system"

I know this will be looked down upon when I ask this as it’s very complex but I am curious where I could possibly start off to make a sound beat detection system. When I mean by sound beat detection I mean by background sound beat and main sound beat too. Let’s have an example: Glitch Mob Remix of Seven Nation Army It has the background sound but then during the remix part I want the “beat” detector to focus on the remix sounds. The script should be able to get the beat down without before rendering. Before you say start off by making a script to track playback loudness and time position I have already done that.

The goal of the formula(s) is to find a way to ignore all other audio except playbackloudness beats or audio peaks

I don’t expect formulas shared here but it will be appreciated. I just want places when I can start off right now as I’m scratching my head right now on where to start.

Update:
Go to here

11 Likes

Are you trying to detect the BPM of said songs?

There’s no good way to do that with the current audio tools on Roblox from what I know. Using loudness alone probably won’t be very accurate.

That being said, there’s loads of websites that detect song BPMs. Maybe some of them could work with HTTP Service? That would probably be the best way.

Also, if that’s not an option, many songs in certain genres have BPMs in a certain range. For example, EDM music tends to have tempos around 128 BPM.

If you aren’t talking about BPM, are you referring to the actual sounds in the song? Those technically wouldn’t be the “beat” and would rather be specific instruments, which I know would basically be impossible to detect, especially on Roblox. In fact, there is no professional software that can detect specific instruments precisely. There’s just way too many factors for it to be possible.

So basically, you can’t really do this with the current tools available unless you can figure it out with HTTP Service. Would be pretty cool though.

5 Likes

I meant actual sounds.

Doing my research I found an EqualizerEffect the issue is it doesn’t affect playbackloudness sadly. Low Gain would help me a lot

1 Like

What exactly do you need the beats for? There could be another way.

I wanted to make an EDM stage. So auto detection for sound beats would be useful for me.

If you know which songs will be playing, you could look up the BPMs of said songs and then apply that to them manually.

That could possibly work then there could be a chance that a BPM library wouldn’t support a song. I tried lua coding it. (I had lost the coding) but I remember using LastPlaybackloudness and Playbackloudness. I was comparing them to see if a difference in audio happened

Like I said, there are some websites that can detect BPMs. I use this one a lot and it seems pretty accurate. You can always use something like that if your library doesn’t have a song.

1 Like

I was not looking for this answer but this is a good place for a starting point. Thank you for your help

No problem. Good luck.

Alright, I’m sorry but I found a game that had what I was looking for:

Go to the dancefloor and you’ll see.

It looks like it’s just reading the playbackloudness and applying effects depending on how it changed. No special beat-detecting stuff at all.

EDIT: And the reason this works is because the kicks in the songs in there are mixed really high.

1 Like

Alright, thank you. I think this is where I can start off.

Okay cool.

Well, there might be a little bit of special stuff going on :smirk: It’s true that the only real-time data source is PlaybackLoudness, and that the loudness values are all from before the DSP chain, so EqualizerEffect has no effect on PlaybackLoudness values.

That’s a big part of it; the fact that kicks are high-amplitude gives the code an excellent shot at correctly identifying the “main beat” of a dance tune. But a few of the lighting effects (the RAVEN sign over the stage, and the disco ball in the space lounge) use autocorrelation as well, both to decide where the main beat is an then reject transients that are off-beat (have a low autocovariance score). A loud enough transient can still power through the weighting and trip the effects, it will never be perfect. It could be a little smarter even than it is, by playing a second copy of the song silently ahead in time of the copy you hear, but there is a bug with multiple sound sources playing the same ID that made that problematic.

4 Likes

Thank you for this. This helps me a lot now. I am not planning to make a club game with this and actually plan making a parkour beat style game.

1 Like

Sounds lit.

If you have a fixed soundtrack, you can to a lot better effects synchronization by pre-processing the audios offline and generating metadata. That’s just not usually an option for clubs and boomboxes, because they can play nearly any sound Id or have too large a playlist for this to be practical.

Now I’m scratching my head on the conversion of playbackloudness to Hz. I found a possible method but I need to convert playbackloudness to Hz.
(Documentation - Roblox Creator Hub)

Edit: I need to add an equalizer sound effect formula. I need to get the Hertz for the Low Gain. Are there any methods?

Nope, thinking of it as needing an equalizer is the wrong approach. 60 samples per second of average loudness is not an audio signal, and you can’t treat it as such. You’d need 100 times this many samples per second to separate just low to midrange frequencies. The filters in Club Raven are not filtering audio frequencies at all, they are all well infrasonic and correlating the loudness signal to frequencies that correspond to BPM.

For example, the loudness envelope of a 120 bpm song is going to correlate strongly with a 2Hz reference signal. Beat detection requires finding which frequency signal correlates most strongly, and syncing to the beat is finding what phase maximizes the correlation. There isn’t exactly a simple formula for this, it’s a signal processing problem that’s well off the beaten path of general game programming.

2 Likes