Rhythm Game in BGE

I have been wanting to create a rhythm game in BGE for a long time now, but there is still a problem I can’t figure out. I don’t know how to go about making the stage animation play in sync with the music. If there is any dip in frame rate, the stage animation gets out of time with the music. Anyone have any ideas?

By using aud Python module to play the song you can keep track of the current playing time through Handle.position. This way, you may try to spawn the notes at specific time values of the song, making the notes async to the framerate. I’ll try to make a example blend file for you (I’m also interested in making a rhythm game someday, this subject is also of my interest).

1 Like

Please do! This method sounds very interesting

Here’s the example file and a video showing it working. It was a bit more tricky than I thought it would be, but it’s quite functional for an example. :laughing:

ExRhythm.zip (710.7 KB)

2 Likes

is it possible to detect realtime audio input ?
i want to create automated lipsync but with realtime sound input,

cube should move according to my voice frequency , no recorded audio, it should react as i speak

is this possible ?

Thank you very much for this! This is exactly what I was looking for

1 Like

I’ve researched a little and found out the sounddevice (updated more recently) and PyAudio Python libraries.

I was able to record and playback in realtime from the microphone with this code:

import sounddevice

# Constants
SAMPLE_RATE = 44100
RECORDING_DURATION = 2.5  # In seconds

# Record audio with given duration, sample rate and channel number
recording = sounddevice.rec(
	int(SAMPLE_RATE * RECORDING_DURATION), # Total duration in samples
	samplerate=SAMPLE_RATE, 
	channels=1, 
	dtype='float64'
)

# Wait for recording to finish
print("Recording Audio")
sounddevice.wait()

# Play recording with given sample rate
print("Audio recording complete , Play Audio")
sounddevice.play(recording, SAMPLE_RATE)

# Wait for playback to finish
sounddevice.wait()
print("Play Audio Complete")

However, as I don’t have any knowledge about sound processing (pitch / amplitude detection, etc), so I can’t help any further.

I made a rhythm game for BGMC one time. it used the wave library to get the amplitude of the music, and you had to jump over blocks the size of the amplitude.

https://blenderartists.org/t/bgmc-27-sound-blocks