Minor fixes

This commit is contained in:
Kae 2023-07-19 23:25:16 +10:00
parent 1f038540a5
commit f2bc9adc36
2 changed files with 6 additions and 10 deletions

View File

@ -214,6 +214,7 @@ void ClientApplication::applicationInit(ApplicationControllerPtr appController)
m_voice->loadJson(jVoice.toObject(), true); m_voice->loadJson(jVoice.toObject(), true);
m_voice->init(); m_voice->init();
m_voice->setLocalSpeaker(0);
} }
void ClientApplication::renderInit(RendererPtr renderer) { void ClientApplication::renderInit(RendererPtr renderer) {
@ -376,12 +377,11 @@ void ClientApplication::update() {
else if (m_state > MainAppState::Title) else if (m_state > MainAppState::Title)
updateRunning(); updateRunning();
// swallow leftover encoded data incase we aren't in-game yet to allow mic read to continue. // Swallow leftover encoded voice data if we aren't in-game to allow mic read to continue for settings.
// TODO: directly disable encoding at menu so we don't have to do this if (m_state <= MainAppState::Title) {
{
DataStreamBuffer ext; DataStreamBuffer ext;
m_voice->send(ext); m_voice->send(ext);
} } // TODO: directly disable encoding at menu so we don't have to do this
m_guiContext->cleanup(); m_guiContext->cleanup();
m_edgeKeyEvents.clear(); m_edgeKeyEvents.clear();

View File

@ -314,22 +314,18 @@ void Voice::readAudioData(uint8_t* stream, int len) {
if (active) { if (active) {
float decibels = getAudioLoudness((int16_t*)stream, sampleCount); 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 (m_inputMode == VoiceInputMode::VoiceActivity) {
if (decibels > m_threshold) if (decibels > m_threshold)
m_lastThresholdTime = now; m_lastThresholdTime = now;
active = now - m_lastThresholdTime < 50; active = now - m_lastThresholdTime < 50;
} }
} }
else if (!m_loopback)
m_clientSpeaker->decibelLevel = -96.0f;
if (!m_loopback) { if (!m_loopback) {
if (active && !m_clientSpeaker->playing) if (active && !m_clientSpeaker->playing)
m_clientSpeaker->lastPlayTime = now; m_clientSpeaker->lastPlayTime = now;
m_clientSpeaker->decibelLevel = getAudioLoudness((int16_t*)stream, sampleCount, m_inputVolume);
m_clientSpeaker->playing = active; m_clientSpeaker->playing = active;
} }