On Thu, 2001-09-20 at 21:25, Joe Drew wrote:
I don't know if it's accurate - I haven't been able to test it yet - but my algorithm is this:
frame(n) = frame (n-1) + (header->bitrate / 100) * mad_timer_count(&header->duration, MAD_UNITS_CENTISECONDS);
You might try changing that to /1000 and MAD_UNITS_MILLISECONDS, but I don't know how that will affect it. As I said, I haven't been able to test this yet - it remains to be seen how well it will work.
The formula detailed above neglects one important consideration: bitrate is in bits, and mmap()ed files are in bytes. You have to divide the bitrate by 8.
The revised formula[1] seems to work pretty well. I don't know that it's perfectly accurate - for that, it seems that XMMS has lookup tables and other things in its Input plugin - but it is pretty good, and good enough for me. I will see whether it gives noticable jumps when I test mpg321's new seeking with frontends, possibly tomorrow (more bugs still to work out).