[l56] Need help!

Posted by leemcd56 on Nov. 22, 2009, 2:38 p.m.

I desperately need help figuring out this mathematical conundrum. I've never been good at math so I'm pretty much fried. I'm trying to create a metronome in Game Maker (I have reasons) and GM is sadly so screwed up you have to bust your brain to figure everything out. I've discovered that the perfect second in the alarm system is a delay of 30 between each alarm. Now, to calculate the delay time of a tempo beat is simple because there are 60 seconds in a minute, and 1000 milliseconds in a second, so that's 60 * 1000, which totals 60000. Fair enough. All I really need is to sort out how to calculate a proper timing mechanism to get all of this sorted out. Since I'm dumb in math I could only think of this:

Quote:
latency = mark_time(120) / 2;

delay = 30;

second = 1000;

alarm[0] = latency;

With mark_time being:

Quote:
return (60000/argument0);

Any help would be greatly appreciated!

P.S. Someone, please add a

block.

Comments

leemcd56 15 years ago

Let me rephrase: Say I used the precise timing DLL, I still need an interim to figure out how to calculate the correct timing I want. That's all I'm asking for now.

PY 15 years ago

It'll do it in ms, most likely. 1000 ms = 1 second.

You'll want to do something like

while 1

now=(whatever the function for current time is)

wait until (function for current time)-now<1000

tick()

PY 15 years ago

Aww, snap, stripped my tabbing.

sirxemic 14 years, 12 months ago

create or something:

Quote:
start_time = current_time;

bpm = 130;

beat = 0;

last_beat = 0;

do_something_like_making_a_tick_sound();

step or something:

Quote:
beat = (current_time-start_time) div (60000/bpm)

if beat != last_beat

{

last_beat = beat;

do_something_like_making_a_tick_sound();

}

EDIT: I tested it, of course it works.

leemcd56 14 years, 12 months ago

sir Xemic, you're a freaking genius! Thanks :D

leemcd56 14 years, 12 months ago

Use what sir Xemic wrote, it works!

Misconstruct 14 years, 12 months ago

I'm your problem, leemcd56 got a good solution.