Erick,
Thank you very much for your detailed analysis. It has helped me
clarify my thinking and devise a solution.
RB via QT Declares
Duration - 1917006.0 TimeScale units
TimeScale = 600
len = 3195.01 = 53.2501666667 sec = 53:15.01
The one thing you didn't notice, however, is that the last 15 seconds
of the samples produced using QT Declares are all zero, thus there's
only 53:00 of samples there (at 44,100 Hz) for a 53:15 movie. That's
why I get lost when trying to match the player Position with the
corresponding sample.
It is a mistake to think that iTunes and QuickTime Player are
necessarily standards by which to measure and not REALbasic. I know
it may be hard to believe, but I think REALbasic is in the right
this time. I've done a lot of QuickTime development and I can say
without hesitation that I've found QTPlayer to not be the greatest
when it comes to reporting the precise length of files. This is true
in both the audio and video realm all the way down to the frame
level.
I agree that I can accept either as "correct," and go from there.
So, I'll no longer make value judgments. Let's just say there are
three "domains" -- one thinks these mp3 podcasts are 53:00 in length,
another says they're 53:15, and a third says the sample rate is
44,100 Hz.
Domain 1: iTunes, QT Player -- length is 53:00, sample rate is 44,100
Domain 2: RB MoviePlayer -- length is 53:15, rate is unknown
Domain 3: OS QT Library calls -- sample rate is 44,100
length is 53:15 but there are 15 seconds of zero samples at the end.
To use the Position or Duration of the MoviePlayer (in domain 2) to
access the audio samples in the MemoryBlock from Addey's routine
(domain 3), I need to know the sample rate in domain 2. That's the
missing number. Addey's routine says the sample rate is 44,100, but
either the RB Player isn't playing at that rate (and I cannot get the
sample rate directly from domain 2), or domain 3 is dropping every
213-th sample and replacing them with zeros at the end.
I need a formula to relate the domains. I've tried this and it
works: I'm already connecting with iTunes (domain 1) via AppleScript,
so I also ask it for the track's duration. Then this formula links
all three domains:
( iTunes duration / MoviePlayer.Duration ) * SampleRate = Rate
Domain 1 Domain 2 Domain 3 Domain 2
( 53:00 / 53:15 ) * 44,100 = 43,892
then
Sample_index = MoviePlayer.Position * Rate
Am I clever, or what? :-)
The reason I just don't use constants is because I might use this
application for other mp3 files, and I don't want to have to do it
empirically again.
The remaining mystery is why are the mp3 podcasts from Bruce Williams
different from all other mp3 files I've tested? They are causing
some sort of trouble because the three domains don't agree (like they
do for other mp3 files).
Jeff
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>