[vorbis] Starting at square one with Vorbis...

Michael Smith msmith at labyrinth.net.au
Tue Aug 8 01:32:25 PDT 2000



At 02:55 PM 8/7/00 -0700, you wrote:
>I want to use Vorbis to stream music off the HD in my 
>DirectX app. Currently, we have a generic streamer that
>writes raw digital sound data into the primary sound 
>buffer. We plug sound sources (e.g. wav files, PCM files)
>into this streamer by having the sound sources have
>an interface something like this:
>
>   class SourceDataSourceInterface{
>      virtual   bool   Init(char* pSource) = 0;
>      virtual   bool   Shutdown() = 0;
>      virtual   bool   ReadFull(char** pDest, int* size) = 0;
>      virtual   int    ReadPart(char* pDest, int size) = 0;
>      virtual   void*  GetFormat() = 0;
>   };
>
>I want to write some code that can convert Vorbis file
>data to raw digital data that the DirectX sound driver can 
>use. As such, I want to write a version of the above 
>struct (well, the actual version has a little more than above)
>for Vorbis.
>
>Can somebody tell me where to start? I read what documentation
>there was at www.vorbis.com and I couldn't get very far with
>it, mostly because it is largely unfinished. 

There's sufficient documentation to do this, but it would be rather
difficult to figure out JUST from the documentation. I suggest you look at
the stuff in examples/, and the somewhat more complex stuff in various
other places (xmms/ winamp/ vorbis-tools/).

You want to use vorbisfile to do this (you can use the low-level libvorbis
interface, but that's rather difficult to use if you want to do more than
straight-through streaming (if you want to seek, for example)).

If using the stdio functions (fopen, fread, etc.) is acceptable as a
solution, this is pretty trivial. Basically, you call ov_open() in your
Init method, storing the OggVorbis_File struct somewhere useful inside your
object. Then ReadPart() would just call ov_read() inside a loop. ReadFull()
would be similar. GetFormat is easy - there's a bunch of vorbisfile
functions to do that. Shutdown() would just call ov_close(). 

If you don't want to use stdio (for whatever reason - maybe you're
buffering stuff seperately, or you want to use windows-specific functions
for file i/o) then you have to use ov_open_callbacks() instead of ov_open()
- the rest remains the same. 

winamp/vorbis.c includes a fairly comprehensive example of how to use this
interface to use win32 functions instead of stdio.

It's all pretty simple, but there are a couple of things that might trip
you up, so feel free to come back asking more specific questions.

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-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the Vorbis mailing list