Table of Contents

helper_audio.hps

Helper functions for handling sound, music and dialogue

_Sound_Global_EntryAffected
bool _Sound_Global_EntryAffected(int alIdx,
                                 eSoundEntryType aAffectedTypes)

Sound_SetGlobalSpeed
void Sound_SetGlobalSpeed(float afFreq,
                          eSoundEntryType aAffectedTypes=eSoundEntryType_WorldAll)

Sets the relative frequency of all sounds.


Sound_FadeGlobalSpeed
void Sound_FadeGlobalSpeed(float afFreq,
                           float afTime,
                           eSoundEntryType aAffectedTypes=eSoundEntryType_WorldAll)

Fade the relative frequency of all sounds.


Sound_SetGlobalVolume
void Sound_SetGlobalVolume(float afVolume,
                           eSoundEntryType aAffectedTypes=eSoundEntryType_WorldAll)

Set the relative volume of all sounds.


Sound_FadeGlobalVolume
void Sound_FadeGlobalVolume(float afVolume,
                            float afTime,
                            eSoundEntryType aAffectedTypes=eSoundEntryType_WorldAll)

Fade the relative volume of all sounds.


Sound_CreateAIEventAtEntity
void Sound_CreateAIEventAtEntity(const tString &in asEntity,
                                 float afRadius,
                                 int alPrio)

Creates an event that is heard by any entity with the Listener component


Sound_CreateAtEntity
void Sound_CreateAtEntity(const tString &in asSoundName,
                          const tString &in asSoundFile,
                          const tString &in asEntity,
                          float afFadeTime=0.0f,
                          bool abSaveSound=false,
                          float afTargetVolume=1.0f)

Create and play a sound (.snt) file at the position of an entity or player.


Sound_CreateAtEntity_UsePrefix
void Sound_CreateAtEntity_UsePrefix(const tString &in asSoundName,
                                    const tString &in asSoundFile,
                                    const tString &in asEntity,
                                    float afFadeTime,
                                    bool abSaveSound,
                                    float afTargetVolume=1.0f)

Create and play a sound (.snt) file at the position of an entity or player. If a Soundscape area SoundPrefix is set, then that will be used as a parent folder for the sound.


Sound_Play
void Sound_Play(const tString &in asSoundName,
                float afFadeTime,
                bool abResetVolMul=false)

Play a sound that exists in the level editor, attached to an entity, or previously created that has been stopped and now should be played again.


Sound_Stop
void Sound_Stop(const tString &in asSoundName,
                float afFadeTime)

Stop a sound that is currently playing. Can be sound entities or Gui sounds.


Sound_Fade
void Sound_Fade(const tString &in asSoundName,
                float afVolumeDest,
                float afFadeTime)

Fade/Change the volume of a sound entity.


Sound_PlayGui
void Sound_PlayGui(const tString &in asSoundFile,
                   float afVolume,
                   eSoundEntryType aEntryType=eSoundEntryType_Gui)

Play a sound without any world position, either .snt files or any of the supported formats (.wav, .ogg etc) without the need of a .snt file.


Sound_FadeInGui
void Sound_FadeInGui(const tString &in asSoundFile,
                     float afVolume,
                     float afFadeTime)

Fades in a GUI sound. This is can called directly after Sound_PlayGui or in case the sound doesn't exist, start it.


Sound_StopGui
void Sound_StopGui(const tString &in asSoundFile,
                   float afFadeTime,
                   bool abPlayEnd=true)

Stops a GUI sounds


Sound_FadeGuiVolume
void Sound_FadeGuiVolume(const tString &in asSoundFile,
                         float afVolumeDest,
                         float afFadeTime)

Fades a GUI sound volume to another


Sound_FadeGuiSpeed
void Sound_FadeGuiSpeed(const tString &in asSoundFile,
                        float afSpeedDest,
                        float afFadeTime)

Fades a GUI sound speed to another


Sound_SetGuiParam
void Sound_SetGuiParam(const tString &in asSoundFile,
                       const tString &in asParam,
                       float afValue)

Sets the param of a gui sound


Sound_GuiIsPlaying
bool Sound_GuiIsPlaying(const tString &in asSoundFile)

Checks if a gui sound is playing.


Sound_PreloadGroup
void Sound_PreloadGroup(const tString &in asInternalPath,
                        bool abSubGroups)

Preloads a group of sounds and its subgroups if selected Preloading removes lag spikes that can occur when loading a sound from the hdd


Sound_PreloadProject
void Sound_PreloadProject(const tString &in asName)

