This page has been translated automatically.
Видеоуроки
Interface
Essentials
Advanced
Подсказки и советы
Основы
Программирование на C#
Рендеринг
Принципы работы
Свойства (properties)
Компонентная Система
Рендер
Физика
Редактор UnigineEditor
Обзор интерфейса
Работа с ассетами
Настройки и предпочтения
Работа с проектами
Настройка параметров узла
Setting Up Materials
Настройка свойств
Освещение
Landscape Tool
Sandworm
Использование инструментов редактора для конкретных задач
Extending Editor Functionality
Встроенные объекты
Ноды (Nodes)
Объекты (Objects)
Эффекты
Декали
Источники света
Geodetics
World Objects
Звуковые объекты
Объекты поиска пути
Players
Программирование
Основы
Настройка среды разработки
Примеры использования
UnigineScript
C++
C#
Унифицированный язык шейдеров UUSL
File Formats
Rebuilding the Engine Tools
GUI
Двойная точность координат
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
Работа с контентом
Оптимизация контента
Материалы
Art Samples
Tutorials
Внимание! Эта версия документация УСТАРЕЛА, поскольку относится к более ранней версии SDK! Пожалуйста, переключитесь на самую актуальную документацию для последней версии SDK.
Внимание! Эта версия документации описывает устаревшую версию SDK, которая больше не поддерживается! Пожалуйста, обновитесь до последней версии SDK.

Unigine::AmbientSource Class

Header: #include <UnigineSounds.h>
Read More

AmbientSource Class

Members


static AmbientSourcePtr create ( 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.

void setGain ( float gain ) #

Sets volume of the sound.

Arguments

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

float getGain ( ) const#

Returns volume of the sound.

Return value

Volume. 0 means muted, 1 means maximum volume.

float getLength ( ) const#

Returns the total length of the sound sample.

Return value

Length of the sample in seconds.

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 getLoop ( ) const#

Returns a value indicating if the sample is looped.

Return value

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

void setPitch ( float pitch ) #

Sets a sound pitch.

Arguments

  • float pitch - Factor, by which the current pitch will be multiplied.

float getPitch ( ) const#

Returns a sound pitch.

Return value

Factor, by which the current pitch will be multiplied.

bool isPlaying ( ) const#

Returns a value indicating if the sample is being played.

Return value

true if the sample is being played; otherwise, false.

void setSampleName ( const char * name ) #

Sets a new sound file for the ambient sound.
Notice
To change the sound file of the currently played ambient sound, first, you should stop the playback, set the sample name, and then resume the playback.
Source code (C++)
if (sound->isPlaying())
{
	// stop the playing sound
	sound->stop();
	// force updating of the sound thread
	Sound::renderWorld(1);
	// set a new sample file to be played
	sound->setSampleName("stream_stereo_01.oga");
	// play the sound
	sound->play();
}

Arguments

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

const char * getSampleName ( ) const#

Returns the name of the sound file.

Return value

Path to the sound file.

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.

int getSourceMask ( ) const#

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.

bool isStopped ( ) const#

Returns a value indicating if playback is stopped.

Return value

true if the sample is stopped; otherwise, false.

void setTime ( float time ) #

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

float getTime ( ) const#

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

Return value

Time in seconds.

void play ( ) #

Starts playing the sample.

void stop ( ) #

Stops playback. This function saves the playback position so that playing of the file can be resumed from the same point.
Notice
The playback won't stop immediately, as the sound thread is updated at 30 FPS. So, when you need to perform operations that require stopping of the playback (for example, updating the time, from which the sample should be played), you need to force update the sound thread after stopping the playback.
Last update: 29.04.2021
Build: ()