Syncing scripts to beats/start of measures?

I’m making a rhythm game, where the user has to press buttons in sync with symbols moving on a track (think Guitar Hero or Dance Revolution). I’ve got the track, the button patterns and everything working by a script called Rhythm.cs, but I still need to sync the rhythm patterns to the music played by FMOD. I’ve searched everywhere about beat syncing in FMOD, and all lead to this tutorial: https://www.fmod.com/resources/documentation-unity?version=2.0&page=examples-timeline-callbacks.html

But to me that just looks like a blob of code without any instructions how to use it, or how to do different things. Could anyone please help me understand and use it?

What I need is:
1. Fetch tempo of the music from FMOD to Rhythm.cs. Maybe also time signature, but everything is 4/4 by default.
2. I need to wait to the start of a measure to start the rhythm game in Rhythm.cs, so that the button pattern will align to the beats. So I need FMOD to tell me when the next measure starts. I don’t know if it’s necessary, but I’ve added markers in FMOD Studio into start of every measure, just in case.
3. I probably need to check the start of the measures periodically, so the patterns stay in sync.
4. Alternatively it would be good to get info of every beat, but start of the measures will be fine for now.
5. Also, the music is going to loop obviously, so it has to work with that.

Can anyone please help me to get started?

The FMOD_STUDIO_TIMELINE_BEAT_PROPERTIES used in the callback contains information like tempo, time signature, bar, beat and timeline position.

There are a number of other callbacks you can register for as well, FMOD_STUDIO_EVENT_CALLBACK_TYPE.

Did you ended up working this out?

I’m working on a little package with two features that make rhythm games really simple:

  • Any method can be called on the beat (or on any specific beat/bar, every second beat etc.)
  • Any method can be called based on an FMOD marker (eg. create a destination marker in FMOD and a method of the same name will be called on any object (MonoBehaviour) in Unity.

The package is still rough around the edges but I could share it with you privately for now if you just want something to get you started!

Jake

Hello.

I would be very interested in this package if you would be willing to share it.

Thanks in advance!

-Janne

WAY late to this, but just in case anyone else is interested -

Haven’t touched this for a while but I think it mostly works alright!

1 Like