|
#define SOUND_NO_LOOP 0
#define SOUND_LOOP_NORMAL 1
#define SOUND_PAUSED 1
#define SOUND_RESUME_PLAYING 0
const double SOUND_DISTANCE_DEFAULT=1;
#define SOUND_DISTANCE_DEFAULT 1.0
Load a sound file into the engine.
Parameters:
file_name:
file to load
entity:
A handle to a polygon or a group or an object
The entity parameter makes it very easy to create 3D sound that its volume is sensative
to the distance form the entity and the balance is automatically computed for each speaker according to the
location of the entity.
If entity handle is NULL then the sound is not attached
to any entity (polygon,object or group) and is treated as a background sound,
otherwise it is a 3D-sound positioned at the entity's location , volume and
balance are constantly changed according to the listener location.
Important: Make sure that if the sound is attached to an entity and the entity is deleted then
this could cause a fatal error. Make sure to stop a sound or dettach it before deleteing
the object it is associated with.
distance_reach
The third argument is the maximum distance reach of the sound, which can be SOUND_DISTANCE_DEFAULT,
or a distance reach that the user decides on. This argument will effect only if the entity handle
given is not NULL, meaning that the sound has a defined position.
Try giving different numbers and see the effect. for example: 300, 1000, 10000 etc ...
Examples:
A)
This will set the mp3 song as a background sound
DWORD madona=STATE_sound_load("madona\\like_a_virgin.mp3", NULL,SOUND_DISTANCE_DEFAULT);
STATE_sound_play(madona, SOUND_LOOP_NORMAL);
B)
When we will get closer or further away from the bird the engine will
automatically update the volume and the balance according to the camera relative
position towards the bird object.
DWORD bird_sound=STATE_sound_load("voices\\bird_sound.mp3", bird_object_handle,SOUND_DISTANCE_DEFAULT);
STATE_sound_play(bird_sound, SOUND_LOOP_NORMAL);
/With Wave files it is exactly the same, only with a wav sound file.
C)
This will set the Wave song as a background sound
Note that it is much better to use mp3 as a background sound since the files
are a lot smaller.
DWORD madona=STATE_sound_load("madona\\like_a_virgin.wav", NULL, SOUND_DISTANCE_DEFAULT);
STATE_sound_play(madona, SOUND_LOOP_NORMAL);
|