Okay, so I thought about this over lunch, and I figured out a solution
to the problem of playing sound effects from positions other than the
beginning of the sample:
Mix_Chunk's look like this:
typedef struct {
int allocated;
Uint8 *abuf;
Uint32 alen;
Uint8 volume; /* Per-sample volume, 0-128 */
} Mix_Chunk;
So, all we need to do is create a new Mix_Chunk, and set a few values:
allocated=false;
volume=original->volume;
alen=original->alen - NumberOfSamplesWeAreSkipping; //Of course, taking
into account the bitrate.
abuf=&original->abuf[NumberOfSamplesWeAreSkipping];
After that, we just tell SDL_mixer to play our new Mix_Chunk, and then
immeadiately delete it (we don't need to wait for the sound effect to
finish, I believe).
There really should be a function in the API to allow for an easier way
to do this. Perhaps one of us should submit a patch to them?
And I'm fairly confident that the solution I proposed to the second
problem will work. If anybody wants to test it, go for it, but I'll be
testing it soon enough.
-Chris
(BTW, can you guys post to this list, or do I need to modify
permissions? Can somebody just post a test message?)
On Wed, 2002-08-14 at 07:32, Chris Nelson wrote:
SDL_mixer appears to lack some functionality that we need.
Specifically, we need to be able to start playing a sound effect at
places other than the beginning of the sound effect. This is
necessary in order to implement the rewind / fast-forward functions
in conversation, for voices.
Also, we need a function which will determine the length of a sound
effect (Mix_Chunk), in milliseconds. Mix_Chunk->alen tells us the
length in bytes, but we aren't given any direct way to determine the
sampling rate, or the bits per sample (or stereo vs mono). SDL_mixer
might convert each sound effect to the audio output format, when it
loads a wav... This would make sense. In this case, it would be easy
to use Mix_Chunk->alen to detemine a sound effect's length, in
conjunction with Mix_QuerySpec(). Can somebody please verify this,
or even write such a function?
This website has documentation for SDL_mixer:
http://jcatki.no-ip.org/SDL_mixer/SDL_mixer_frame.html
Thanks.
-Chris
|