snd_add(var handle, var offset, void* Sample, var length)

Adds a new sound sample into the buffer of a playing or looping sound. Can be used to stream own sound samples through the engine's sound player, f.i. for a VoIP implementation. A7.82  LC 


handle - target sound handle that was returned by the play function.
offset - start address for writing into the target sound buffer, in bytes.
Sample - pointer to the source sample buffer; must have the same format and frequency as the target sound.
length - size of the source sample in bytes. offset+length can go beyond the end of the target sound buffer; in this case the sample is "wrapped around" to the beginning of the target buffer.




Example (lite-C):

#include <acknex.h>
#include <default.c>
#include <d3d9.h>
function main() { while (!key_space) wait(1); // wait until key pressed SOUND* sine_snd = snd_create("#4"); // 4 seconds sine wave SOUND* whamm_snd = snd_create("bumm.ogg"); // test sound (16 bits PCM 44.1 kHz sample rate) // retrieve buffer and length from the test sound DSBUFFERDESC *dsBufferDesc; byte** pSampleBuffer; snd_buffer(whamm_smd,(void**)&dsBufferDesc,(void***)&pSampleBuffer); var length = dsBufferDesc->dwBufferBytes; var h = snd_loop(sine_snd,100,0); // add the test sound twice into the playing sine wave buffer snd_add(h,0,*pSampleBuffer,length); snd_add(h,length,*pSampleBuffer,length); }

See also:

SOUND, snd_create, snd_buffer, snd_play, snd_playing

► latest version online