Preloads a whole sound project and all sounds within it Preloading removes lag spikes that can occur when loading a sound from the hdd


Sound_PreloadCoreSounds
void Sound_PreloadCoreSounds()

Preloads all the basic sounds


Sound_PreloadCoreUWSounds
void Sound_PreloadCoreUWSounds()

Sound_PreloadCoreInteractions
void Sound_PreloadCoreInteractions()

Sound_PreloadCoreUWInteractions
void Sound_PreloadCoreUWInteractions()

Sound_Exists
bool Sound_Exists(const tString &in asSoundName)

Returns true or false if a given sound entity exists


Music_PlayExt
void Music_PlayExt(const tString &in asFile,
                   bool abLoop,
                   float afVolume,
                   float afFreq,
                   float afVolumeFadeTime,
                   float afFreqFadeTime,
                   eMusicPrio alPrio,
                   bool abResume)

Play music with extended options.


Music_Play
void Music_Play(const tString &in asFile,
                float afVolume,
                bool abLoop,
                eMusicPrio alPrio)

Play music at standard frequency with a default fade time of 0.3 seconds.


Music_PlayOverlay
void Music_PlayOverlay(const tString &in asFile,
                       float afVolume)

Plays a piece of music over the currently running music TODO: Needs to have proper code!


Music_Stop
void Music_Stop(float afFadeTime,
                eMusicPrio alPrio)

Stop a music track for a certain priority from playing.


Music_StopAll
void Music_StopAll(float afFadeTime)

Stop a music tracks for all priorities


Music_AddDynamicTrack
void Music_AddDynamicTrack(tID a_idEntity,
                           int alTrackPrio,
                           eMusicPrio alMusicPrio,
                           const tString &in asFile,
                           float afVolume,
                           float afFadeInTime,
                           float afFadeOutTime)

This adds music that is meant to only be played during a certain occurance, eg when an creature is hunting the player.


Music_RemoveDynamicTrack
void Music_RemoveDynamicTrack(tID a_idEntity)

This removes the dynamic track for certain entity and, if playing, fades out the music associated with it.


Music_FadeVolumeMul
void Music_FadeVolumeMul(float afMul,
                         float afTime)

Fades the volume multiplier for music.


Voice_Play
bool Voice_Play(const tString &in asSubject,
                int alSpecificLineIdx=-1,
                const tString &in asCallback="",
                int alPrio=0)

Starts playing a voice


Voice_PlayWhenPossible
void Voice_PlayWhenPossible(const tString &in asSubject,
                            const tString &in asConditionCallback="",
                            float afMaxCheckTime=30.0f,
                            float afMinQuietTime=5.0f,
                            const tString &in asVoiceCallback="",
                            int alPrio=0)

Starts playing a voice, but if another one is already playing it queues it until no other sound is playing and some custom conditions are met.


_Voice_PlayWhenPossible_CheckTimer
void _Voice_PlayWhenPossible_CheckTimer(const tString &in asTimer)

Voice_AbortIfQueued
void Voice_AbortIfQueued(const tString &in asSubject)

If a subject is queued (still not played) after started with Voice_PlayWhenPossible, use this to remove it and make sure it never plays


Voice_ClearQueued
void Voice_ClearQueued()

Clears all queued subjects.


Voice_IsQueued
bool Voice_IsQueued(const tString &in asSubject)

If a subject is queued with Voice_PlayWhenPossible, return true


Voice_SubjectExists
bool Voice_SubjectExists(const tString &in asSubject)

Checks if the specified subject exists.


Voice_GetSubjectLineNumber
int Voice_GetSubjectLineNumber(const tString &in asSubject)

Gets the number of subject lines in a subject. Returns 0 if the subject does not exist.


Voice_GetSubjectSceneName
tString Voice_GetSubjectSceneName(const tString &in asSubject)

Gets the name of the scene that the specified subject belongs to.

Returns: tString , The scene the subject belongs to.


Voice_SetSource
void Voice_SetSource(const tString &in asCharacter,
                     const tString &in asEntityName,
                     float afMinDistance,
                     float afMaxDistance,
                     bool abUse3D,
                     float afMaxPlayerListeningRange=-1,
                     float afMinFreq=22000,
                     float afMaxFreq=22000,
                     eLuxVoiceSourceFreqencyFlag aFrequencyFlags=eLuxVoiceSourceFreqencyFlag_None)

Sets the source of voice. Note that this can be a moving entity.


Voice_StopAll
void Voice_StopAll()

Stops all voices playing


