Skip to content

Add a simple rhythm game demo#1197

Merged
fire merged 1 commit intogodotengine:masterfrom
PizzaLovers007:rhythm-game
May 22, 2025
Merged

Add a simple rhythm game demo#1197
fire merged 1 commit intogodotengine:masterfrom
PizzaLovers007:rhythm-game

Conversation

@PizzaLovers007
Copy link
Copy Markdown
Contributor

Follow-up for one of the project suggestions in godotengine/godot#105510 (comment).

This demo project is a rhythm game that utilizes the audio syncing strategies from https://docs.godotengine.org/en/stable/tutorials/audio/sync_with_audio.html along with a 1€ filter to have a smooth and accurate playback position. The project was built in 4.4.1.stable, thus not requiring the DSP time/play_scheduled from godotengine/godot#105510.

The song was taken from the BPM Sync demo project, and all other assets were made by me.

Key design decisions:

  • The 1€ filter operates on the delta between the audio clock and system clock, rather than the time itself. This is because the anti-jittering mechanism only works well when the filtered value changes very little.
  • V-sync is disabled to allow for more precise input timings (capped at 1000 FPS). "Mailbox" would be ideal here, but this behaves like VSYNC_ENABLED with Compatibility render mode. Switching to Forward+ for this specific reason didn't seem worthwhile since tearing is not visible due to the notes moving vertically.

@Calinou
Copy link
Copy Markdown
Member

Calinou commented Apr 24, 2025

  • V-sync is disabled to allow for more precise input timings (capped at 1000 FPS). "Mailbox" would be ideal here, but this behaves like VSYNC_ENABLED with Compatibility render mode. Switching to Forward+ for this specific reason didn't seem worthwhile since tearing is not visible due to the notes moving vertically.

Note that this should no longer be necessary if godotengine/godot-proposals#552 is implemented.

Comment thread audio/rhythm_game/globals/one_euro_filter.gd Outdated
@fire
Copy link
Copy Markdown
Member

fire commented Apr 24, 2025

From the other pull request, I really appreciated the web demo for explaining.

@PizzaLovers007
Copy link
Copy Markdown
Contributor Author

The metronome demo PR is done now 😃 I was working on cleaning things up before sending it out. #1199

@PizzaLovers007 PizzaLovers007 force-pushed the rhythm-game branch 2 times, most recently from 78acc1f to 8a4821f Compare April 25, 2025 04:34
@fire
Copy link
Copy Markdown
Member

fire commented Apr 26, 2025

I played with the demo and I didn't notice any problems. The game was pretty fun!

Copy link
Copy Markdown
Member

@fire fire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that when toggling the checkbox the filter in the middle of the game it doesn't reset and required a reset. Not sure.

@PizzaLovers007
Copy link
Copy Markdown
Contributor Author

I noticed that when toggling the checkbox the filter in the middle of the game it doesn't reset and required a reset. Not sure.

Do you mean the checkbox setting persists after pressing R to restart? This is intentional since I thought it would make sense to see the opposite filter setting from the beginning if you toggled first, then hit R.

It's supposed to immediately swap between the filtered and unfiltered playback position though, so if you need to hit R to restart before the setting takes effect then something is wrong.

@mk56-spn
Copy link
Copy Markdown

mk56-spn commented May 5, 2025

i have some minor gripes:

the default latency is way overdone,

this is after all a test that will mostly be used by devs on computers, where 42 ms of audio lag is very uncommon on the sort of systems a rhythm game would be being tested on in my estimation ( other than phones)

granted i am not recommending a value as low as mine because i am using a very low latency setup, but something like + 10 ms seems more in line with what most people would expect
image

overall a very well synced and pleasing demo that demonstrates the massive difference a filter does ( its noticeable enough on a 60 refresh rate and helps immensely there already, but cranking it up to 144 or 360 which is not uncommon in the rhythm game play landscape shows a world of difference.

if i had any other requests it would be a scroll speed slider, given jitter is most visible at higher scroll speeds, this would make the difference more stark on 60 especially

@PizzaLovers007
Copy link
Copy Markdown
Contributor Author

Thanks for testing! I'm surprised -2ms is what you felt was correct. I do agree that 42ms is odd, but after repeated tests I can get it consistently <1ms error. I lowered it to 20ms to try to strike a middle ground.

I also added some more things:

  • Scroll speed slider
  • Sync test chart (simple quarter notes, maybe this would help with input sync testing)
  • Metronome, though "flawed" because of the lack of sound scheduling

@fire
Copy link
Copy Markdown
Member

fire commented May 16, 2025

@Calinou Can you take a look? If you approve we can merge.

@fire
Copy link
Copy Markdown
Member

fire commented May 16, 2025

I talked to JulianTodd and he suggest optional things to see the truth for example how the key thump and sound lines up in a graph.

Like the graph in the right side.

image

https://github.com/godot-extended-libraries/godot-debug-menu

It's optional, but I wanted to note.

Here's another view of the stacked graphs.

image

@PizzaLovers007
Copy link
Copy Markdown
Contributor Author

PizzaLovers007 commented May 17, 2025

I've added a graph inspired by ITG Simply Love's results screen:
rhythm_game

Does this look good/is intuitive? Points below the line are late hits, and above the line are early hits.

@mk56-spn
Copy link
Copy Markdown

I've added a graph inspired by ITG Simply Love's results screen: rhythm_game

Does this look good/is intuitive? Points below the line are late hits, and above the line are early hits.

clean and simple , similar to etternas too ( i believe both are Stepmania forks)

@fire
Copy link
Copy Markdown
Member

fire commented May 18, 2025

I uploaded this project as an itchio web https://ifiregames.itch.io/godot-engine-samples-rhythm-game

Copy link
Copy Markdown
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, it works as expected. Code looks good to me.

I think this is a pretty good start as it is. I can perform a polishing pass after it's merged.

My score on a first playthrough (never listened to the full song before):

Screenshot_20250522_225749

I kept the latency settings to their default. I'm on a 240 Hz display with X11 compositing disabled and it seemed suitable out of the box. It was perhaps a tad high and could be changed according to the monitor refresh rate on startup automatically, but this can be difficult to get right.

@fire fire merged commit 1f58baa into godotengine:master May 22, 2025
1 check passed
@fire
Copy link
Copy Markdown
Member

fire commented May 22, 2025

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants