From f2bc9adc365c5488e0fdd0996d5bdc3027f34806 Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Wed, 19 Jul 2023 23:25:16 +1000 Subject: [PATCH] Minor fixes --- source/client/StarClientApplication.cpp | 10 +++++----- source/frontend/StarVoice.cpp | 6 +----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/source/client/StarClientApplication.cpp b/source/client/StarClientApplication.cpp index b264f15..33327fa 100644 --- a/source/client/StarClientApplication.cpp +++ b/source/client/StarClientApplication.cpp @@ -214,6 +214,7 @@ void ClientApplication::applicationInit(ApplicationControllerPtr appController) m_voice->loadJson(jVoice.toObject(), true); m_voice->init(); + m_voice->setLocalSpeaker(0); } void ClientApplication::renderInit(RendererPtr renderer) { @@ -375,13 +376,12 @@ void ClientApplication::update() { updateTitle(); else if (m_state > MainAppState::Title) updateRunning(); - - // swallow leftover encoded data incase we aren't in-game yet to allow mic read to continue. - // TODO: directly disable encoding at menu so we don't have to do this - { + + // Swallow leftover encoded voice data if we aren't in-game to allow mic read to continue for settings. + if (m_state <= MainAppState::Title) { DataStreamBuffer ext; m_voice->send(ext); - } + } // TODO: directly disable encoding at menu so we don't have to do this m_guiContext->cleanup(); m_edgeKeyEvents.clear(); diff --git a/source/frontend/StarVoice.cpp b/source/frontend/StarVoice.cpp index 843203f..4a0e344 100644 --- a/source/frontend/StarVoice.cpp +++ b/source/frontend/StarVoice.cpp @@ -314,22 +314,18 @@ void Voice::readAudioData(uint8_t* stream, int len) { if (active) { float decibels = getAudioLoudness((int16_t*)stream, sampleCount); - if (!m_loopback) - m_clientSpeaker->decibelLevel = getAudioLoudness((int16_t*)stream, sampleCount, m_inputVolume); - if (m_inputMode == VoiceInputMode::VoiceActivity) { if (decibels > m_threshold) m_lastThresholdTime = now; active = now - m_lastThresholdTime < 50; } } - else if (!m_loopback) - m_clientSpeaker->decibelLevel = -96.0f; if (!m_loopback) { if (active && !m_clientSpeaker->playing) m_clientSpeaker->lastPlayTime = now; + m_clientSpeaker->decibelLevel = getAudioLoudness((int16_t*)stream, sampleCount, m_inputVolume); m_clientSpeaker->playing = active; }