I work with the FSOUND_DSP_MixBuffers Function a lot at moment.
But now there are problems and I need to have more
details on how this function work.

I’d like to copy a part of a soundsample into a buffer.
The buffer-size is 8820 bytes.
I use the standard output-rate of 44100Hz (sound-samples are 44100Hz, too).
MixBuffers works only with samples, so I get them from 8820/4=2205.
The mix-frequency is 44100;

So I call …MixBuffers(dest,src,2205,44100,FSOUND_STEREOPAN,FSOUND_16BITS|FSOUND_STEREO);

In 16Bit and Stereo the sample-data should look like this part:

“…Left Byte1, Left Byte2, Right Byte1, Right Byte2…”

So, one sample has 2 bytes and we have stereo, thats are 4 bytes for each piece.

I think, Mixbuffers normaly mix in 4 byte sized steps.
But 2205 cannot divide by 4, so MixBuffers can only mix 2204 Samples in this way.
And what’s about the 2 Bytes (one sample channel left) at last?
There are no more bytes for the right-channel, so how does
MixBuffers mix these 2 last bytes?
Maybe, Mixbuffers internal add 2 dummy bytes to final the mix or what?
I ask this, because I need to exactly paste the following 8820 Bytes
behind the last one.

And what happens, when I’d like to take a mix-frequency of 22050 ?
I know, now I need a bigger destination-buffer to get all the 2205 Samples in,
but I like to have the same 8820 Byte destination-buffer and only
use the half of the samples size to copy…

This should look like this: (2205/2, because of 22050Hz and same dest-size)


But here you see my biggest problem: the half size of the samples are 1102.5, so
Mix-Buffers will only take the integer 1102… it works, but it is not accurate, when
I like to paste (like called above) the next 8820 bytes at this position,
so I get crack&pop noises from time to time.

Can anyone help me about my two questions?
The fmod-documentation does not go in these interesting details.

Greetings and sorry for poor english,

  • You must to post comments

hi brett!

  1. Now I have made some tests: MixBuffers mixes all 2205 (not only 2204) Samples in 4Byte-Mode… so the last 2 Bytes will also be mixed
    (it’s only one of the stereo-channels).
    And with the next buffer-filling MixBuffers will correctly begin with
    the other channel first.

So, in 44100 Hz mix-frequency all my manual buffer-routine really works.

2. With other mix-frequencys as parameter for MixBuffers, I don’t know
the result of the function, also when I use the math-simple half freq. of

Source-Buffers and destinations buffers are always the same format.

Yes, I use 2 buffer-sizes… 2x50ms… When one get filled, the other is playing.
But MixBuffers seems to be the only solution for me, I don’t have the time to write my own mixer, resample, etc. routines in ASM.
Memcpy will not mix my samples when I use multiple samples.


  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.