Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /storage/content/49/145849/famitracker.com/public_html/forum/classes/dbHandler.php on line 29 FamiTracker
Login:
Menu:
Post: Author:
FamiTracker > General > FamiTracker Talk > Famitracker's non-150-tempo Frame Distribution Owner: gyms New post
Page 1 of 1 Sort:  
Famitracker's non-150-tempo Frame Distribution Posted: 2012-09-17 01:16 Reply | Quote
gyms



Member for: 4183 days
Status: Offline

#39632
Today I was comparing FT's compiler with ppmck's compiler to see if there were any differences in how they divided and distributed frames toward certain note values when the 'tempo's were set to something other than 150(@60Hz of course).

I found that at tempo 120 there were no differences at all, however there are slight variations at tempo 143(under the nsfimport microscope). I also noticed quite a few interesting things at this tempo in regard to frame skipping patterns.


I measured the frame distribution toward sixteenth notes at tempo 143. The following values indicate how many frames each successive sixteenth note recieved(the beginning of the pattern at least):

FT: 7 66 7 66 7 666 7 66 7 666 ...
ppmck: 6 7 666 7 66 7 66 7 666 7 ...

It's odd to confirm that the compilers handled frame distribution differently, but I noticed something else about FT's compiler that's a bit interesting.

If I render the same ftm multiple times, the pattern is different each time. For example:

the first render would be: 666 7 66 7 666 7 66 7 ...
and the second render would be: 7 66 7 66 7 666 7 66 7 ...

And if I listen carefully, it seems that each time I start realtime playback, it starts on a different point in the pattern.

Does anyone (rainwarrior? jsr?) know what's up with this? How does FT's realtime playback and compiler handle frame distribution at these kind of tempos?


Also I tried to establish where the pattern actually stopped and repeated itself with tempo 143. It's either ridiculously long or there's some form of randomization going on with the pairs of two and three sixes.

I'd really like to know how these patterns work. There's a musical reason for it, but I'll bring that up later perhaps.

Posted: 2012-09-17 05:00  (Last Edited: 2012-09-17 05:12) Reply | Quote
rainwarrior

Avatar

Member for: 4150 days
Location: Canada
Status: Offline

#39635
You should notice that ppmck and FT are producing the same pattern, they just started at a different point in the pattern. Similarly with FT doing it differently at different times, it probably just doesn't reset its tempo generating device when you stop or play. (This might be considered a bug.)

It's very similar to [url=http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm]Bresenham's Line Algorithm.

The way you keep your framerate in synch with an arbitrary timing (i.e. your tempo setting) is to always keep a running total of the total time spent, and when it reaches your time per row, play a row and subtract that time from the total. Something like this:


time_accum = 0 ms;
time_per_row = 179 ms;
time_per_frame = 15 ms;
.
for(each frame)
{
... time_accum += time_per_frame; // account for time spent this frame
... if (time_accum >= time_per_row) // we have accumulated enough time to play a row
... {
....... advance_row();
....... time_accum -= time_per_row; // account for time used on row
... }
}

So what this code is doing is adding time to our counter every time a new frame is reached; this tells us how much time has elapsed that hasn't been spent playing a row. When we reach our threshold (time_per_row) we play a row and can subtract the time owed to that row from our counter. This is a fairly standard algorithm for keeping a consistent timing.


When "time_per_row" is a multiple of "time_per_frame" in this example, you will get the same number of frames per row every time, but if they are uneven, the unused portion of each row accumulates until it finally spills over. Consider if they were 7 and 3:

before we start: time_accum = 0
frame 0: time_accum = 0+3 = 3
frame 1: time_accum = 3+3 = 6
frame 2: time_accum = 6+3 = 9 >> play row, time_accum = 9-7 = 2
frame 3: time_accum = 2+3 = 5
frame 4: time_accum = 5+3 = 8 >> play row, time_accum = 8-7 = 1
frame 5: time_accum = 1+3 = 4
frame 6: time_accum = 4+3 = 7 >> play row, time_accum = 7-7 = 0
frame 7: time_accum = 3
frame 8: time_accum = 6
frame 9: time_accum = 9 >> play row, time_accum = 2
frame 10: time_accum = 5
frame 11: time_accum = 8 >> play row, time_accum = 1
frame 12: time_accum = 4
frame 13: time_accum = 7 >> play row, time_accum = 0
frame 14: time_accum = 3
frame 15: time_accum = 6
... (pattern repeats)

You'll see that this generates a pattern of 3, 2, 2, 3, 2, 2...

Posted: 2012-09-17 08:32 Reply | Quote
gyms



Member for: 4183 days
Status: Offline

#39636
Thank You!

Posted: 2012-09-17 22:02 Reply | Quote
jsr
Administrator

Avatar

Member for: 5924 days
Location: Sweden
Status: Offline

#39668
I don't think I have anything more to add, other than that the tempo counter is supposed to be cleared each time the player starts, so I can't tell why it would produce different results. I'll need to check this.

_______________________
Programmer and developer
Posted: 2012-09-22 23:22 Reply | Quote
jsr
Administrator

Avatar

Member for: 5924 days
Location: Sweden
Status: Offline

#39798
gyms: I checked the tempo code and the counter appeared to be cleared properly, so I could not reproduce the problem. Did you get this problem in the latest version?

_______________________
Programmer and developer
Posted: 2012-09-27 08:46 Reply | Quote
gyms



Member for: 4183 days
Status: Offline

#39950
After messing around a bit, I figured out what happened: one of my tests had more rows in the frame than the others(hurrr)

Didn't really occur to me at the time I was first doing all this stuff that the length of the song affected the division, which would also explain why the ppmck nsf didn't line up with the FT nsf. I just dropped a big, random number of 16th C notes at tempo 143 into ppmck and then filled up a FT frame with C notes, which I loosely guesstimated to match the uncounted number of notes in the ppmck one(there were more than 64 rows). When I tested FT against itself, I must have just left the default 64 rows on.

haha, jeez...sorry to bother you with my clumsy tests, but thanks for checking, jsr! :-))

Posted: 2012-09-28 11:51 Reply | Quote
jsr
Administrator

Avatar

Member for: 5924 days
Location: Sweden
Status: Offline

#39981
Ah ok, no worries gyms. :)

_______________________
Programmer and developer
Page 1 of 1 Sort: