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.
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.
- The current play address in the target buffer can be retrieved with the snd_playing function. This can be used to pause the target sound when it reaches the end of the buffer, and restart it when a new sound sample was added.
- The format or address of a sound sample buffer can be retrieved with the snd_buffer function.
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
var length = dsBufferDesc->dwBufferBytes;
var h = snd_loop(sine_snd,100,0);
// add the test sound twice into the playing sine wave buffer
SOUND, snd_create, snd_buffer, snd_play, snd_playing