Skip to content

Commit

Permalink
fix: Stability fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
na2axl committed Dec 5, 2024
1 parent 1f41bc7 commit 239c7d3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/Core/Playback/ChannelInternalState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 3 additions & 2 deletions src/Core/RoomInternalState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<AmUInt32>(type)];
std::copy(std::begin(coefficients), std::begin(coefficients) + 9, m_absorptionCoefficients);
std::copy_n(std::begin(coefficients), 9, m_absorptionCoefficients);
}

void RoomInternalState::Update()
Expand All @@ -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) /
Expand Down
2 changes: 1 addition & 1 deletion src/Sound/Schedulers/RandomScheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace SparkyStudios::Audio::Amplitude
Sound* RandomScheduler::Select(const std::vector<AmSoundID>& toSkip)
{
Pick:
float selection = std::rand() / static_cast<float>(RAND_MAX) * _probabilitiesSum;
AmReal32 selection = static_cast<AmReal32>(std::rand()) / static_cast<AmReal32>(RAND_MAX) * _probabilitiesSum;
for (flatbuffers::uoffset_t i = 0; i < _sounds.size(); ++i)
{
const auto* entry = _definition->sounds()->GetAs<RandomSchedulerCollectionEntry>(i);
Expand Down

0 comments on commit 239c7d3

Please sign in to comment.