This page has been translated automatically.
UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Content Creation
Materials
Unigine Material Library
Tutorials
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.

Unigine::Sound Class

Unigine sound. This interface provides access to Unigine sound functions.

To use this class, include the UnigineSound.h file.

Unigine::Sound Class

Members


virtual ~Sound ()

Virtual destructor.

static Sound * get ()

Returns a pointer to the existing sound.

Return value

Pointer to the existing sound.

virtual void setEnabled (int enable) const =0

Enables or disables the sound.

Arguments

  • int enable - 1 to enable the sound, 0 to disable it.

virtual int isEnabled () const =0

Returns a value indicating if the sound is enabled.

Return value

Returns 1 if the sound is enabled; otherwise, 0.

virtual void setVolume (float volume) const =0

Sets the sound volume in range [0;1]. The default is 1 that means maximum volume.

Arguments

  • float volume - Sound volume. 0 means muted sound, 1 means maximum volume.

virtual float getVolume () const =0

Returns the current sound volume.

Return value

Sound volume. 0 means muted sound, 1 means maximum volume.

virtual void setSourceVolume (int source, float volume) const =0

Sets the volume of the specified sound channel.

Arguments

  • int source - Number of the sound channel (from 0 to 31).
  • float volume - Channel volume. The provided value is saturated within [0;1] range, where 0 means muted sound and 1 is the maximum volume.

virtual float getSourceVolume (int source) const =0

Returns the current volume of the specified sound channel.

Arguments

  • int source - Number of the sound channel (from 0 to 31).

Return value

Volume of the specified sound channel. The returning value is in range [0;1], where 0 means muted sound and 1 is the maximum volume.

virtual void renderWorld (int force) const =0

Forces update of the sound system: all sound settings will be applied at once (such as play, stop events and change of parameters). A sound system has its own fixed frame rate (30 fps), while a script update rate can be much higher, which sometimes cause commands being skipped, unless a forced update is used.

Arguments

  • int force - 1 to force update of the sound system; otherwise, 0.

virtual int loadWorld (const XmlPtr & xml) const =0

Loads a sound state from the Xml. The sound state includes such settings as the volume, velocity, adaptation, Doppler factor, time scale and number of sound sources and their volumes.

Arguments

  • const XmlPtr & xml - Xml smart pointer.

Return value

Returns 1 if the the sound state is loaded successfully; otherwise, 0 is returned.

virtual int saveWorld (const XmlPtr & xml) const =0

Saves a sound state into the Xml. The sound state includes such settings as the volume, velocity, adaptation, Doppler factor, time scale and number of sound sources and their volumes.

Arguments

  • const XmlPtr & xml - Xml smart pointer.

Return value

Returns 1 if the sound state is saved successfully; otherwise, 0.

virtual int saveState (const StreamPtr & stream) const =0

Saves a sound state into the stream. The sound state includes such settings as the volume, velocity, adaptation, Doppler factor, time scale and number of sound sources and their volumes.

Arguments

  • const StreamPtr & stream - Stream smart pointer.

Return value

Returns 1 if the sound state is saved successfully; otherwise, 0.

virtual int restoreState (const StreamPtr & stream) const =0

Restores a sound state from the stream. The sound state includes such settings as the volume, velocity, adaptation, Doppler factor, time scale and number of sound sources and their volumes.

Arguments

  • const StreamPtr & stream - Stream smart pointer.

Return value

Returns 1 if the sound state is restored successfully; otherwise, 0 is returned.
Last update: 2017-07-03
Build: ()