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. A7.80  LC 

Parameters:

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.

Speed:

Fast

Remarks:

Example (C++ or lite-C):

DSBUFFERDESC *dsBufferDesc; // from DirectSound 8
byte** pSampleBuffer;
SOUND* oldsound = snd_create("#20"); // create a 20 seconds dummy sound
snd_buffer(oldsound,&dsBufferDesc,&pSampleBuffer);
// remove original sample
if (pSampleBuffer && *pSampleBuffer) sys_free(*pSampleBuffer);
// create and copy a new sample
byte* myNewSampleBuffer = (byte*)sys_malloc(myNewBufferLength);
memcpy(myNewSampleBuffer,mySoundData,myNewBufferLength);
// replace with new sample
*pSampleBuffer = myNewSampleBuffer;
dsBufferDesc->dwBufferBytes = myNewBufferLength;
memcpy(dsBufferDesc->lpwfxFormat,myNewWaveFormat,sizeof(WAVEFORMATEX));

See also:

SOUND, snd_create, snd_add

► latest version online