Game
Rock Beyond Time
3 years ago

Important formulas for syncing animation to music


Okay, so let's say you've written songs for your game, and you want to sync up the animation to it on Game Maker. Well, there are many ways to go about it, but the key component is this:

audio_sound_get_track_position(BGM)

This little thing tells the computer where in the sound file it is. As such, if audio_sound_get_track_position(BGM)> whatever, do this. If you want it to do something ONCE, I recommend making a second variable. For example, if audio_sound_get_track_position(BGM)> a point in the song, and Bit < 1, make Bit = 1, and do that one thing once.

Now, you could just find out where the sound is on Audacity, but that can get messy in the world of audio-syncing. However, there is one factor that can make your life easier, especially if you're syncing it to a song you wrote: the tempo.

You see, the tempo is measured in Beats Per Minute, and can be easily found in the music-making software you used. The BPM is fine and dandy, but if you want to get real with your code, you need to know Beats per Second. So...

BPS= BPM/60

...and let's say you want to know how long a beat actually is, in seconds, which would be a decimal. Now, there are 60 seconds in a minute, so...

Beat Length= 1/(BPM/60)

Also, for further reference, a "Beat" is one Quarter note. Also, the math can get messy and lead to the decimal equivalents of 1/3 and such, with its infinitely repeating decimal points, so it's just easier on the brain if you let the computer do it.

Now, let's say you want to do an animation loop that matches with the beat, and need to find the proper animation speed, where 0 is NOT moving, and 1 is moving exactly with the frame rate. Well, replace that 1 with the frame rate, and divide all that by the number of frames between beats.

Animation speed= Frames between beats/ (FPS/(BPM/60))

This might be very helpful if you ever want to loop a drum beat or a metronomic movement without having to type out horrendous amounts of code. Maybe, if you're clever.



0 comments

Loading...

Next up

I realize some players just want to play the game and see the story, while others may actually want to use those revival items, so here's a little compromise for you all.

Also, yes, I NEED to put on that "Pro" flag everywhere.

It's getting closer to being finished.

Even though the 2.5D gimmick was only for that one level, I see no reason to not use it for this boss fight.

I decided that the fourth button will be used for switching between using weapons, and not using them. Why? Because it works with the mouse's scroll wheel.

Also, you've got an indicator at the top-left if you've got the gun active or not.

A rather interesting thing I forgot about...

That boss is now done, and implemented.

I can safely say I've completed half of the main game now, even though it's just the first three levels and the second-to-last.

Time to do something else.

Welcome to Space.

...not much going on here, is there?

Why a chrome sphere for this logo? Because I wanted to.

What happens in the "O" usually changes from game to game. Cybosaurs had Sinistar, Shiro Ninja had , Shiro Ninja Mayhem had Pirate Jack, Dragonian had the cast of Staff of Laria, and so on.

If there's going to be a save feature in my game, I might as well give the players their own kind of Level Select so they can replay it any way they want.

I know I should work on that boss, but still...

The next update may be full of bugs.

...moths, mostly.

Part of the expansion involves a cute little fight right here. ...in space for no apparent reason.

...too bad it won't be as epic as the final boss, but still...