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
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?
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?
Code:
if ((int)lastTime != (int)bpmTime) metronome=(metronome+1)&3;
lastTime = bpmTime;
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
1. never use == with a float/double
2. have a look at QueryPerformanceCounter
Also try finding the metronome interval using something like
instead of messing with incrementing after comparison.
Code:
floor(time/intervaltime)%4
instead of messing with incrementing after comparison.
sweet, thanks for the advice =D
If you can avoid using floating point don't use it. Specially with timers!
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 :)
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 :)
Code:
bpmInterval = (60 / BPM) * 1000;
...
beat = floor(time / bpmInterval)%4;
yes.
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.
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.
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
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
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).
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.
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.
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.
^^^^
Ha, tell me about it.. I would recommend treating each transition differently. There is no magic formula or special trick, just hard work.
@ps
yeah, i know its not a blog hehe.. i just get excited is all :)
yeah, i know its not a blog hehe.. i just get excited is all :)
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!
ps said it! FLASH! FLASH FLASH!
! ! H Y P N O G L O W ! !
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.
No! Just record space-bar taps, and flash it like there's no tomorrow!
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!
loadScene("scene1"); // scene one prolly will be a loader or some sort
if(demoTimer > 10){playTransition1("scene2");} //and we're off!
add picture of bruce lee, david hasselhoff or chuck norris.
always a good transition.
always a good transition.
/startthread "this morning my knee was itchy, so i scratched it and continued doing my regular affairs."
classes are overrated.
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.
xteraco: hey man, don't listen to this Navis guy. What do he know about transitions?!