This class provides a convenient way of managing sounds in an environment, with 1 to 3 dimensions. The sound_pool_item class holds all the information necessary for one single sound in the game world. Note that you should not make instances of the sound_pool_item class directly but always use the methods and properties provided in the sound_pool class.
sound_pool(int default_item_size = 100);
destroy all sounds.
void sound_pool::destroy_all();
Destroy a sound.
bool sound_pool::destroy_sound(int slot);
bool: true if the sound is removed successfully, false otherwise.
Pauses all sounds.
void sound_pool::pause_all();
Pauses the sound.
bool sound_pool::pause_sound(int slot);
bool: true if the sound was paused, false otherwise.
Play a sound in 1 dimension and return a slot.
int sound_pool::play_1d(string filename, pack@ packfile, float listener_x, float sound_x, bool looping, bool persistent = false);
int: the index of the sound which can be modified later, or -1 if error. This method may return -2 if the sound is out of earshot.
If the looping parameter is set to true and the sound object is inactive, the sound is still considered to be active as this just means that we are currently out of earshot. A non-looping sound that has finished playing is considered to be dead, and will be cleaned up if it is not set to be persistent.
Play a sound in 2 dimensions and return a slot.
int sound_pool::play_2d(string filename, pack@ packfile, float listener_x, float listener_y, float sound_x, float sound_y, bool looping, bool persistent = false);int sound_pool::play_2d(string filename, pack@ packfile, float listener_x, float listener_y, float sound_x, float sound_y, double rotation, bool looping, bool persistent = false);int sound_pool::play_2d(string filename, float listener_x, float listener_y, float sound_x, float sound_y, bool looping, bool persistent = false);int sound_pool::play_2d(string filename, float listener_x, float listener_y, float sound_x, float sound_y, double rotation, bool looping, bool persistent = false);int: the index of the sound which can be modified later, or -1 if error. This method may return -2 if the sound is out of earshot.
If the looping parameter is set to true and the sound object is inactive, the sound is still considered to be active as this just means that we are currently out of earshot. A non-looping sound that has finished playing is considered to be dead, and will be cleaned up if it is not set to be persistent.
Play a sound in 3 dimensions and return a slot.
int sound_pool::play_3d(string filename, pack@ packfile, float listener_x, float listener_y, float listener_z, float sound_x, float sound_y, float sound_z, double rotation, bool looping, bool persistent = false);int sound_pool::play_3d(string filename, pack@ packfile, vector listener, vector sound_coordinate, double rotation, bool looping, bool persistent = false);int: the index of the sound which can be modified later, or -1 if error. This method may return -2 if the sound is out of earshot.
If the looping parameter is set to true and the sound object is inactive, the sound is still considered to be active as this just means that we are currently out of earshot. A non-looping sound that has finished playing is considered to be dead, and will be cleaned up if it is not set to be persistent.
Play a sound and return a slot. This method has many parameters that can be customized.
int sound_pool::play_extended(int dimension, string filename, pack@ packfile, float listener_x, float listener_y, float listener_z, float sound_x, float sound_y, float sound_z, double rotation, int left_range, int right_range, int backward_range, int forward_range, int lower_range, int upper_range, bool looping, double offset, float start_pan, float start_volume, float start_pitch, bool persistent = false, mixer@ mix = null, string[]@ fx = null, bool start_playing = true, double theta = 0);
calculate_theta function in rotation.nvgt include.int: the index of the sound which can be modified later, or -1 if error. This method may return -2 if the sound is out of earshot.
If the looping parameter is set to true and the sound object is inactive, the sound is still considered to be active as this just means that we are currently out of earshot. A non-looping sound that has finished playing is considered to be dead, and will be cleaned up if it is not set to be persistent.
Play a stationary sound and return a slot.
int sound_pool::play_stationary(string filename, bool looping, bool persistent = false);int sound_pool::play_stationary(string filename, pack@ packfile, bool looping, bool persistent = false);int: the index of the sound which can be modified later, or -1 if error. This method may return -2 if the sound is out of earshot.
If the looping parameter is set to true and the sound object is inactive, the sound is still considered to be active as this just means that we are currently out of earshot. A non-looping sound that has finished playing is considered to be dead, and will be cleaned up if it is not set to be persistent.
This method will play the sound in stationary mode. This means that sounds played by this method have no movement updates as if they are stationary, and coordinate update functions will not work.
Resumes all sounds.
void sound_pool::resume_all();
Resumes the sound.
bool sound_pool::resume_sound(int slot);
bool: true if the sound was resumed, false otherwise.
Determine whether the sound is active.
bool sound_pool::sound_is_active(int slot);
bool: true if the sound is active, false otherwise.
If the looping parameter is set to true and the sound object is inactive, the sound is still considered to be active as this just means that we are currently out of earshot. A non-looping sound that has finished playing is considered to be dead, and will be cleaned up.
Determine whether the sound is playing.
bool sound_pool::sound_is_playing(int slot);
bool: true if the sound is playing, false otherwise.
Updates the listener coordinate in 1 dimension.
void sound_pool::update_listener_1d(float listener_x);
Updates the listener coordinate in 2 dimensions.
void sound_pool::update_listener_2d(float listener_x, float listener_y, double rotation = 0.0);
Updates the listener coordinate in 3 dimensions.
void sound_pool::update_listener_3d(float listener_x, float listener_y, float listener_z, double rotation = 0.0, bool refresh_y_is_elevation = true);void sound_pool::update_listener_3d(vector listener, double rotation = 0.0, bool refresh_y_is_elevation = true);y_is_elevation property should refresh from the sound_pool_default_y_is_elevation global property.y_is_elevation property should refresh from the sound_pool_default_y_is_elevation global property.Updates the sound coordinate in 1 dimensions.
bool sound_pool::update_sound_1d(int slot, int x);
bool: true if the sound is updated successfully, false otherwise.
Updates the sound coordinate in 2 dimensions.
bool sound_pool::update_sound_2d(int slot, int x, int y);
bool: true if the sound is updated successfully, false otherwise.
Updates the sound coordinate in 3 dimensions.
bool sound_pool::update_sound_3d(int slot, int x, int y, int z);bool sound_pool::update_sound_3d(int slot, vector coordinate);bool: true if the sound is updated successfully, false otherwise.
Updates the sound range in 1 dimensions.
bool sound_pool::update_sound_range_1d(int slot, int left_range, int right_range);
bool: true if the sound is updated successfully, false otherwise.
Updates the sound range in 2 dimensions.
bool sound_pool::update_sound_range_2d(int slot, int left_range, int right_range, int backward_range, int forward_range);
bool: true if the sound is updated successfully, false otherwise.
Updates the sound range in 3 dimensions.
bool sound_pool::update_sound_range_3d(int slot, int left_range, int right_range, int backward_range, int forward_range, int lower_range, int upper_range, bool update_sound = true);
bool: true if the sound is updated successfully, false otherwise.
Updates the sound start properties.
bool sound_pool::update_sound_start_values(int slot, float start_pan, float start_volume, float start_pitch);
bool: true if the sound is updated successfully, false otherwise.
The pitch step size to decrease when the sound is behind. Default is 0.25.
float sound_pool::behind_pitch_decrease;
The maximum distance that the sounds can be heard. Default is 0 (disabled).
int sound_pool::max_distance;
The pan step size, the sound's final pan or position in HRTF is calculated by multiplying the player's distance from the sound by this value. Default is 1.0.
float sound_pool::pan_step;
The volume step size, the sound's final volume is subtracted by this number multiplied by the player's distance from the sound. Default is 1.0.
float sound_pool::volume_step;
Toggles whether the Y coordinate is the same as Z, or in otherwords whether the y coordinate determines up/down or forward/backwards in your game world. By default, it retrieves from the sound_pool_default_y_elevation global property.
bool sound_pool::y_is_elevation = sound_pool_default_y_elevation;