Chunksize

What, exactly, does “chunksize” mean? (It’s the last argument to
Mix_OpenAudio)

None of the header or C or README files that I see actually explain it.

So far as I can tell, it’s something to do with an internal buffer used by
the mixer. Changing the value can supposedly produce better output.

Thanks!

-bill!
(trying to finish up part one of his SDL talk for his LUG! D’oh! 2 hrs left!)

What, exactly, does “chunksize” mean? (It’s the last argument to
Mix_OpenAudio)

None of the header or C or README files that I see actually explain it.

So far as I can tell, it’s something to do with an internal buffer used by
the mixer. Changing the value can supposedly produce better output.

It is the size of the internal buffer used by SDL for audio - it is
the amount of data that is written to the soundcard at once.

-Sam Lantinga				(slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec

Choosing the right chunksize is a difficult task if you want
both samples and background music - as the docs explain you
either get long reponse times for samples (if the buffer is
too big) or music underflow (if it’s too small).

An good solutoon is to use a smaller buffer if you can manage
to run the sound thread/process at higher priority than the X
server, but of course that needs root privileges…

Another idea I had is to use a larger internal buffer for the
music so that the music mixer could mix one or two chunksizes
ahead. I’m not sure if this really would help avoiding underflows,
but after having a closer look at the SDL mixer sources I decided
to better not touch the mixer buffer code… :wink:

BTW, I get no sound at all if I set the chunksize >= 16384
(at 22 kHZ, 16 bit).

Markus

P.S. I have made some smaller enhancments to the SDL mixer when
writing the pysol-sound-server (using mikmod 3.1.8, MOD
rewinding, etc).On 22-Dec-1999 Sam Lantinga wrote:

What, exactly, does “chunksize” mean? (It’s the last argument to
Mix_OpenAudio)

None of the header or C or README files that I see actually explain it.

So far as I can tell, it’s something to do with an internal buffer used by
the mixer. Changing the value can supposedly produce better output.

It is the size of the internal buffer used by SDL for audio - it is
the amount of data that is written to the soundcard at once.

  -Sam Lantinga                           (slouken at devolution.com)

Lead Programmer, Loki Entertainment Software

“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec

---- Markus F.X.J. Oberhumer <@Markus_F.X.J_Oberhum> ----
---- http://wildsau.idv.uni-linz.ac.at/mfx/ ----
---- 5E CB 5C 85 DE AF 9E BF E9 DA 7E 6A 39 F8 CC 67 ----

                         3 WARPS TO URANUS

P.S. I have made some smaller enhancments to the SDL mixer when
writing the pysol-sound-server (using mikmod 3.1.8, MOD
rewinding, etc).

Can you send them to me so I can include them in the next release
of the mixer?

Thanks!
-Sam Lantinga (slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec

It is the size of the internal buffer used by SDL for audio - it is
the amount of data that is written to the soundcard at once.

Thanks. :slight_smile: (BTW - I did a talk on SDL tonight at LUGOD, showing how insanely
easy it is to use… Besides the vacation-related low turnout, it went
pretty well! :slight_smile: )

-bill!

[Charset iso-8859-1 unsupported, filtering to ASCII…]

Choosing the right chunksize is a difficult task if you want

Thanks for the info. I have no problem with 512 chunksize (just copied
the value from aliens demo) on my Celeron 300 at 450Mhz. I cross compiled
one of my games for Windows and ran it on a Pentium I at 133Mhz, and also
had no problem…

However, one friend (who, albiet, was ditzing around with the source and
turning off optimizations and turning on debugging) ran it on his Pentium II
at 233Mhz laptop, and everything (audio and video) was jerky.

(HOWEVER :), tonight I tried the same game on a DIFFERENT PII-233 and it
was fine :slight_smile: )

-bill!

> 3 WARPS TO URANUS

Hehe :slight_smile: I like your .sig. (Too me a sec. to remember WHAT game it was :slight_smile: )

Normaly (i.e. I haven’t even checked SDL-sound) the chunksize affects how
big a buffer is mixed/played at a time. Changing/selecting/starting chunks
takes time, and therefore big chunks generaly are faster than smaller
chunks. But they also have a higher latency, which means you need to know
some time ahead what you will want to play. If the chunksize is, say, 4410
samples big it plays for 1/10 second (assuming 44KHz). This time is always
played out, and the data cannot be changed while playing this chunk. If the
game wants to do a spontaneous sound-effect, then that will have to wait for
the next chunk, which can last 1/10 second (*2 for hardware-doublebuffered
chunks or something). If the chunks get too big the sound will be obviously
out of sync. Well, now there are realy two possibilities, either audio laggs
because of the big buffer-latency, in which case smaller chunks might help,
or it laggs because the machine can’t switch buffers fast enough, and bigger
chunks would help. First case would sound delayed, while the second case
would sound jumpy, broken or cut off, as chunks are dropped.
At least that’s what I believe to know, so please someone correct me if I’m
wrong or SDL works differently.

All the best,
robOn Sun, Jan 23, 2000 at 11:20:10PM -0800, William Kendrick wrote:

Speaking of mixer & win32… I’m still confused by this whole "chunksize."
Thing.

On my box (Celeron @ 450Mhz running Linux), audio sounds great.
On a friend’s box (Pentium @ 133Mhz running Windows95), audio is lagged.

I’m using a chunksize of 512. Should I decrease it? What does changing
the number actually do? What are the pros/cons of smaller numbers.
The pros/cons of larger numbers?