Voice_Stop
void Voice_Stop(const tString &in asScene)

Stops all voices in a scene.


Voice_SkipCurrentLine
void Voice_SkipCurrentLine(const tString &in asScene)

Skips the current line (same as stop but response triggers are used)


Voice_SkipCurrentSound
void Voice_SkipCurrentSound(const tString &in asScene)

Skips the current sound and jumps to next (if any)


Voice_AdvanceFromCurrentSound
void Voice_AdvanceFromCurrentSound(const tString &in asScene)

Like SkipCurrentSound, but if there is subtitle it makes sure it is displayed first.


Voice_SetPaused
void Voice_SetPaused(const tString &in asScene,
                     bool abX)

Stops all voices in a scene.


Voice_SetPausedAll
void Voice_SetPausedAll(bool abX)

Stops all active voice scenes


Voice_SetFocusScene
void Voice_SetFocusScene(const tString &in asScene)

Sets the focus for a scene even if a scene with higher focusprio is playing. This makes the voices in the scene show subtitles and voices from other scenes lower. This will stay in effect until another scene is set. Note that a new subject in a scene with higher focus prio will override this.


Voice_FadeSceneVolumeTo
void Voice_FadeSceneVolumeTo(const tString &in asScene,
                             float afVolume,
                             float afTime)

Fades the volume of the voices from a specfic scene


Voice_CharacterIsSpeaking
bool Voice_CharacterIsSpeaking(const tString &in asCharacter)

If a character is currently speaking (i.e their voice is played).


Voice_SceneIsActive
bool Voice_SceneIsActive(const tString &in asScene)

If the specified scene is currently active.

Returns: bool, true if scene is currently active.


Voice_SubjectIsPlaying
bool Voice_SubjectIsPlaying(const tString &in asSubject)

If the specified subject is currently being played.

Returns: bool, true if subject is currently active.


Voice_AnySceneIsActive
bool Voice_AnySceneIsActive()

If any scene is currently active.

Returns: bool, true if any scene is currently active.


Voice_SceneInvolvingCharacterIsActive
bool Voice_SceneInvolvingCharacterIsActive(const tString &in asCharacter)

True if a scene involving this character is currently active.

Returns: bool, true if any scene involving the character is currently active.


Voice_SetCharacterSpeakingCallback
void Voice_SetCharacterSpeakingCallback(const tString &in asCharacter,
                                        const tString &in asCallback)

Sets a callback that is called when a character starts and stops speaking. If character callback exists, the callback func is replaced with the latest one.


Voice_RemoveCharacterSpeakingCallback
void Voice_RemoveCharacterSpeakingCallback(const tString &in asCharacter)

Removes a callback that is called when a character starts and stops speaking


Dialog_Begin
void Dialog_Begin(const tString &in asName="")

Begins the declaration of a dialog. Must be called before any other dialog creation is done.


Dialog_End
void Dialog_End(const tString &in asStartBranch="")

Ends the declaration of a dialog and starts the dialog. After this no more dialog creation funcs can be called without calling Dialog_Begin again.


Dialog_SetCallbackFunc
void Dialog_SetCallbackFunc(const tString &in asFunc)

Sets a callback function for the dialog. NOTE: Currently not used!


Dialog_AddBranch
void Dialog_AddBranch(const tString &in asName,
                      const tString &in asNextBranch="")

Adds a branch (a list of subjects) to the dialog. Dialog_Begin must be called before this is used!


Dialog_AddBranchAndSubject
void Dialog_AddBranchAndSubject(const tString &in asSubjectAndBranchName,
                                const tString &in asNextBranch="",
                                const tString &in asCallback="")

Adds a branch with a single subject to the dialog. The branch gets the same name as the subject. Dialog_Begin must be called before this is used!


Dialog_AddSubject
void Dialog_AddSubject(const tString &in asSubject,
                       const tString &in asCallback="")

Adds a subject to the latest added branch. The subjects will be played in order they are added. Dialog_AddBranch must be called before this is used!


Dialog_AddPause
void Dialog_AddPause(float afTime,
                     const tString &in asCallback="")

Adds a pause to the latest added branch. This pause will come after Dialog_AddBranch must be called before this is used!


Dialog_SetResponseTimeLimit
void Dialog_SetResponseTimeLimit(float afTime)

Set the response time for the response options. This is how long the player has to pick. Dialog_AddSubject must be called before this is used!


Dialog_AddResponseOption
void Dialog_AddResponseOption(const tString &in asEntry,
                              const tString &in asBranch,
                              int alOptionId=-1,
                              const tString &in asCallback="")

