From 2d8000b023342602b4789350e4adef8aea1a7907 Mon Sep 17 00:00:00 2001 From: BotoX Date: Wed, 19 May 2021 23:46:12 +0200 Subject: [PATCH] make silence chunks useful/correct --- demboyz/io/voicewriter/voicedatawriter.cpp | 5 +++-- demboyz/io/voicewriter/voicedatawriter.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/demboyz/io/voicewriter/voicedatawriter.cpp b/demboyz/io/voicewriter/voicedatawriter.cpp index aae5d6e..9b6b581 100644 --- a/demboyz/io/voicewriter/voicedatawriter.cpp +++ b/demboyz/io/voicewriter/voicedatawriter.cpp @@ -190,14 +190,15 @@ void VoiceDataWriter::EndCommandPacket(const PacketTrailingBits& trailingBits) if(!m_isSilenced) { m_isSilenced = true; - m_silence.emplace_back(std::make_pair(m_curTick, 0)); + m_silenceTicksStart = m_silenceTicks; + m_silence.emplace_back(std::make_pair(m_curTick - m_silenceTicks, 0)); } m_silenceTicks += (m_curTick - m_lastTick); } else if(m_isSilenced) { m_isSilenced = false; - m_silence.back().second = m_curTick; + m_silence.back().second = m_silenceTicks - m_silenceTicksStart; } for(auto& state : m_playerVoiceStates) diff --git a/demboyz/io/voicewriter/voicedatawriter.h b/demboyz/io/voicewriter/voicedatawriter.h index cd41814..3cd81b5 100644 --- a/demboyz/io/voicewriter/voicedatawriter.h +++ b/demboyz/io/voicewriter/voicedatawriter.h @@ -86,6 +86,7 @@ private: int32_t m_lastVoiceTick = 0; int32_t m_silenceTicks = 0; + int32_t m_silenceTicksStart = 0; const char* m_outputPath = nullptr; int16_t m_decodeBuffer[32768];