Merge pull request #385 from SHADE-DP/SP3-129-AudioSystem
Add Set audio param with label functionality
This commit is contained in:
commit
421016f4fc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -113,7 +113,8 @@ public partial class LeafChase : BehaviourTreeNode
|
||||||
if (GetNodeData("isAlert") != null && (bool)GetNodeData("isAlert") == true)
|
if (GetNodeData("isAlert") != null && (bool)GetNodeData("isAlert") == true)
|
||||||
{
|
{
|
||||||
//AudioHandler.audioClipHandlers["BGMAdpative"].SetParameter("Detected", 0.0f);
|
//AudioHandler.audioClipHandlers["BGMAdpative"].SetParameter("Detected", 0.0f);
|
||||||
Audio.SetParameter("Detected", 0.0f);
|
//Audio.SetParameter("Detected", 0.0f);
|
||||||
|
Audio.SetParameterWithLabel("PlayerDetection", "Undetected");
|
||||||
AudioHandler.audioClipHandlers["SFXHumming"].Play();
|
AudioHandler.audioClipHandlers["SFXHumming"].Play();
|
||||||
}
|
}
|
||||||
SetNodeData("isAlert", false);
|
SetNodeData("isAlert", false);
|
||||||
|
|
|
@ -245,7 +245,8 @@ public partial class LeafPatrol : BehaviourTreeNode
|
||||||
AudioHandler.audioClipHandlers["SFXHumming"].Play();
|
AudioHandler.audioClipHandlers["SFXHumming"].Play();
|
||||||
//AudioHandler.audioClipHandlers["BGMUnalert"].Play();
|
//AudioHandler.audioClipHandlers["BGMUnalert"].Play();
|
||||||
//AudioHandler.audioClipHandlers["BGMAdaptive"].SetParameter("Detected", 0.0f);
|
//AudioHandler.audioClipHandlers["BGMAdaptive"].SetParameter("Detected", 0.0f);
|
||||||
Audio.SetParameter("Detected", 0.0f);
|
//Audio.SetParameter("Detected", 0.0f);
|
||||||
|
Audio.SetParameterWithLabel("PlayerDetection", "Undetected");
|
||||||
}
|
}
|
||||||
SetNodeData("isAlert", false);
|
SetNodeData("isAlert", false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ public partial class LeafSearch : BehaviourTreeNode
|
||||||
private Vector3 eyeOffset;
|
private Vector3 eyeOffset;
|
||||||
private float sightDistance;
|
private float sightDistance;
|
||||||
private GameObject? player; //To be searched for and marked
|
private GameObject? player; //To be searched for and marked
|
||||||
|
private bool screamOnce;
|
||||||
}
|
}
|
||||||
|
|
||||||
//FUNCTIONS HERE
|
//FUNCTIONS HERE
|
||||||
|
@ -67,7 +68,8 @@ public partial class LeafSearch : BehaviourTreeNode
|
||||||
if (GetNodeData("isAlert") != null && (bool)GetNodeData("isAlert") == true)
|
if (GetNodeData("isAlert") != null && (bool)GetNodeData("isAlert") == true)
|
||||||
{
|
{
|
||||||
//AudioHandler.audioClipHandlers["BGMAdaptive"].SetParameter("Detected", 0.0f);
|
//AudioHandler.audioClipHandlers["BGMAdaptive"].SetParameter("Detected", 0.0f);
|
||||||
Audio.SetParameter("Detected", 0.0f);
|
//Audio.SetParameter("Detected", 0.0f);
|
||||||
|
Audio.SetParameterWithLabel("PlayerDetection", "Undetected");
|
||||||
AudioHandler.audioClipHandlers["SFXHumming"].Play();
|
AudioHandler.audioClipHandlers["SFXHumming"].Play();
|
||||||
reevaluateWaypoint();
|
reevaluateWaypoint();
|
||||||
}
|
}
|
||||||
|
@ -97,6 +99,7 @@ public partial class LeafSearch : BehaviourTreeNode
|
||||||
|
|
||||||
//Search for player
|
//Search for player
|
||||||
player = GameObject.Find("Player");
|
player = GameObject.Find("Player");
|
||||||
|
screamOnce = false;
|
||||||
|
|
||||||
//Automatically fail if no player is found
|
//Automatically fail if no player is found
|
||||||
if (player == null)
|
if (player == null)
|
||||||
|
@ -188,31 +191,41 @@ public partial class LeafSearch : BehaviourTreeNode
|
||||||
if (GetNodeData("isAlert") == null)
|
if (GetNodeData("isAlert") == null)
|
||||||
{
|
{
|
||||||
SetNodeData("isAlert", true);
|
SetNodeData("isAlert", true);
|
||||||
|
screamOnce = true;
|
||||||
//Audio.StopAllSounds();
|
//Audio.StopAllSounds();
|
||||||
AudioHandler.audioClipHandlers["SFXDetectAh"].Play();
|
//AudioHandler.audioClipHandlers["SFXDetectAh"].Play();
|
||||||
AudioHandler.audioClipHandlers["SFXDetectSting"].Play();
|
AudioHandler.audioClipHandlers["SFXDetectSting"].Play();
|
||||||
//AudioHandler.audioClipHandlers["BGMAlert"].Play();
|
//AudioHandler.audioClipHandlers["BGMAlert"].Play();
|
||||||
AudioHandler.audioClipHandlers["SFXHumming"].Stop(false);
|
AudioHandler.audioClipHandlers["SFXHumming"].Stop(false);
|
||||||
//AudioHandler.audioClipHandlers["BGMUnalert"].Stop(true);
|
//AudioHandler.audioClipHandlers["BGMUnalert"].Stop(true);
|
||||||
//AudioHandler.audioClipHandlers["BGMAdaptive"].SetParameter("Detected", 1.0f);
|
//AudioHandler.audioClipHandlers["BGMAdaptive"].SetParameter("Detected", 1.0f);
|
||||||
Audio.SetParameter("Detected", 1.0f);
|
//Audio.SetParameter("Detected", 1.0f);
|
||||||
|
Audio.SetParameterWithLabel("PlayerDetection", "Detected");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (GetNodeData("isAlert") != null && (bool)GetNodeData("isAlert") == false)
|
if (GetNodeData("isAlert") != null && (bool)GetNodeData("isAlert") == false)
|
||||||
{
|
{
|
||||||
//Audio.StopAllSounds();
|
//Audio.StopAllSounds();
|
||||||
AudioHandler.audioClipHandlers["SFXDetectAh"].Play();
|
screamOnce = true;
|
||||||
|
//AudioHandler.audioClipHandlers["SFXDetectAh"].Play();
|
||||||
AudioHandler.audioClipHandlers["SFXDetectSting"].Play();
|
AudioHandler.audioClipHandlers["SFXDetectSting"].Play();
|
||||||
//AudioHandler.audioClipHandlers["BGMAlert"].Play();
|
//AudioHandler.audioClipHandlers["BGMAlert"].Play();
|
||||||
AudioHandler.audioClipHandlers["SFXHumming"].Stop(false);
|
AudioHandler.audioClipHandlers["SFXHumming"].Stop(false);
|
||||||
//AudioHandler.audioClipHandlers["BGMUnalert"].Stop(true);
|
//AudioHandler.audioClipHandlers["BGMUnalert"].Stop(true);
|
||||||
//AudioHandler.audioClipHandlers["BGMAdaptive"].SetParameter("Detected", 1.0f);
|
//AudioHandler.audioClipHandlers["BGMAdaptive"].SetParameter("Detected", 1.0f);
|
||||||
Audio.SetParameter("Detected", 1.0f);
|
//Audio.SetParameter("Detected", 1.0f);
|
||||||
|
Audio.SetParameterWithLabel("PlayerDetection", "Detected");
|
||||||
}
|
}
|
||||||
SetNodeData("isAlert", true);
|
SetNodeData("isAlert", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (screamOnce)
|
||||||
|
{
|
||||||
|
screamOnce = false;
|
||||||
|
AudioHandler.audioClipHandlers["SFXDetectAh"].Play();
|
||||||
|
}
|
||||||
|
|
||||||
status = BehaviourTreeNodeStatus.SUCCESS;
|
status = BehaviourTreeNodeStatus.SUCCESS;
|
||||||
onExit(BehaviourTreeNodeStatus.SUCCESS);
|
onExit(BehaviourTreeNodeStatus.SUCCESS);
|
||||||
return status;
|
return status;
|
||||||
|
|
|
@ -83,10 +83,10 @@ public class GameManager : Script
|
||||||
|
|
||||||
protected override void start()
|
protected override void start()
|
||||||
{
|
{
|
||||||
AudioHandler.audioClipHandlers["BGMAdaptive"] = Audio.CreateAudioClip("event:/Music/bgm_adaptive");
|
AudioHandler.audioClipHandlers["BGMAdaptive"] = Audio.CreateAudioClip("event:/Music/bgm_adaptive_new");
|
||||||
AudioHandler.audioClipHandlers["BGMAdaptive"].Play();
|
AudioHandler.audioClipHandlers["BGMAdaptive"].Play();
|
||||||
|
|
||||||
Audio.SetParameter("Detected", 0.0f);
|
Audio.SetParameterWithLabel("PlayerDetection", "Undetected");
|
||||||
|
|
||||||
AudioHandler.audioClipHandlers["KitchenAmbience"] = Audio.CreateAudioClip("event:/Ambience/roomtone_kitchen");
|
AudioHandler.audioClipHandlers["KitchenAmbience"] = Audio.CreateAudioClip("event:/Ambience/roomtone_kitchen");
|
||||||
AudioHandler.audioClipHandlers["KitchenAmbience"].Play();
|
AudioHandler.audioClipHandlers["KitchenAmbience"].Play();
|
||||||
|
|
|
@ -656,6 +656,15 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SHAudioSystem::SetParameterWithLabel(const char* path, const char* label)
|
||||||
|
{
|
||||||
|
result = fmodStudioSystem->setParameterByNameWithLabel(path, label);
|
||||||
|
if (result != FMOD_OK)
|
||||||
|
{
|
||||||
|
ErrorCheck();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AudioClip::Play()
|
void AudioClip::Play()
|
||||||
{
|
{
|
||||||
if(!instance)
|
if(!instance)
|
||||||
|
@ -734,12 +743,16 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//void AudioClip::SetParameterLabel(const char* paramName, const char* label)
|
void AudioClip::SetParameterWithLabel(const char* paramName, const char* label)
|
||||||
//{
|
{
|
||||||
// if (!instance)
|
if (!instance)
|
||||||
// return;
|
return;
|
||||||
// instance->setParameterByNameWithLabel(paramName, label);
|
FMOD_RESULT result = instance->setParameterByNameWithLabel(paramName, label);
|
||||||
//}
|
if (result != FMOD_OK)
|
||||||
|
{
|
||||||
|
SHLOG_ERROR("Audio system error: {}", FMOD_ErrorString(result))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
float AudioClip::GetParameterValue(const char* paramName)
|
float AudioClip::GetParameterValue(const char* paramName)
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace SHADE
|
||||||
void SetPause(bool pause);
|
void SetPause(bool pause);
|
||||||
bool IsPaused();
|
bool IsPaused();
|
||||||
void SetParameter(const char* paramName, float value);
|
void SetParameter(const char* paramName, float value);
|
||||||
//void SetParameterLabel(const char* paramName, const char* label);
|
void SetParameterWithLabel(const char* paramName, const char* label);
|
||||||
float GetParameterValue(const char* paramName);
|
float GetParameterValue(const char* paramName);
|
||||||
float GetVolume();
|
float GetVolume();
|
||||||
void SetVolume(float volume);
|
void SetVolume(float volume);
|
||||||
|
@ -94,6 +94,7 @@ namespace SHADE
|
||||||
|
|
||||||
float GetParameterValue(const char* path);
|
float GetParameterValue(const char* path);
|
||||||
void SetParameter(const char* path, float value);
|
void SetParameter(const char* path, float value);
|
||||||
|
void SetParameterWithLabel(const char* path, const char* label);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FMOD::Studio::System* fmodStudioSystem;
|
FMOD::Studio::System* fmodStudioSystem;
|
||||||
|
|
|
@ -124,6 +124,12 @@ namespace SHADE
|
||||||
audioSys->SetParameter(Convert::ToNative(path).data(), value);
|
audioSys->SetParameter(Convert::ToNative(path).data(), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Audio::SetParameterWithLabel(System::String^ path, System::String^ label)
|
||||||
|
{
|
||||||
|
auto audioSys = SHSystemManager::GetSystem<SHAudioSystem>();
|
||||||
|
audioSys->SetParameterWithLabel(Convert::ToNative(path).data(), Convert::ToNative(label).data());
|
||||||
|
}
|
||||||
|
|
||||||
AudioClipHandler Audio::CreateAudioClip(System::String^ path)
|
AudioClipHandler Audio::CreateAudioClip(System::String^ path)
|
||||||
{
|
{
|
||||||
auto audioSys = SHSystemManager::GetSystem<SHAudioSystem>();
|
auto audioSys = SHSystemManager::GetSystem<SHAudioSystem>();
|
||||||
|
|
|
@ -105,6 +105,7 @@ namespace SHADE
|
||||||
static void SetVCAVolume(System::String^ path, float volume);
|
static void SetVCAVolume(System::String^ path, float volume);
|
||||||
static float GetParameterValue(System::String^ path);
|
static float GetParameterValue(System::String^ path);
|
||||||
static void SetParameter(System::String^ path, float value);
|
static void SetParameter(System::String^ path, float value);
|
||||||
|
static void SetParameterWithLabel(System::String^ path, System::String^ label);
|
||||||
|
|
||||||
//to comment ltr
|
//to comment ltr
|
||||||
static AudioClipHandler CreateAudioClip(System::String^ path);
|
static AudioClipHandler CreateAudioClip(System::String^ path);
|
||||||
|
|
|
@ -79,6 +79,11 @@ namespace SHADE
|
||||||
NativeObject->SetParameter(Convert::ToNative(paramName).data(), value);
|
NativeObject->SetParameter(Convert::ToNative(paramName).data(), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AudioClipHandler::SetParameterWithLabel(System::String^ paramName, System::String^ label)
|
||||||
|
{
|
||||||
|
NativeObject->SetParameterWithLabel(Convert::ToNative(paramName).data(), Convert::ToNative(label).data());
|
||||||
|
}
|
||||||
|
|
||||||
float AudioClipHandler::GetParameterValue(System::String^ paramName)
|
float AudioClipHandler::GetParameterValue(System::String^ paramName)
|
||||||
{
|
{
|
||||||
return NativeObject->GetParameterValue(Convert::ToNative(paramName).data());
|
return NativeObject->GetParameterValue(Convert::ToNative(paramName).data());
|
||||||
|
|
|
@ -71,6 +71,7 @@ namespace SHADE
|
||||||
void SetPause(bool pause);
|
void SetPause(bool pause);
|
||||||
bool IsPaused();
|
bool IsPaused();
|
||||||
void SetParameter(System::String^ paramName, float value);
|
void SetParameter(System::String^ paramName, float value);
|
||||||
|
void SetParameterWithLabel(System::String^ paramName, System::String^ label);
|
||||||
float GetParameterValue(System::String^ paramName);
|
float GetParameterValue(System::String^ paramName);
|
||||||
float GetVolume();
|
float GetVolume();
|
||||||
void SetVolume(float volume);
|
void SetVolume(float volume);
|
||||||
|
|
Loading…
Reference in New Issue