pouët.net

Go to bottom

medium precision timer .... stumped

category: general [glöplog]
I've been working on the demo system for that new team i mentioned, and i've hit a brick wall... I'm working on timers, i've got a sortof "high precision" timer if you will, that increments based on BPM's, and i'm working on what is to be a sortof metranome... the return for the metranome member would be something like, a number between 0 and 3, and would only increment based on bpms, so if you were at 4bpm, it would increment every 15 seconds... i thought i had it all worked out untill i did a check that looked like this

Code: tempTimer = (int)bpmTime / bpmTime; if(tempTimer == 1.0){ metranome++; } if(metranome > 3){ metranome = 0; }


problem is, it doesent work.... the value almost never == 1.0... the best i've done is if(tempTimer > 0.99){blah} wich is largely innaccurate... so, i made a sortof console output to show me the numbers. As i suspceted, wasnt hitting 1.0, it'd hit 0.993423, then go to 1.000023.... thus throwing me off track...

My initial idea is to find a way to make my own type, that is a float with a lower precision ... so rather than having 7 digits, a type that only has 3, 2 being to the right of the decimal... but, no luck on figuring out how to do it...

Anyways, i'm not to good with math(but i'm learning) and i dont know all of stl, so i'm in need of a little help...

any idea's?
added on the 2007-06-26 01:07:50 by xteraco xteraco
Code: if ((int)lastTime != (int)bpmTime) metronome=(metronome+1)&3; lastTime = bpmTime;



added on the 2007-06-26 01:11:17 by kb_ kb_
I haven't read your stuff entirely (too long) but keep 2 things in mind:

1. never use == with a float/double

2. have a look at QueryPerformanceCounter
added on the 2007-06-26 01:11:49 by keops keops
Also try finding the metronome interval using something like
Code: floor(time/intervaltime)%4


instead of messing with incrementing after comparison.
added on the 2007-06-26 01:17:10 by bruce bruce
sweet, thanks for the advice =D
added on the 2007-06-26 01:20:26 by xteraco xteraco
If you can avoid using floating point don't use it. Specially with timers!
added on the 2007-06-26 01:24:23 by xernobyl xernobyl
I didnt want to use floating point numbers, but what happened is I have a function called pollTimerBPM which takes bpms as an argument... to figure up our interval i do something like

bpmInterval = (60 / BPM) * 1000;

wich doesent always render an integer... when working with odd bpms and such it gets difficult... Anyways, i'm at work right now, and kindof skateing on the edge of my boss's threshold.... been working on this "demo thing" all day, and not doing work just after putting in a 2 weeks notice... so i've not been able to fully concentrait...

When i get home tonight, gonna grab a couple beer's and hit the code hard and see what comes of it :)
added on the 2007-06-26 01:31:32 by xteraco xteraco
Code:bpmInterval = (60 / BPM) * 1000; ... beat = floor(time / bpmInterval)%4;

yes.
added on the 2007-06-26 01:41:17 by bdk bdk
I normally do a:

beat=pow(max (0,cos (2*PI*time/bpmInterval)),8); or something like that myself. beat now has continuity and your linked events will develop alot more naturally.

added on the 2007-06-26 07:35:02 by Navis Navis
got it all working last night :)

also had a chance to fix a few bugs this morning... i'm almost to the part where i can add the 'pretty bits'

we (as in our small team) are thinking, we want to have a fairly robust transitions system so we can have a stylish way to flip between scenes... so that might be what we start working on next, not sure
added on the 2007-06-26 17:23:18 by xteraco xteraco
Maybe it's easier if you skip the BPM shit and just use the time, and to the sync by hand on the demo or the music (whatever is easier).
added on the 2007-06-26 17:30:41 by xernobyl xernobyl
you do realize pouet aint a blog right?
am just saying, dont be surprised if people start telling you to fuck off if you keep opening threads everytime you're doing something..
just dont say i didnt warn yah.
added on the 2007-06-26 17:33:20 by psenough psenough
we want to have a fairly robust transitions system so we can have a stylish way to flip between scenes... so that might be what we start working on next, not sure
^^^^

Ha, tell me about it.. I would recommend treating each transition differently. There is no magic formula or special trick, just hard work.
added on the 2007-06-26 17:35:02 by Navis Navis
@ps

yeah, i know its not a blog hehe.. i just get excited is all :)

added on the 2007-06-26 17:44:48 by xteraco xteraco
Quote:
Ha, tell me about it.. I would recommend treating each transition differently. There is no magic formula or special trick, just hard work.


when bored of fadeins and blunt cuts remember: you can always still use the good old white flash!
added on the 2007-06-26 18:04:08 by psenough psenough
ps said it! FLASH! FLASH FLASH!
added on the 2007-06-26 18:11:33 by kusma kusma
! ! H Y P N O G L O W ! !
added on the 2007-06-26 18:15:14 by psenough psenough
Quote:
There is no magic formula or special trick, just hard work.


True. If you try to find a general formula that is supposed to work everywhere, you'll only end up with dull stuff (like FFT based sync)

Xteraco: I strongly suggest that you don't try to follow any well known recipe. Get some information on how people usually do things but then try to implement you own system with your own touch and ideas.
added on the 2007-06-26 18:15:14 by keops keops
No! Just record space-bar taps, and flash it like there's no tomorrow!
added on the 2007-06-26 18:26:04 by kusma kusma
the way i've been looking at doing it is making a class for transitions alone, and after all the boring system stuff, setting down and codeing transitions as its own function, and doing maybe 10 of em... so in the main code, i could say something like

loadScene("scene1"); // scene one prolly will be a loader or some sort
if(demoTimer > 10){playTransition1("scene2");} //and we're off!
added on the 2007-06-26 18:27:51 by xteraco xteraco
add picture of bruce lee, david hasselhoff or chuck norris.
always a good transition.
added on the 2007-06-26 18:28:50 by psenough psenough
/startthread "this morning my knee was itchy, so i scratched it and continued doing my regular affairs."
classes are overrated.
added on the 2007-06-26 19:11:46 by xernobyl xernobyl
the oop is not the issue here but the content. Maybe you are missing the point. All the UML diagrams in the world will not save you if the concept is wrong, aesthetically speaking.
added on the 2007-06-26 19:20:08 by Navis Navis
xteraco: hey man, don't listen to this Navis guy. What do he know about transitions?!
added on the 2007-06-26 19:41:27 by Hyde Hyde

login

Go to top