diff --git a/src/GameWorld.cpp b/src/GameWorld.cpp index 38d7410..c32e695 100755 --- a/src/GameWorld.cpp +++ b/src/GameWorld.cpp @@ -1005,7 +1005,6 @@ void GameWorld::Initialize() transform->Position = glm::vec3(20,2,-100); transform->Scale = glm::vec3(3); auto emitterComponent = AddComponent(se1); - emitterComponent->Path = "Sounds/WUB.mp3"; emitterComponent->MinDistance = 0.1f; emitterComponent->MaxDistance = 100000.f; emitterComponent->Gain = 1; diff --git a/src/InputManager.cpp b/src/InputManager.cpp index 3b3ac36..524033e 100644 --- a/src/InputManager.cpp +++ b/src/InputManager.cpp @@ -44,17 +44,16 @@ void InputManager::Update(double dt) if(m_CurrentKeyState[GLFW_KEY_Z]) //TEMP { - Events::PlayBGM e; - e.Resource = "Sounds/BGM/MainMenu.mp3"; + Events::PlaySFX e; + e.Resource = "Sounds/BGM/DarkHorse.mp3"; e.Loop = true; + e.Emitter = 58; EventBroker->Publish(e); } if(m_CurrentKeyState[GLFW_KEY_P]) //TEMP { Events::StopSound e; - e.Emitter = 59; - EventBroker->Publish(e); - e.Emitter = 62; + e.Emitter = 58; EventBroker->Publish(e); } diff --git a/src/Systems/SoundSystem.cpp b/src/Systems/SoundSystem.cpp index b6ec59b..d13fe04 100755 --- a/src/Systems/SoundSystem.cpp +++ b/src/Systems/SoundSystem.cpp @@ -134,9 +134,11 @@ bool Systems::SoundSystem::PlaySFX(const Events::PlaySFX &event) LOG_ERROR("FMOD: The Entity %i does not have a SoundEmitter-component, but is trying to play a sound", event.Emitter);FMOD_CHANNEL* channel = m_Channels[event.Emitter]; return false; } + emitter->type = Components::SoundEmitter::SoundType::SOUND_3D; Sound* sound = m_World->GetResourceManager()->Load("Sound3D", event.Resource); m_Sounds[event.Emitter] = *sound; + FMOD_Sound_Set3DMinMaxDistance(*sound, emitter->MinDistance, emitter->MaxDistance); PlaySound(&m_Channels[event.Emitter], m_Sounds[event.Emitter], 1.0, event.Loop); FMOD_System_Update(m_System); @@ -154,8 +156,8 @@ bool Systems::SoundSystem::PlayBGM(const Events::PlayBGM &event) { auto emitter = m_World->CreateEntity(); auto eTransform = m_World->AddComponent(emitter); - auto eComponent = m_World->AddComponent(emitter); + m_Channels[emitter] = m_BGMChannel; eComponent->type = Components::SoundEmitter::SoundType::SOUND_3D; Sound* sound = m_World->GetResourceManager()->Load("Sound2D", event.Resource); m_Sounds[emitter] = *sound; diff --git a/src/Systems/SoundSystem.h b/src/Systems/SoundSystem.h index fb5bbd6..1798dc4 100755 --- a/src/Systems/SoundSystem.h +++ b/src/Systems/SoundSystem.h @@ -46,6 +46,7 @@ private: void PlaySound(FMOD_CHANNEL**, FMOD_SOUND*, float volume, bool loop); FMOD_SYSTEM* m_System; + FMOD_CHANNEL* m_BGMChannel; std::vector m_Listeners; std::map m_Channels; std::map m_DeleteChannels;