snd_buffer(SOUND* snd, void** pDesc, void*** ppSample)
Reads, modifies, or replaces a sound buffer at runtime. Can be used to play own sound samples through the engine's sound player.
pDesc - Pointer that is set to the sound's DSBUFFERDESC pointer. Can be used to read and modify the DSBUFFERDESC struct.
ppSample - Pointer that is set to the address of the sound's sample buffer pointer. Can be used to read, modify, or free and replace the sample buffer.
- The DSBUFFERDESC struct is defined in include\d3d9.h,
and can be used to retrieve the sound length and sample frequency.
- For freeing the old and allocating a new sample buffer, the sys_free and sys_malloc functions must be used.
- Sample buffers can only be changed or copied into before the sound is played the first time. Afterwards it can't be modified anymore
by directly accessing the buffer. For changing a sound while it's playing, use snd_add.
Example (C++ or lite-C):
DSBUFFERDESC *dsBufferDesc; // from DirectSound 8
SOUND* oldsound = snd_create("#20"); // create a 20 seconds dummy sound
// remove original sample
if (pSampleBuffer && *pSampleBuffer) sys_free(*pSampleBuffer);
// create and copy a new sample
byte* myNewSampleBuffer = (byte*)sys_malloc(myNewBufferLength);
// replace with new sample
*pSampleBuffer = myNewSampleBuffer;
dsBufferDesc->dwBufferBytes = myNewBufferLength;