Re: Calibrating Buffer Size and Count

Kip Warner <[email protected]>
Newsgroups gmane.comp.lib.openal
Message-ID <[email protected]>
On Sun, 2010-05-30 at 01:05 -0700, Chris Robinson wrote: 
> On Saturday, May 29, 2010 9:28:34 pm Kip Warner wrote:
> > On Fri, 2010-05-28 at 13:29 -0700, Chris Robinson wrote:
> > > So, for instance, you would generate 4 to 8 buffers, and fill them each
> > > with frequency/4*channels*bits/8 bytes (where frequency, channels, and
> > > bits are taken from the stream data format that's given to OpenAL):
> > 
> > The 4 in the divisor, is that the number of buffers one chose to
> > generate?
> 
> It's actually how much of a second, per buffer, to fill (ie. 1/4th of a second 
> in each buffer; 2 would be half, and 8 would be 1/8th of a second, etc). With 
> a one-second long buffer queue, it's the same as the number of buffers to 
> generate.
> 
> > How do I determine the number of buffers to use for a stream? Do you
> > reckon to just hardcode it at, say, 8, and instead leave the size of the
> > buffers themselves as the parameter to fiddle with?
> 
> It's pretty arbitrary. Generally speaking, it's probably not a problem to 
> hard-code the buffer count (eg. 4 or 8 or so), as long as you make the buffer 
> size flexible depending on the stream format.
> 
> What I tend to do, when simplicity is called for, is hard-code the buffers to 
> 3 or 4, and specify a buffer size of 16384 sample frames (which is multiplied 
> by 2 or 4, depending on the decoded format, to get the byte size). This should 
> work fine as long as the stream doesn't use a really high sample rate (like 
> 96khz or more).

For audio effects, probably 48 KHz files will be used. For music, they
may end up being 96 KHz / 24-bit. Do you recommend having the sole
configurable aspect being the total length of the entire buffer queue
for a source? That way a user can select 500 ms, 1s, 2s, etc. for their
machine and it can automatically calculate the size of each buffer
required, given the number of hard coded buffers, bit rate, frequency,
channels, etc..

> > > int framesize = stream->channels * stream->bits / 8;
> > > BytesPerBuffer = stream->Freq / 4 * framesize;
> > 
> > The 4 again in the divisor is the number of buffers chosen for the
> > stream?
> 
> It's the same as above. How much of a second's worth of data to fill each 
> buffer.
> 
> > PS If you remember, please cc me so I get it faster than the batch mode
> > dispatches.
> 
> Sure. Sorry about that.

Very helpful and thank you. You're very knowledgeable and this is
helping greatly as I finish up the audio component of the engine design
for my game (https://www.avaneya.com). Actually, when the design is
done, it would be really helpful if you were able to take a moment and
look at just the AudioManager's UML.

-- 
Kip Warner -- Software Engineer
OpenPGP encrypted/signed mail preferred
http://www.thevertigo.com

_______________________________________________
Openal mailing list
[email protected]
http://opensource.creative.com/mailman/listinfo/openal
signature.asc (application/pgp-signature, 198 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEABECAAYFAkwCvvwACgkQLXnfK7bii22etgCffqMaE6IMMdfZ26NsmYM+nFfG
l4oAoLVrIM7RYWMExysdCAdfEjbgLHbO
=97h6
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.