Adds a response option that is shown after the subject is over. Max number is 4, +1 default (this actually depends on the game implementation, but this the default max). Important: The defauly subject must be added last! Dialog_AddSubject must be called before this is used!


Dialog_AddResponseCondition_VarIsSet
void Dialog_AddResponseCondition_VarIsSet(const tString &in asVar)

Adds a condition that must be true for the option reponse option to be added. This checks if var is greater than 0. Dialog_AddResponseOption must be called before this is used!


Dialog_AddResponseCondition_VarNotSet
void Dialog_AddResponseCondition_VarNotSet(const tString &in asVar)

Adds a condition that must be true for the option reponse option to be added. This checks if var is less than 1 Dialog_AddResponseOption must be called before this is used!


Dialog_AddResponseCondition_VarEqual
void Dialog_AddResponseCondition_VarEqual(const tString &in asVar,
                                          int alVal)

Adds a condition that must be true for the option reponse option to be added. This checks if var is equal to a value. Dialog_AddResponseOption must be called before this is used!


Dialog_AddResponseCondition_VarLesser
void Dialog_AddResponseCondition_VarLesser(const tString &in asVar,
                                           int alVal)

Adds a condition that must be true for the option reponse option to be added. This checks if var is lesser than a value. Dialog_AddResponseOption must be called before this is used!


Dialog_AddResponseCondition_VarGreater
void Dialog_AddResponseCondition_VarGreater(const tString &in asVar,
                                            int alVal)

Adds a condition that must be true for the option reponse option to be added. This checks if var is greater than a value. Dialog_AddResponseOption must be called before this is used!


Dialog_AddResponseEvent_SetVar
void Dialog_AddResponseEvent_SetVar(const tString &in asVar,
                                    int alVal=1)

Event that happens after option is picked. This sets the value of a variable. Dialog_AddResponseOption must be called before this is used!


Dialog_AddResponseEvent_IncVar
void Dialog_AddResponseEvent_IncVar(const tString &in asVar,
                                    int alVal=1)

Event that happens after option is picked. This increments the value of a variable. Dialog_AddResponseOption must be called before this is used!


Dialog_AddResponse_OneTimeCheck
void Dialog_AddResponse_OneTimeCheck(const tString &in asVar)

This makes sure that the option is only shown once. Dialog_AddResponseOption must be called before this is used!


Dialog_AddEndEvent_SetVar
void Dialog_AddEndEvent_SetVar(const tString &in asVar,
                               int alValue=1)

Sets the value of an internal Dialog variableafter a subject is over. Dialog_AddSubject must be called before this is used!


Dialog_AddEndEvent_IncVar
void Dialog_AddEndEvent_IncVar(const tString &in asVar,
                               int alValue=1)

Increments the value of an internal Dialog variable after a subject is over. If var was not set priorly, it will start with 0. Dialog_AddSubject must be called before this is used!


Dialog_AddEndEvent_VarIsSet
void Dialog_AddEndEvent_VarIsSet(const tString &in asVar,
                                 const tString &in asNewBranch)

Checks if a variable as a value greater than 0 and exists. Dialog_AddSubject must be called before this is used!


Dialog_AddEndEvent_VarEquals
void Dialog_AddEndEvent_VarEquals(const tString &in asVar,
                                  int alValue,
                                  const tString &in asNewBranch)

Checks if a variable is equal to a value. If a variable does not exist it will assume to have value 0. Dialog_AddSubject must be called before this is used!


Dialog_AddEndEvent_VarGreater
void Dialog_AddEndEvent_VarGreater(const tString &in asVar,
                                   int alValue,
                                   const tString &in asNewBranch)

Checks if a variable is greater than a value. If a variable does not exist it will assume to have value 0. Dialog_AddSubject must be called before this is used!


Dialog_AddEndEvent_VarLesser
void Dialog_AddEndEvent_VarLesser(const tString &in asVar,
                                  int alValue,
                                  const tString &in asNewBranch)

Checks if a variable is lesser than a value. If a variable does not exist it will assume to have value 0. Dialog_AddSubject must be called before this is used!


Dialog_AddLineEvent_OutOfRange
void Dialog_AddLineEvent_OutOfRange(const tString &in asNewBranch)

Adds a branching event to the latest added subject. Checked at end of every line. This event checks if player is out of range from all characters in the dialog, and if so branches. Dialog_AddSubject must be called before this is used!


Dialog_AddEndEvent_OutOfRange
void Dialog_AddEndEvent_OutOfRange(const tString &in asNewBranch)

