# Question How Would I go About Making a Rhythm Game?

Discussion in 'General Discussion' started by Bl00dyFish, Nov 19, 2023.

1. ### Bl00dyFish

Joined:
Mar 12, 2022
Posts:
71
Hello!

I want to start making a rhythm game where a song plays, and you have to press random buttons to the beat of the song. I want to be able to detect significant beats in the music and then instantiate an indicator for which button to press.

I feel like this could be simple to do (but I could be wrong since I have absolutely NO experience working with music in Unity).

Is there a method I could call before the game starts to find these beats in the music clip?

2. ### DevDunk

Joined:
Feb 13, 2020
Posts:
4,881
If the notes are random, you can just take the BPM of the song and spawn based on that. That could be once every 4 beats, every 2 beats, every beat, every half beat, etc.

For automatically increasing intensity you could look into reading the audio (not sure how exactly).
Maybe the average sound level of that section of the clip to see when more music is played? Or when the average frequencies change much, indicating a change of music?

3. ### Bl00dyFish

Joined:
Mar 12, 2022
Posts:
71
How would you get the bpm for a song with code? Is there a method?

4. ### neginfinity

Joined:
Jan 27, 2013
Posts:
13,498
There were several libraries for music analysis, I think a lot of them for C++. Have you actually tried search engine?

The thing is, very often those games feature hand-crafted tracks. Meaning somebody placed every note, manually, using existing track as a reference. Beat Saber works this way. Same deal with Guitar Hero.

5. ### halley

Joined:
Aug 26, 2013
Posts:
2,287
If you wanted to guess the bpm of a wave file without any prior knowledge, you could

* perform a fourier analysis to break it down into frequencies
* inspect the lower frequencies and ignore the higher frequencies
* look for peaks in the lower frequency energy
* find the median gap in time between peaks (not mean gap, median gap)
* assume that the median gap is the beat, and inversely the beats per minute
* hope that the song doesn't change signature in the middle

6. ### PanthenEye

Joined:
Oct 14, 2013
Posts:
2,018

Joined:
Oct 5, 2013
Posts:
3,951
I second Koreographer, used it back in 2016 and it was great then, its come leaps and bounds since then

8. ### bluescrn

Joined:
Feb 25, 2013
Posts:
640
If you want to make a *good* rhythm game, you most likely need to create track-specific gameplay markup, and custom tools for editing it. It's not just about detecting a beat, you need the gameplay to match the intensity of the music and maybe the rising and falling pitch of melodies.

(Although these days, maybe there's the potential for an AI-based solution to generating it procedurally for arbitrary music tracks... I wonder if there's enough existing Guitar Hero/Rock Band data to train an AI to generate markup for arbitrary tracks? Purely in theory of course, wouldn't want to get into the potential copyright issues there...)

DevDunk likes this.