From 239c7d3b76a5d1e6a17ffa92207d419badca8b68 Mon Sep 17 00:00:00 2001 From: Axel Nana Date: Thu, 5 Dec 2024 09:18:25 +0100 Subject: [PATCH] fix: Stability fixes. --- src/Core/Playback/ChannelInternalState.cpp | 2 ++ src/Core/RoomInternalState.cpp | 5 +++-- src/Sound/Schedulers/RandomScheduler.cpp | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Core/Playback/ChannelInternalState.cpp b/src/Core/Playback/ChannelInternalState.cpp index 36177800..41336ea6 100644 --- a/src/Core/Playback/ChannelInternalState.cpp +++ b/src/Core/Playback/ChannelInternalState.cpp @@ -45,6 +45,8 @@ namespace SparkyStudios::Audio::Amplitude priority_node.remove(); bus_node.remove(); entity_node.remove(); + room_node.remove(); + listener_node.remove(); } void ChannelInternalState::Reset() diff --git a/src/Core/RoomInternalState.cpp b/src/Core/RoomInternalState.cpp index cdaee139..e8286517 100644 --- a/src/Core/RoomInternalState.cpp +++ b/src/Core/RoomInternalState.cpp @@ -48,9 +48,10 @@ namespace SparkyStudios::Audio::Amplitude RoomMaterial::RoomMaterial(RoomMaterialType type) : m_type(type) + , m_absorptionCoefficients{ 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f } { const auto& coefficients = kDefaultAbsorptionCoefficients[static_cast(type)]; - std::copy(std::begin(coefficients), std::begin(coefficients) + 9, m_absorptionCoefficients); + std::copy_n(std::begin(coefficients), 9, m_absorptionCoefficients); } void RoomInternalState::Update() @@ -66,7 +67,7 @@ namespace SparkyStudios::Audio::Amplitude const auto& coefficients = _materials[i].m_absorptionCoefficients; // Compute average absorption coefficients - AmReal32 averageAbsorptionCoefficients = + const AmReal32 averageAbsorptionCoefficients = std::accumulate( std::begin(coefficients) + kReflectionStartingBand, std::begin(coefficients) + kReflectionStartingBand + kReflectionAveragingBandsCount, 0.0f) / diff --git a/src/Sound/Schedulers/RandomScheduler.cpp b/src/Sound/Schedulers/RandomScheduler.cpp index de792bec..36ba2186 100644 --- a/src/Sound/Schedulers/RandomScheduler.cpp +++ b/src/Sound/Schedulers/RandomScheduler.cpp @@ -57,7 +57,7 @@ namespace SparkyStudios::Audio::Amplitude Sound* RandomScheduler::Select(const std::vector& toSkip) { Pick: - float selection = std::rand() / static_cast(RAND_MAX) * _probabilitiesSum; + AmReal32 selection = static_cast(std::rand()) / static_cast(RAND_MAX) * _probabilitiesSum; for (flatbuffers::uoffset_t i = 0; i < _sounds.size(); ++i) { const auto* entry = _definition->sounds()->GetAs(i);