This page has been translated automatically.
Programming
Fundamentials
Setting Up Development Environment
UnigineScript
High-Level Systems
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Bounds-Related Classes
Containers
Controls-Related Classes
Core Library
Engine-Related Classes
GUI-Related Classes
Node-Related Classes
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
Rendering-Related Classes
Utility Classes
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

SoundSource Class

This class is used to create directional sound sources. The source's sound fades out linearly in a specified range (see getMinDistance() and getMaxDistance()). If inner and outer sound cones are defined, they will also have their share in the attenuation factor (see the getConeInnerAngle() and getConeOuterAngle() functions).

Sound sources are automatically handled by the sound manger. When the sound source is within the audible range, it is loaded into the memory (a full sample or its chunk, depending on whether the source is static or streamed). When it gets outside the audible range, the sound file is automatically deleted from the memory. Static sound sources are instanced; streamed ones are not.
If you still want to manage a sound source manually, you can check if it has stopped playing and after that delete it.

There is also no limitation on the number of sound sources in the world, as only currently audible ones are rendered. In the worst case scenario, when the number of simultaneously heard sound sources exceeds the hardware capabilities, some of them will not played.

SoundSource Class

Members


SoundSource (const char * name, int stream = 0)

Constructor. Creates a new world sound source using a given sound sample file.

Arguments

  • const char * name - Path to the sound sample file.
  • int stream - Positive value to create a streaming source, 0 to create a static source. If the flag is set, the sample will not be fully loaded into memory. Instead, its successive parts will be read one by one into a memory buffer.

float getLength ()

Returns the total length of the sound sample.

Return value

Length of the sample in seconds.

void setAirAbsorption (float absorption)

Updates the air absorption value for the sound source that determines the distance-dependent attenuation of the reverberation sound at high frequencies caused by the propagation medium.

Arguments

  • float absorption - Air absorption value in range [0.0;10.0].

int getLoop ()

Returns a value indicating if the sample is looped.

Return value

Positive number if the sample is currently looped; otherwise, 0.

int getSourceMask ()

Returns a bit mask that determines to what sound channels the source belongs to. For a sound source to be heard, its mask should match at least with the player's sound mask in at least one bit.

Return value

Integer, each bit of which specifies a sound channel.

void setReverbMask (int mask)

Updates the bit mask that determines what reverberation zones can be heard. For sound to reverberate, at least one bit of this mask should match with the player's reverberation mask. At the same time, reverb mask of the reverberation zone should also match with the player's one (but not necessarily in the same bit as this mask matches it).

Arguments

  • int mask - Integer, each bit of which is a mask for reverberating sound sources.

float getAirAbsorption ()

Returns the current air absorption value for the sound source that determines the distance-dependent attenuation of the reverberation sound at high frequencies caused by the propagation medium.

Return value

Air absorption value.

void setConeInnerAngle (float angle)

Updates an angle of the inner sound cone. Sound volume in the inner cone does not change. 360 degrees represents an omnidirectional sound source.

Arguments

  • float angle - Cone inner angle in degrees.

void setGain (float gain)

Updates the gain controlling the sound intensity. Setting the value to 0.0 mutes the sound source.

Arguments

  • float gain - Gain value in range [0.0;1.0].

void play ()

Starts playing the sample.

float getMaxDistance ()

Returns a distance, at which the sound completely fades out, in units.

Return value

Distance in units.

float getConeOuterGainHF ()

Returns the current gain filter value for the sound source that attenuates the reverberation sound at high frequencies outside the oriented cone.

Return value

High-frequency reverberation gain value.

float getGain ()

Returns the current gain controlling the sound intensity. Is set to 0, the sound source is muted.

Return value

Gain value.

const char * getSampleName ()

Returns the sound sample file of the sound source.

Return value

Path to the sound sample file.

void setSampleName (const char * name)

Reloads the internal sound source.

Arguments

  • const char * name - Path to the sound sample file.

int getOcclusion ()

Returns a value indicating if sound source should be muffled when being occluded.

