PDA

View Full Version : Timing errors


Dmaxer
09-16-2005, 06:20 AM
Sorry for posting again on this subject . I have read a few posts in this forum regarding
Timing and the clock (ticks) max runs at and this post
http://forums.cgsociety.org/showthread.php?t=266473&highlight=ticks (http://forums.cgsociety.org/showthread.php?t=266473&highlight=ticks)
did help me but Im still stuck so here goes



Im reading data from a midi ,writing that data to a text file .then reading the
text file in to max. that part works fine, but I cant get the timing right. if I play a wave
rendered from the same midi file I use to animate my objects in max
You see and hear that the animation is way out

all the timing data in the text file is in microseconds

I read the a value into the variable Tempo
Then read a value into the variable Div
Then I get the variable PPQN by Tempo / Div

So if Tempo = 500 000 and Div = 480, PPQN will be 1041 and this
variable tells me the length in microseconds each click should represent

I then go on to read my Click variable and rotate an object at that time

So right now part of my code looks like





PPQN = Tempo / Div
ani = PPQN/4800
T2 = ani*click
at time (execute(T2 as string + "t")) rotate theObj rot_key





can anyone tell me if theres a better way to do this ?? Im still learning Max
script so please forgive me if its something simple Im missing
I do know I must be doing this wrong but
Im not sure how to go about fixing it
I found if I multiyply ani by 23 it seems the timing is a
lot closer but it driffs off the longer the animation runs
so the error is adding up with each click
Thanks for reading

All the best Danny

Dmaxer
09-16-2005, 10:00 PM
well Im still working on this and Ive found if I multply ani by 23.1 the timing is very good , but its still drifting out , any ideas guys ?

Bobo
09-16-2005, 10:18 PM
well Im still working on this and Ive found if I multply ani by 23.1 the timing is very good , but its still drifting out , any ideas guys ?

Not sure what exactly you are doing, but if you have a variable in Milliseconds,
all you have to do is:

1. Turn the milliseconds into seconds by dividing by 1000.0
2. Turn the seconds into frames by multiplying by FrameRate

So if you have 1041 ms, the result would be
1041/1000.0*FrameRate = 1.041 * 30 = 31.23

You can use this value to set the current time.

If your FrameRate is different, the multiplier might be 24, 25 etc., but the general functionality will be the same.

Dmaxer
09-16-2005, 11:00 PM
Thanks Bobo but all the timing data in the text file is in microseconds
each one of the click values I read from the text file is the amount of ppq microseconds that have passed , so if ppq = 1041 and click = 9600 then that should be 1041 microseconds * 9600 = 9993600 microseconds .
but if I do it like this it dont work

Dmaxer
09-16-2005, 11:21 PM
ok I used this code here but I end up with a about 52 seconds of animation it should be about 10 seconds with ppq = 1042 and timecode = 9600 both of these timing are in microseconds not milliseconds , :(


ppq = Tempo/Division as float -- microseconds per PPQ
ani = ppq/1000.0*FrameRate
T1 = (ani*timecode) as float
animationRange = interval 0 (execute(T1 as string + "t"))

Dmaxer
09-16-2005, 11:23 PM
Im goin to keep at it , thanks for your help Bobo , I will work it out in the end :)

CGTalk Moderation
09-16-2005, 11:23 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.