At 05:23 PM 9/25/01 -0700, you wrote:>More newbie questions, please bear with me =)
>
>I've got my high level code pretty well structured, and I'm now
trying
>to decode vorbis streams on the fly using the ov_open_callbacks()
>routines. I can't seem to figure out how to tell it what output format
>I want -- is this possible? For example, I would like to be able to
>specify number of channels output (e.g. stereo vs. sum-to-mono vs.
>reversed stereo) and possibly the ideal output frequency (to match user
>configuration). Is this possible?
Libvorbis is just a straight decoding library - it won't do any
manipulations of the format of the actual audio itself. vorbisfile is
a higher-level API on top of libvorbis - for convenience, it formats
the decoded audio into the typical 8/16 bit interleaved channel formats
typical of PCM audio, but doesn't do more than that.
For extra processing (channel mixing, channel flipping, resampling, which
you mentioned, and other similar things), you'll have to do the processing
externally to libvorbis. I'll give you a short description of where to start
with that. (It's entirely possible you already have code for doing this
for the case where you just have a wav file, or something like that. In that
case, you might want to just use that on the output - not the most efficient
technique, but not too bad)
Libvorbis itself actually returns float ** from the core decode functions,
so you get the n-channels independently, and in the native internal format
(floating point). So, for processing into some other format, this is the
natural place to start. If you look at vorbisfile.c:ov_read(), you'll see
what is done for the current 8/16 bit interleaved PCM conversion. Since
you most likely want to keep using vorbisfile, my suggestion would be to
just add in calls to your conversion routines (or just throw them in there
for simple cases) in here, and just use a slightly customised vorbisfile.
Doing channel mixing, or reverse stereo (for example) from here is really
really simple. Resampling doesn't magically become easier, though ;)
The alternative to this is to write all the code you need using libvorbis,
rather than vorbisfile. This isn't as much work as it might seem, since
most of the complexity of vorbisfile is to deal with harder situations,
like seeking, which a game is unlikely to need (if you do, just use
vorbisfile). This gives you a lot more flexibility, but it is more work.
Feel free to ask more questions if any of this is unclear.
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.