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.
No language code for this page. You can select other language.
No language code for this page,
shown in other instead.
shown in other instead.
This class is used to create an ambient background sound that is non-directional.
For an ambient source to be played, a player is always required. In case an ambient source needs to be played when neither a world, nor the editor are loaded, a player should be created in the system script unigine.cpp; otherwise, no sound will be heard.
AmbientSource (string name, int stream = 0)Constructor. Creates a new ambient sound source using a given sound file.
- string name - Path to the sound file.
- int stream = 0 - 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 getGain ()Returns volume of the sound.
Return valueVolume. 0 means muted, 1 means maximum volume.
float getLength ()Returns the total length of the sound sample.
Return valueLength of the sample in seconds.
int getLoop ()Returns a value indicating if the sample is looped.
Return valuePositive number if the sample is looped; otherwise, 0.
float getPitch ()Returns a sound pitch.
Return valueFactor, by which the current pitch will be multiplied.
string getSampleName ()Returns the name of the sound file.
Return valuePath to the sound file.
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 valueInteger, each bit of which specifies a sound channel.
float getTime ()Returns the current time, at which the sample is being played.
Return valueTime in seconds.
int isPlaying ()Returns a value indicating if the sample is being played.
Return value1 if the sample is being played; otherwise, 0.
int isStopped ()Returns a value indicating if playback is stopped.
Return value1 if the sample is stopped; otherwise, 0.
void play ()Starts playing the sample.
void setGain (float gain)Sets volume of the sound.
- float gain - Volume. 0 means muted, 1 means maximum volume.
void setLoop (int mode)Sets a value indicating if the sample should be looped.
- int mode - Positive number to loop the sample, 0 to play it only once.
void setPitch (float pitch)Sets a sound pitch.
- float pitch - Factor, by which the current pitch will be multiplied.
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.
- int mask - Integer, each bit of which specifies a sound channel.
void setTime (float time)Sets time, from which the sample should be played.
- float time - Time in seconds.
void stop ()Stops playback. This function saves the playback position so that playing of the file can be resumed from the same point.
Last update: 2017-07-03
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)