Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 310bfaa

Browse files
committed
Revert "Change pitchVariation to be additive, so it's not so confusing and weird with high/low pitch values"
This reverts commit 2e6b2cc.
1 parent 2e6b2cc commit 310bfaa

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
248248

249249
- New `HeldDevice` Lua function `IsEmpty`, which indicates whether the device is devoid of ammo. Can be used to skip an extra step to check for a `Magazine`. Will always return `false` for non-`HDFirearm` devices.
250250

251-
- New `SoundContainer` INI and Lua (R/W) property `PitchVariation`, which can be used to add randomness to the pitch of the sounds being played. Note that this randomness can raise or lower the sounds' pitch.
251+
- New `SoundContainer` INI and Lua (R/W) property `PitchVariation`, which can be used to randomize the pitch of the sounds being played.
252252

253253
- New `AHuman` and `ACrab` INI and Lua (R/W) property `JetReplenishRate`, which determines how fast jump time (i.e. jetpack fuel) is replenished during downtime.
254254

Managers/AudioMan.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,15 +530,16 @@ namespace RTE {
530530
int channelIndex;
531531
std::vector<const SoundSet::SoundData *> selectedSoundData;
532532
soundContainer->GetTopLevelSoundSet().GetFlattenedSoundData(selectedSoundData, true);
533-
float pitchVariation = std::abs(soundContainer->GetPitchVariation());
533+
float pitchVariationFactor = 1.0F + std::abs(soundContainer->GetPitchVariation());
534534
for (const SoundSet::SoundData *soundData : selectedSoundData) {
535535
result = (result == FMOD_OK) ? m_AudioSystem->playSound(soundData->SoundObject, channelGroupToPlayIn, true, &channel) : result;
536536
result = (result == FMOD_OK) ? channel->getIndex(&channelIndex) : result;
537537

538538
result = (result == FMOD_OK) ? channel->setUserData(soundContainer) : result;
539539
result = (result == FMOD_OK) ? channel->setCallback(SoundChannelEndedCallback) : result;
540540
result = (result == FMOD_OK) ? channel->setPriority(soundContainer->GetPriority()) : result;
541-
result = (result == FMOD_OK) ? channel->setPitch(soundContainer->GetPitch() + RandomNum(-pitchVariation, pitchVariation)) : result;
541+
float pitchVariationMultiplier = pitchVariationFactor == 1.0F ? 1.0F : RandomNum(1.0F / pitchVariationFactor, 1.0F * pitchVariationFactor);
542+
result = (result == FMOD_OK) ? channel->setPitch(soundContainer->GetPitch() * pitchVariationMultiplier) : result;
542543
if (soundContainer->IsImmobile()) {
543544
result = (result == FMOD_OK) ? channel->set3DLevel(0.0F) : result;
544545
result = (result == FMOD_OK) ? channel->setVolume(soundContainer->GetVolume()) : result;

0 commit comments

Comments
 (0)