Return value

Positive number if the sound is muffled by occlusion; otherwise, 0.

float getConeInnerAngle ()

Returns the current angle of the inner sound cone. Sound volume in the inner cone does not change.

Return value

Cone inner angle in degrees.

float getConeOuterAngle ()

Returns the current angle of the outer sound cone. When moving to the edge of the outer cone, sound volume is fading up to the outside the cone gain value.

Return value

Cone outer angle in degrees.

void stop ()

Stops playback. This function saves the playback position so that playing of the file can be resumed from the same point.

void setLoop (int loop)

Updates a value indicating if the sample should be looped.

Arguments

  • int loop - Positive number to loop the sample, 0 to play it only once.

void setPitch (float pitch)

Updates a sound pitch.

Arguments

  • float pitch - Factor, by which the current pitch will be multiplied in range [0.1;10.0].

void setSourceMask (int mask)

Updates a bit mask that determines to what sound channels the source belongs to. For a sound source to be heard, its mask should match with the player's sound mask in at least one bit.

Arguments

  • int mask - Integer, each bit of which specifies a sound channel.

float getMinDistance ()

Returns a distance, at which the sound starts to fade, in units.

Return value

Distance in units.

void setConeOuterGain (float gain)

Updates the gain controlling the sound intensity outside the oriented cone defined by the outer angle.

Arguments

  • float gain - Cone outer gain in range [0.0;1.0].

int isPlaying ()

Returns a value indicating if the sample is currently being played.

Return value

1 if the sample is being played; otherwise, 0.

float getConeOuterGain ()

Returns the current gain controlling the sound intensity outside the oriented cone defined by the outer angle.

Return value

Cone outer gain.

void setTime (float time)

Updates time, from which the sample should be played.
Notice
This function is ineffective if the sample is already playing. At first it is necessary to stop the playback, set the time, and then resume the playback.

Arguments

  • float time - Time in seconds.

int isStopped ()

Returns a value indicating if playback is currently stopped.

Return value

1 if the sample is stopped; otherwise, 0.

void setConeOuterAngle (float angle)

Updates an angle of the outer sound cone. When moving to the edge of the outer cone, sound volume is fading up to the gain value outside the oriented cone.

Arguments

  • float angle - Cone outer angle in degrees.

void setConeOuterGainHF (float coneoutergainhf)

Updates the gain filter value for the sound source that attenuates the reverberation sound at high frequencies outside the oriented cone.

Arguments

  • float coneoutergainhf - High-frequency reverberation gain value in range [0.0;1.0].

float getTime ()

Returns the current time, at which the sample is being played.

Return value

Time in seconds.

void setMinDistance (float distance)

Updates a distance, at which the sound starts to fade, in units.

Arguments

  • float distance - Distance in units.

void setRoomRolloff (float rolloff)

Updates the scaling room rolloff factor for the sound source that determines attenuation of the reverberation sound over distance.

Arguments

  • float rolloff - Room rolloff factor in range [0.0; 10.0].

float getRoomRolloff ()

Returns the current scaling room rolloff factor for the sound source that determines attenuation of the reverberation sound over distance.

Return value

Room rolloff factor.

int getReverbMask ()

Returns the current bit mask that determines what reverberation zones can be heard. For sound to reverberate, at least one bit of this mask should match with the player's reverberation mask. At the same time, reverb mask of the reverberation zone should also match with the player's one (but not necessarily in the same bit as this mask matches it).

Return value

Integer, each bit of which is a mask for reverberating sound sources.

void setMaxDistance (float distance)

Updates a distance, at which the sound completely fades out, in units.

Arguments

  • float distance - Distance in units.

void setOcclusion (int occlusion)

Updates a value indicating if the sound source should be muffled when being occluded.

Arguments

  • int occlusion - Positive number if the sound should be muffled by occlusion; otherwise, 0.

float getPitch ()

Returns the current sound pitch.

Return value

Factor, by which the pitch is multiplied.
Last update: 2017-07-03
Build: ()