[Scummvm-devel] Unifiying MP3/Vorbis playback code some more

Torbjorn.E.Andersson at tietoenator.com Torbjorn.E.Andersson at tietoenator.com
Thu Dec 4 23:35:00 CET 2003


The way Broken Sword II handles sound currently, it probably needs the
ability to decode a compressed sound, either in its entirety or just a
part of it, to a separate buffer for playback later. Here's how it
works now:

Sound Effects
-------------

Sound effects seem to be embedded into the cluster files along with
other resources, e.g. sounds for the Paris section would be in
paris.clu. Compressing these is probably more trouble than it's worth,
so I'm not going to worry about them.

Speech
------

All speech, including that for the animated cutscenes, is stored in
speech.clu (one on each CD, so ScummVM allows you to name them
speech1.clu and speech2.clu). Speech for the cutscenes is decoded in
advance, presumably to interfer as little as possible with the
decoding of the movie. To avoid code duplication, I've changed the
normal speech to be handled the same way, except the decoded buffer is
played immediately.

I don't know if this decoding in advance thing is necessary, but I'm
guessing it might be. At least if you're playing the game from CD.

Music
-----

Music is stored, in the same format as the speech, in music.clu (one
on each CD; can be renamed music1.clu and music2.clu). The only
difference is that there are fewer sounds in each file.

The music is handled by a "premix" process, which means it can't rely
on the mixer to resample the music from 22 kHz to whatever the backend
wants. I still don't know whether or not this is a good idea, but the
method we used before this - a timer adding chunks of decoded data to
a stream channel - wasn't working too well enough because there were
frequent "pops" in the music. My guess was that timers aren't exact
enough, so that's why I rewrote it the way I did.



I'm not religiously attached to this code in any way, so if anyone
wants to rewrite it, go right ahead! I didn't expect to do any of the
sound code for Broken Sword II anyway. I just wanted to get it to the
point where it would draw most of the graphics, and then sit back and
wait for someone else to take over. So far, my plan has been an almost
complete failure. :-)

I've submitted a program - untested, obviously - for compressing the
speech / music to the patch tracker if anyone wants to experiment with
it. It's certainly something that seems worth doing because here are
the results of my test run (using default compression parameters)

        | Original    MP3        Ogg Vorbis
--------+------------------------------------
music1  | 141M        38M        35M
music2  | 141M        38M        35M
speech1 | 169M        51M        55M
speech2 | 201M        65M        65M

At least assuming I didn't do something silly like accidentally
throwing away 60% of the data.

Torbjörn

-- 
TietoEnator Resource Management AB
Persona
Torbjörn Andersson
http://www.rm.tietoenator.com/
 




More information about the Scummvm-devel mailing list