[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

Kaz 14 years, 12 months ago

Uh why don't you just do this?

Create:

Quote:
alarm[0]=room_speed//1 second

Alarm 0 event:

Quote:
alarm[0]=room_speed

sound_play(sound)

leemcd56 14 years, 12 months ago

Because that would only work for a tempo of 120. If I wanted to change it to 240 then that wouldn't help.

Kaz 14 years, 12 months ago

So multiply room_speed by 2?

leemcd56 14 years, 12 months ago

Yeah, no, that doesn't work. Let's pretend the room_speed variable doesn't exist.

Kaz 14 years, 12 months ago

Well if you're just trying to play a sound every second or a period of time relative to a second, it should work. You just have to find what you have to divide/multiply by.

TempoWanted=240;

AlarmSpd=(60/TempoWanted)*room_speed;

Should work O_O

Kaz 14 years, 12 months ago

If you don't want room_speed, there's a few precise time dlls on GMC.

leemcd56 14 years, 12 months ago

True, but the only reason I'm trying to figure this is just in case I want to migrate out of GML for another language. I can tap out the screwed up timing in the alarm system myself if I decide that, but I'm just trying to figure out this formula XD.

PY 14 years, 12 months ago

if you moved away from GM you'd have access to real timing. Stop using GM if you want to stop using GM. It's meant for making games, not language-agnostic algorithms.

leemcd56 14 years, 12 months ago

I'm not intending on giving up GM at the moment, just pissed at not being able to figure out this algorithm. It's relating to a game I'm working on, which involves a metronome and I want it to be correct, and I'm going to use a precise timing DLL but I still need to figure this out. So, stop running around in circles and help me if you can. Otherwise, no comment.

PY 14 years, 12 months ago

ooh la la. You're using GM, you don't get to be picky with your coding. Either use built in functions, or use a timing dll, there is no middle ground, so don't shout at me because you want one.