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
Core Library
Containers
Engine Classes
Node-Related Classes
Rendering-Related Classes
Physics-Related Classes
Bounds-Related Classes
GUI-Related Classes
Controls-Related Classes
Pathfinding-Related Classes
Utility Classes
Внимание! Эта версия документация УСТАРЕЛА, поскольку относится к более ранней версии SDK! Пожалуйста, переключитесь на самую актуальную документацию для последней версии SDK.
Внимание! Эта версия документации описывает устаревшую версию SDK, которая больше не поддерживается! Пожалуйста, обновитесь до последней версии SDK.

AmbientSource Class

This class is used to create an ambient background sound that is non-directional.

Notice
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 Class

Members


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

Constructor. Creates a new ambient sound source using a given sound file.

Arguments

  • const char * name - Path to the sound 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.

int isStopped ()

Returns a value indicating if playback is stopped.

Return value

1 if the sample is stopped; otherwise, 0.

int getLoop ()

Returns a value indicating if the sample is looped.

Return value

Positive number if the sample is 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 stop ()

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

const char * getSampleName ()

Returns the name of the sound file.

Return value

Path to the sound file.

float getTime ()

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

Return value

Time in seconds.

void setPitch (float pitch)

Sets a sound pitch.

Arguments

  • 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.

Arguments

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

void setTime (float time)

Sets time, from which the sample should be played.

Arguments

  • float time - Time in seconds.

float getGain ()

Returns volume of the sound.

Return value

Volume. 0 means muted, 1 means maximum volume.

void setGain (float gain)

Sets volume of the sound.

Arguments

  • float gain - Volume. 0 means muted, 1 means maximum volume.

void setLoop (int loop)

Sets a value indicating if the sample should be looped.

Arguments

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

int isPlaying ()

Returns a value indicating if the sample is being played.

Return value

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

void play ()

Starts playing the sample.

void * getInterface ()

Return value

void setSampleName (const char * name)

Reloads the internal sound source.

Arguments

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

float getPitch ()

Returns a sound pitch.

Return value

Factor, by which the current pitch will be multiplied.
Last update: 03.07.2017
Build: ()