Adds a branching event to the latest added subject. Checked at end of the subject. This event checks if player is out of range from all characters in the dialog, and if so branches. Dialog_AddSubject must be called before this is used!


Dialog_AddLineEvent_PlayerNotLooking
void Dialog_AddLineEvent_PlayerNotLooking(const tString &in asNewBranch)

Adds a branching event to the latest added subject. Checked at end of every line. This event checks if is not looking at any character in the dialog, and if so branches. Dialog_AddSubject must be called before this is used!


Dialog_AddEndEvent_PlayerNotLooking
void Dialog_AddEndEvent_PlayerNotLooking(const tString &in asNewBranch)

Adds a branching event to the latest added subject. Checked at end of the subject. This event checks if is not looking at any character in the dialog, and if so branches. Dialog_AddSubject must be called before this is used!


Dialog_AddLineEvent_PlayerNotLookingOrOutOfRange
void Dialog_AddLineEvent_PlayerNotLookingOrOutOfRange(const tString &in asNewBranch)

Adds a branching event to the latest added subject. Checked at end of every line. This event checks if is not looking at any character any character or is out of range, and if so branches. Dialog_AddSubject must be called before this is used!


Dialog_AddEndEvent_PlayerNotLookingOrOutOfRange
void Dialog_AddEndEvent_PlayerNotLookingOrOutOfRange(const tString &in asNewBranch)

Adds a branching event to the latest added subject. Checked at end of subject. This event checks if is not looking at any character any character or is out of range, and if so branches. Dialog_AddSubject must be called before this is used!


Dialog_AddLineEvent_Callback
void Dialog_AddLineEvent_Callback(const tString &in asCallbackFunc,
                                  const tString &in asNewBranch)

Adds a branching event to the latest added subject. Checked at end of every line. This event checks if a custom callback returns true and if so branches. Dialog_AddSubject must be called before this is used!


Dialog_AddEndEvent_Callback
void Dialog_AddEndEvent_Callback(const tString &in asCallbackFunc,
                                 const tString &in asNewBranch)

Adds a branching event to the latest added subject. Checked at end of the subject. This event checks if a custom callback returns true and if so branches. Dialog_AddSubject must be called before this is used!


Dialog_CharacterIsActive
bool Dialog_CharacterIsActive(const tString &in asName)

Checks if a character is currently taking part in a dialog.


Dialog_Stop
void Dialog_Stop(const tString &in asName)

Stops a dialog


Dialog_StopAll
void Dialog_StopAll()

Stops all dialog


Dialog_StartConversation_CharMover
void Dialog_StartConversation_CharMover(const tString &in asVoiceCharacter,
                                        const tString &in asFocusEntityName,
                                        int alHeadBoneIndex,
                                        cLuxCharMover @apCharMover,
                                        float afMinTurnAngle,
                                        float afMaxMoveDist=0.5f)

Starts a dialog with an entity that has a CharMover. Should only be used internally by entities.


Dialog_StartConversation_PosBased
void Dialog_StartConversation_PosBased(const tString &in asVoiceCharacter,
                                       const tString &in asFocusEntity,
                                       const tString &in asPositionArea,
                                       const tString &in asHeadBone="",
                                       float afMaxMoveDist=0.5f,
                                       cVector3f avFocusOffset=cVector3f_Zero)

Starts a dialog with an entity, moving the player to a position to have the conversation.


Dialog_StartConversation
void Dialog_StartConversation(const tString &in asVoiceCharacter,
                              const tString &in asFocusEntityName,
                              float afMaxMoveDist=0.5f,
                              cVector3f avFocusOffset=cVector3f_Zero)

Starts a dialog with an entity.


Dialog_GetCharacterScene
tString Dialog_GetCharacterScene(const tString &in asCharacter)

Gets the scene the character is currently in.


Dialog_SetVar
void Dialog_SetVar(const tString &in asVar,
                   int alValue=1)

Sets the value of an internal Dialog variable


Dialog_IncVar
void Dialog_IncVar(const tString &in asVar,
                   int alValue=1)

Incremements the value of an internal Dialog variable. If var was not set priorly, it will start with 0.


Dialog_GetVar
int Dialog_GetVar(const tString &in asVar)

Gets the value of an internal Dialog variable. If it does not exist, 0 is returned.


Dialog_GetCharactersInSubject
void Dialog_GetCharactersInSubject(const tString &in asSubject,
                                   array< tString > &out avOutCharacters)

Returns a list of the characters who speak in a particular dialog subject.