[vorbis] problems loading an ogg to memory
Stan Seibert
volsung at mailsnare.net
Wed Sep 3 10:33:37 PDT 2003
On Wed, 2003-09-03 at 12:16, Joel Gonzales wrote:
> This seems to be where I'm stuck at currently. What function do I call
> to set the sample size?
>From the ov_read() documentation:
long ov_read(OggVorbis_File *vf, char *buffer, int length, int
bigendianp, int word, int sgned, int *bitstream);
[snip]
word
Specifies word size. Possible arguments are 1 for 8-bit
samples, or 2 or 16-bit samples. Typical value is 2.
So you actually don't make a specific function call to set the sample
size. You just pass the size you want with every ov_read() call.
> Just to make sure my math is correct:
> if we have 200 PCM samples, 1 channel and a rate of 44100, that would give
> 200*1*44100 = 8820000 (assuming a file that isn't chained)
>
> So I'd need an array of size 8820000? or is the number given in bits/bytes?
If your sound file is 200 PCM samples in length at a rate of 44100 with
only one channel, then the size of the array in bytes is 8820000*sample
size in bytes. For example, assume you are decoding a file to 16-bit
integers. You could declare the array to hold this in C in one of the
following two ways:
hort music[8820000]; /* Assumes shorts are 16 bit on your platform */
or
char music[17640000];
If you decode to 8-bit integers, you can do:
char music[8820000];
---
Stan Seibert
<p>--- >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