snd_create(STRING* filename): SOUND*
snd_createoal(STRING* filename): SOUND* C A8.22
Creates a DirectSound resp. OpenAL sound object. Objects created this way are automatically deleted on closing the engine, or by calling the ptr_remove function.
snd_createstream(STRING* filename): SOUND* C A8.22
Creates an OpenAL sound object for stream playing from an .ogg sound file.
Parameters:
filename - .ogg or .wav sound file name, or "#nnn" for a 440 Hz sine wave sound of nnn seconds duration (char* or STRING*).
Returns:
SOUND* pointer, or NULL if the sound could not be created.
Speed:
Slow
Remarks about OpenAL sounds:
- OpenAL sound objects can be played with the normal snd_ functions, but support additional features such as environment effects, sound cones, and stream playing. For creating and playing OpenAL sounds, the ackoal.dll is used and the ackoal.h header file must be included.The OpenAL interface was implemented by
Matthias Auer.
- OpenAL SOUND structs have a different format than DirectPlay SOUND structs. They are defined as ASOUND in the ackoal.h header. The snd_ functions automatically detect whether SOUND pointers or handles belong to an OpenAL or DirectSound struct.
- OpenAL sound files must be either directly located in the work folder, or the path must be given with the file name, f.i. snd_createoal("media\\hit.ogg");.. They can not be directly played from inside a .wrs resource, but must be extracted before. Only .ogg files can be stream played.
- For playing OpenAL sounds, OpenAL must be installed on the target system. It's automatically installed with Gamestudio; for installing it on other PCs, the redistributable OpenAL installer (oalinst.exe) and license is included in the external folder. Run oalinst.exe -s for installation in silent mode. The license permits you to freely integrate OpenAl in your applications.
Remarks:
-
Sine wave sounds created with "#nnn" are sampled in 16 bit with 44.1 kHz sample rate. They don't require a sound file and can be used as sound buffers for further manipulation with the snd_tune, snd_add, or snd_buffer functions.
Example (lite-C):
SOUND* oggsound = snd_create("test.ogg");
// play the sound
var ogghandle = snd_play(oggsound,100,50);
// wait until finished
while(snd_playing(ogghandle)) { wait(1); }
// remove the sound
ptr_remove(oggsound);
See also:
SOUND, snd_buffer, ptr_remove
► latest version online