From 6b018aeb32192351f44f1204ae368420542ab196 Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Mon, 3 Apr 2023 00:37:40 -0400 Subject: [PATCH] Audio mixer window --- Editor/src/Windows/AudioWindow.h | 36 ++++++++++++++++++++++++++ Editor/src/Windows/EditorInterface.cpp | 4 ++- Editor/src/Windows/EditorInterface.h | 7 ++++- Nuake/src/Audio/AudioManager.cpp | 12 +++------ Nuake/src/Audio/AudioManager.h | 2 ++ Nuake/src/Audio/AudioSource.h | 15 +++++++++++ 6 files changed, 65 insertions(+), 11 deletions(-) create mode 100644 Editor/src/Windows/AudioWindow.h create mode 100644 Nuake/src/Audio/AudioSource.h diff --git a/Editor/src/Windows/AudioWindow.h b/Editor/src/Windows/AudioWindow.h new file mode 100644 index 00000000..aa278836 --- /dev/null +++ b/Editor/src/Windows/AudioWindow.h @@ -0,0 +1,36 @@ +#pragma once +#include "imgui/imgui.h" + +class AudioWindow +{ +public: + AudioWindow() = default; + ~AudioWindow() = default; + + float dummyVolume = 1.0f; + void Draw() + { + constexpr int numBus = 6; + if(ImGui::Begin("Audio mixer")) + { + for (int i = 0; i < numBus; i++) + { + const std::string busName = "Bus " + std::to_string(i); + ImGui::BeginTable(busName.c_str(), 1, 0, ImVec2(300, ImGui::GetContentRegionAvail().y)); + + ImGui::TableSetupColumn(busName.c_str(), 0, 1.0f); + ImGui::TableNextColumn (); + ImGui::TableHeader(busName.c_str()); + ImGui::TableNextColumn(); + + const float height = ImGui::GetContentRegionAvail().y - 50; + const std::string id = "##Volume" + std::to_string(i); + ImGui::VSliderFloat(id.c_str(), ImVec2(50, height), &dummyVolume, -60.0f, 6.0f, "%.3dB", ImGuiSliderFlags_Logarithmic); + ImGui::TableNextColumn(); + ImGui::EndTable(); + } + } + + ImGui::End(); + } +}; \ No newline at end of file diff --git a/Editor/src/Windows/EditorInterface.cpp b/Editor/src/Windows/EditorInterface.cpp index 92e37e56..23514384 100644 --- a/Editor/src/Windows/EditorInterface.cpp +++ b/Editor/src/Windows/EditorInterface.cpp @@ -55,7 +55,7 @@ namespace Nuake { { filesystem = new FileSystemUI(this); _WelcomeWindow = new WelcomeWindow(this); - + _audioWindow = new AudioWindow(); m_EntitySelectionFramebuffer = CreateRef(false, Vector2(1280, 720)); } @@ -1463,6 +1463,8 @@ namespace Nuake { pInterface.m_CurrentProject = Engine::GetProject(); + _audioWindow->Draw(); + DrawMenuBar(); pInterface.DrawEntitySettings(); diff --git a/Editor/src/Windows/EditorInterface.h b/Editor/src/Windows/EditorInterface.h index 55f48bc9..878c3e68 100644 --- a/Editor/src/Windows/EditorInterface.h +++ b/Editor/src/Windows/EditorInterface.h @@ -4,13 +4,17 @@ #include #include "src/Core/FileSystem.h" + #include "../Actions/EditorSelection.h" #include "EditorSelectionPanel.h" #include "WelcomeWindow.h" +#include "AudioWindow.h" -namespace Nuake { +namespace Nuake +{ class Material; class FileSystemUI; + class EditorInterface { private: @@ -32,6 +36,7 @@ namespace Nuake { bool m_IsMaterialSelected = false; public: WelcomeWindow* _WelcomeWindow; + AudioWindow* _audioWindow; FileSystemUI* filesystem; EditorSelection Selection; EditorSelectionPanel SelectionPanel; diff --git a/Nuake/src/Audio/AudioManager.cpp b/Nuake/src/Audio/AudioManager.cpp index 65f48572..3edf8fce 100644 --- a/Nuake/src/Audio/AudioManager.cpp +++ b/Nuake/src/Audio/AudioManager.cpp @@ -22,20 +22,14 @@ namespace Nuake void AudioManager::PlayTTS(const std::string& text) { - SoLoud::Speech speech; - speech.setText(text.c_str()); - _soloud->play(speech); - // Wait until sounds have finished - while (_soloud->getActiveVoiceCount() > 0) - { - // Still going, sleep for a bit - SoLoud::Thread::sleep(100); - } } void AudioManager::AudioThreadLoop() { + SoLoud::Speech speech; + speech.setText("Nuake"); + _soloud->play(speech); while(_audioThreadRunning) { diff --git a/Nuake/src/Audio/AudioManager.h b/Nuake/src/Audio/AudioManager.h index 53f3ec4b..27553b6e 100644 --- a/Nuake/src/Audio/AudioManager.h +++ b/Nuake/src/Audio/AudioManager.h @@ -7,6 +7,7 @@ namespace SoLoud { class Soloud; + class AudioSource; } namespace Nuake @@ -21,6 +22,7 @@ namespace Nuake std::thread _audioThread; std::mutex _audioMutex; + const int MAX_VOICE_COUNT = 32; public: AudioManager() = default; ~AudioManager() = default; diff --git a/Nuake/src/Audio/AudioSource.h b/Nuake/src/Audio/AudioSource.h new file mode 100644 index 00000000..7d4b513f --- /dev/null +++ b/Nuake/src/Audio/AudioSource.h @@ -0,0 +1,15 @@ +#pragma once + +namespace Nuake +{ + class AudioSource + { + private: + + public: + AudioSource() = default; + ~AudioSource() = default; + + + }; +} \ No newline at end of file