Re: [Plib-users] Toying with Ogg
Brought to you by:
sjbaker
|
From: Steve B. <sjb...@ai...> - 2001-06-29 05:18:41
|
Cameron Moore wrote:
> I'm playing around with Ogg Vorbis at the moment, and I'm stuck trying
> to figure out how to use it with plib. My first goal is to use
> slSample( Uchar *buff, int leng ) to play the stream.
Isn't that going to be a rather large file though?
> The problem for this newbie is that libvorbisfile converts the .ogg
> stream into a char[] buffer (PCM) but plib wants a Uchar* buffer. Is
> there a trick to converting between these datatypes?
Well, it depends on how Ogg translates that into a voltage.
If it's signed char, then probably +127 is the max positive, zero is
zero and -128 is max negative...as you'd expect.
SL is using 255 is max positive, 128 is zero volts and 0 is max negative,
so, looking at the bit patterns:
volts Ogg SL
+max 01111111 11111111
00111111 10111111
zero 00000000 10000000
11000000 01000000
-max 10000000 00000000
...so you just need to flip the topmost bit of each byte...
slByte = oggByte ^ 0x80 ;
Tadaaa!
But I think you really need to find a way for Ogg's output to continuously
churn out bytes and feed them into SL...that's *hard* to do...but 2.4 Megabytes
per minute of music is a heck of a lot of memory to burn.
----------------------------- Steve Baker -------------------------------
HomeMail : <sjb...@ai...> WorkMail: <sj...@li...>
HomePage : http://web2.airmail.net/sjbaker1
Projects : http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net
http://agtoys.sf.net http://prettypoly.sf.net
http://freeglut.sf.net http://toobular.sf.net
|