Trigger API Reference\DCEI Functions\Sound

bool IsMusicEnabled()

bool IsMusicEnabled()

Description


Returns if the music is enabled or not.

Example Usage

local music_enabled = DCEI.IsMusicEnabled()
if music_enabled then
    DCEI.LogMessage("Music is enabled")
else
    DCEI.LogMessage("Music is disabled")
end

bool IsSoundEnabled()

bool IsSoundEnabled()

Description


Returns if the sound is enabled.

Example Usage

local sound_enabled = DCEI.IsSoundEnabled()
if sound_enabled then
    DCEI.LogMessage("Sound is enabled")
else
    DCEI.LogMessage("Sound is disabled")
end

void SetMasterVolume(float volume)

void SetMasterVolume(float volume)

Description


Sets the master volume for both music and sound. The function automatically clamps the volume value between 0 and 1.

Parameters

Example Usage

DCEI.SetMasterVolume(1)
Core.Timer.Real.New({
    duration = 3,
    action = function()
        DCEI.SetMasterVolume(0.2)
    end,
})

float GetMasterVolume()

float GetMasterVolume()

Description


Gets the value of the master volume. 0 is silence and 1 is the maximum value.

Example Usage

local master_volume = DCEI.GetMasterVolume()
DCEI.LogMessage("The master volume is: " + master_volume)

void PlayMusic(string name, bool smoothTransition = False)

void PlayMusic(string name, bool smoothTransition = False)

Description


Plays the specified song on repeat. This will replace the default music played. Music must be declared by register api Sound.

Parameters

Battle1
Battle2
Battle3
Hometown1
Boss1

Example Usage

function OnClickRMB()
    DCEI.PlayMusic("Boss1", false)
end

DCEI.TriggerAddMouseDownEvent(1, OnClickRMB)

void SetMusicVolume(float volume)

void SetMusicVolume(float volume)

Description


Sets the music volume to a value between 0 and 1. Cannot be used on the game's first frame as the music hasn't initialized yet.

Parameters

Example Usage

function OnClickRMB()
    DCEI.SetMusicVolume(0.1)
end
DCEI.TriggerAddMouseDownEvent(1, OnClickRMB)

float GetMusicVolume()

float GetMusicVolume()

Description


Gets the value of the music volume. 0 is silence and 1 is the maximum value.

Example Usage

local music_volume = DCEI.GetMusicVolume()
DCEI.LogMessage("The music volume is: " + music_volume)

void PauseMusic()

void PauseMusic()

Description


Pauses the music currently playing. Cannot be used on the game's first frame as the music hasn't initialized yet.

Example Usage

function OnClickRMB()
    DCEI.PauseMusic()
end

DCEI.TriggerAddMouseDownEvent(1, OnClickRMB)

void ResumeMusic()

void ResumeMusic()

Description


Resumes paused music. If music is currently not paused, restarts the music currently playing.

Example Usage

function OnClickLMB()
    DCEI.ResumeMusic()
end

DCEI.TriggerAddMouseDownEvent(0, OnClickLMB)

void PlaySound(string nameOrPath, float volume = 1)

void PlaySound(string nameOrPath, float volume = 1)

Description


Plays the given sound at the given volume. A given volume of 0 will playback at the default volume. While volume doesn't have an explicit maximum value, it's recommended to keep this under 5.
The sound must be declared by register api Sound.

Parameters

Example Usage

local sound = DCEI.Sound("dryad_bewitch_cast")
local volume = 5
DCEI.PlaySound(sound, volume)

void SetSoundVolume(float volume)

void SetSoundVolume(float volume)

Description


Sets the overall sound volume to a value between 0 and 1.

Parameters

Example Usage

DCEI.SetSoundVolume(0.5)
local sound = DCEI.Sound("dryad_bewitch_cast")
local volume = 0
DCEI.PlaySound(sound, volume)

float GetSoundVolume()

float GetSoundVolume()

Description


Gets the value of the sound volume. 0 is silence and 1 is the maximum value.

Example Usage

local sound_volume = DCEI.GetSoundVolume()
DCEI.LogMessage("The sound volume is: " + sound_volume)

void PlaySoundForPlayer(string nameOrPath, int playerId, float volume = 1)

void PlaySoundForPlayer(string nameOrPath, int playerId, float volume = 1)

Description


Play sound for a specific player. Only useful in multiplayer.

Parameters

Example Usage

local sound = DCEI.Sound("dryad_bewitch_cast")
local volume = 1
DCEI.PlaySoundForPlayer(sound, 1, volume)