At 05:40 PM 7/23/01 +1200, you wrote:>Hello Developers
>
>I'm writing a playlist creator app for radio stations (in Delphi) which
>supports WAV & MP3 files & I would like to add OGG support. All I
need is
>the ability to read the length of the track from the file header. The
>documentation on the website is beyond me. I would rather not include a
>bulky library that does everything else. Does anyone have any Delphi code
>or can point in the right direction?
As with mp3, the length of the track isn't available just from the start of
the file. Examining the header is insufficient.
If you don't want to use libvorbis/libvorbisfile, then this isn't
trivial,
but it isn't that hard (though it gets moderately complex when you add
chaining support.). However, it's made much easier if you use libogg (this
is a very small library, not a bulky one).
Basically, you want to find the final page of each logical stream. For the
simple case of a non-chained stream, this just means finding the final page
in the file, which is pretty simple. From that, get the 'granulepos'
value.
That's the number of samples in the stream. You can then get the length by
dividing by the sample rate. Sample rate is given in the primary header
(the first packet) - libvorbis does this, but it's easy to find without
libvorbis. It's at offset 12 in the first packet, 4 bytes (little endian)
giving the sample rate. See vorbis/lib/info.c, around line 193, for the
code which reads this in libvorbis.
Michael
--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to
'vorbis-dev-request@xiph.org'
containing only the word 'unsubscribe' in the body. No subject is
needed.
Unsubscribe messages sent to the list will be ignored/filtered.