Game
Rock Beyond Time
4 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

Importing again.

It may say there are 20 warnings, but 18 are about "__cam" and two are about "array_length_1d", related to ye olde depth system.

...well, I don't know if I should be worried about either at the moment.

He's coming back. ...but just this once.

If you think YOU're asking "Is it done yet? Is it done yet? Is it done yet?" then just imagine how I feel every time I have to add little details and bug fixes.

...I'd better make a trailer or pitch reel.

Just a reminder. It's coming on the 16th, assuming nothing goes wrong.

Do you know how hard it is to get THIS shot?

Like I said, I'm making level thumbnails for the Level Select screen. Also, this gives you a good idea how big the max health bar is.

How it started vs. How it's going.

The character-puppet thing ended up being the basis for the boss designs instead of the Robot Maid herself.

I could salvage it, but I'd think adding a mode where bosses fight each other is a bit too extra.

I hope you appreciate what I go through for pointless details like this.

I don't plan on going this crazy too much, though.

Well, finding glitches was bound to happen.

In this case, with a scrolling boss, the player's trapped on the left side of the screen until there's no solid block there.

I'd better fix that, THEN shrink the gap behind the boss.

I was considering releasing the expansion today, but then I found a lot of bugs I should've spotted in the original build, and I made the minimap do extra stuff for said expansion.

Don't worry, it'll be out by tomorrow night.

I'm pretty sure I got the save feature working, though I don't know if three save files is acceptable.

Then again, the save features are for Casual Play only. Arcade and Caravan Modes don't let you save your game, for hopefully obvious reasons.