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

Commit 78a410a

Browse files
committed
Cleanup pitch setting in ADoor and HDFirearm since SetPitch is nicer now
Some minor comment cleanups in SoundContainer header Fix up NetworkClient to support audioman and soundcontainer changes Clean up contentfile a little
1 parent 8deb5c7 commit 78a410a

File tree

6 files changed

+24
-13
lines changed

6 files changed

+24
-13
lines changed

Entities/ADoor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ namespace RTE {
422422
m_SpriteAnimDuration = LERP(0, m_MaxHealth, 10, m_InitialSpriteAnimDuration, m_Health);
423423

424424
if (!m_DoorMoveSound.IsBeingPlayed()) { m_DoorMoveSound.Play(m_Pos); }
425-
g_AudioMan.SetSoundPitch(&m_DoorMoveSound, LERP(10, m_InitialSpriteAnimDuration, 2, 1, m_SpriteAnimDuration) * g_AudioMan.GetGlobalPitch());
425+
m_DoorMoveSound.SetPitch(LERP(10, m_InitialSpriteAnimDuration, 2, 1, m_SpriteAnimDuration));
426426

427427
m_Health -= 0.4F;
428428
}

Entities/HDFirearm.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,13 +1009,13 @@ void HDFirearm::Update()
10091009
if (m_Activated && !m_Reloading && m_ActivationTimer.GetElapsedSimTimeMS() < m_ActivationDelay)
10101010
{
10111011
animDuration = (int)LERP(0, m_ActivationDelay, (float)(m_SpriteAnimDuration * 10), (float)m_SpriteAnimDuration, m_ActivationTimer.GetElapsedSimTimeMS());
1012-
g_AudioMan.SetSoundPitch(&m_ActiveSound, LERP(0, m_ActivationDelay, 0, 1.0, m_ActivationTimer.GetElapsedSimTimeMS()) * g_AudioMan.GetGlobalPitch());
1012+
m_ActiveSound.SetPitch(LERP(0, m_ActivationDelay, 0, 1.0, m_ActivationTimer.GetElapsedSimTimeMS()));
10131013
}
10141014
// Spin down
10151015
if ((!m_Activated || m_Reloading) && m_LastFireTmr.GetElapsedSimTimeMS() < m_DeactivationDelay)
10161016
{
10171017
animDuration = (int)LERP(0, m_DeactivationDelay, (float)m_SpriteAnimDuration, (float)(m_SpriteAnimDuration * 10), m_LastFireTmr.GetElapsedSimTimeMS());
1018-
g_AudioMan.SetSoundPitch(&m_ActiveSound, LERP(0, m_DeactivationDelay, 1.0, 0, m_LastFireTmr.GetElapsedSimTimeMS()) * g_AudioMan.GetGlobalPitch());
1018+
m_ActiveSound.SetPitch(LERP(0, m_DeactivationDelay, 1.0, 0, m_LastFireTmr.GetElapsedSimTimeMS()));
10191019
}
10201020

10211021
if (animDuration > 0 && !(m_Reloading && m_LastFireTmr.GetElapsedSimTimeMS() >= m_DeactivationDelay))

Entities/SoundContainer.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,8 @@ namespace RTE {
301301
/// <summary>
302302
/// Sets the volume sounds in this SoundContainer should be played at. Note that this does not factor volume changes due to the SoundContainer's position. Does not affect currently playing sounds.
303303
/// </summary>
304-
/// <param name="newVolume">The new volume sounds in this SoundContainer should be played at.</param>
305-
void SetVolume(float newVolume) { newVolume = std::clamp(newVolume, 0.0F, 1.0F); if (IsBeingPlayed()) { g_AudioMan.ChangePlayingSoundContainerVolume(this, newVolume); } m_Volume = newVolume; }
304+
/// <param name="newVolume">The new volume sounds in this SoundContainer should be played at. Limited between 0 and 10.</param>
305+
void SetVolume(float newVolume) { newVolume = std::clamp(newVolume, 0.0F, 10.0F); if (IsBeingPlayed()) { g_AudioMan.ChangePlayingSoundContainerVolume(this, newVolume); } m_Volume = newVolume; }
306306

307307
/// <summary>
308308
/// Gets the pitch the sounds in this SoundContainer are played at. Note that this does not factor in global pitch.
@@ -311,9 +311,9 @@ namespace RTE {
311311
float GetPitch() const { return m_Pitch; }
312312

313313
/// <summary>
314-
/// Sets the pitch sounds in this SoundContainer should be played at and updates any playing instances accordingly. Note that this does not factor in global pitch.
314+
/// Sets the pitch sounds in this SoundContainer should be played at and updates any playing instances accordingly.
315315
/// </summary>
316-
/// <param name="newPitch">The new pitch sounds in this SoundContainer should be played at.</param>
316+
/// <param name="newPitch">The new pitch sounds in this SoundContainer should be played at. Limited between 0.125 and 8 (8 octaves up or down).</param>
317317
void SetPitch(float newPitch) { newPitch = std::clamp(newPitch, 0.125F, 8.0F); if (IsBeingPlayed()) { g_AudioMan.ChangePlayingSoundContainerPitch(this, newPitch); } m_Pitch = newPitch; }
318318
#pragma endregion
319319

Managers/NetworkClient.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -609,20 +609,32 @@ namespace RTE {
609609
soundContainerToHandle->Stop();
610610
soundContainerToHandle->Reset();
611611
}
612-
soundContainerToHandle->Create(sndDataPtr->Loops, sndDataPtr->AffectedByGlobalPitch, sndDataPtr->AttenuationStartDistance, sndDataPtr->Immobile);
613612
for (size_t soundFileHash : sndDataPtr->SoundFileHashes) {
614613
if (soundFileHash != 0) { soundContainerToHandle->AddSound(ContentFile::GetPathFromHash(soundFileHash)); }
615614
}
616-
g_AudioMan.PlaySound(soundContainerToHandle, Vector(sndDataPtr->Position[0], sndDataPtr->Position[1]), -1, -1, sndDataPtr->Pitch);
615+
soundContainerToHandle->SetImmobile(sndDataPtr->Immobile);
616+
soundContainerToHandle->SetAttenuationStartDistance(sndDataPtr->AttenuationStartDistance);
617+
soundContainerToHandle->SetLoopSetting(sndDataPtr->Loops);
618+
619+
//soundContainerToHandle->SetPriority(sndDataPtr.Priority);
620+
soundContainerToHandle->SetAffectedByGlobalPitch(sndDataPtr->AffectedByGlobalPitch);
621+
622+
soundContainerToHandle->SetPosition(Vector(sndDataPtr->Position[0], sndDataPtr->Position[1]));
623+
soundContainerToHandle->SetVolume(sndDataPtr->Volume);
624+
soundContainerToHandle->SetPitch(sndDataPtr->Pitch);
625+
soundContainerToHandle->Play();
617626
break;
618627
case AudioMan::SOUND_STOP:
619628
soundContainerToHandle->Stop();
620629
break;
621630
case AudioMan::SOUND_SET_POSITION:
622631
soundContainerToHandle->SetPosition(Vector(sndDataPtr->Position[0], sndDataPtr->Position[1]));
623632
break;
633+
case AudioMan::SOUND_SET_VOLUME:
634+
soundContainerToHandle->SetVolume(sndDataPtr->Volume);
635+
break;
624636
case AudioMan::SOUND_SET_PITCH:
625-
g_AudioMan.SetSoundPitch(soundContainerToHandle, sndDataPtr->Pitch);
637+
soundContainerToHandle->SetPitch(sndDataPtr->Pitch);
626638
break;
627639
case AudioMan::SOUND_FADE_OUT:
628640
g_AudioMan.FadeOutSound(soundContainerToHandle, sndDataPtr->FadeOutTime);

System/ContentFile.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ namespace RTE {
190190
}
191191
FMOD::Sound *returnSample = nullptr;
192192

193-
// Check if the file has already been read and loaded from the disk and, if so, use that data.
194193
std::unordered_map<std::string, FMOD::Sound *>::iterator foundSound = s_LoadedSamples.find(m_DataPath);
195194
if (foundSound != s_LoadedSamples.end()) {
196195
returnSample = (*foundSound).second;

System/ContentFile.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,10 @@ namespace RTE {
150150
/// <summary>
151151
/// Loads and transfers the data represented by this ContentFile object as an FMOD FSOUND_SAMPLE. Ownership of the FSOUND_SAMPLE is NOT transferred!
152152
/// </summary>
153-
/// <param name="abortGameForInvalidSound">Whether to abort the game if the sound couldn't be added, or just show a console error. Default true.</param>
153+
/// <param name="abortGameForInvalidSound">Whether to abort the game if the sound couldn't be added, or just show a console error</param>
154154
/// <param name="asyncLoading">Whether to enable FMOD asynchronous loading or not. Should be disabled for loading audio files with Lua AddSound.
155155
/// <returns>Pointer to the FSOUND_SAMPLE loaded from disk.</returns>
156-
FMOD::Sound * LoadAndReleaseSample(bool abortGameForInvalidSound = true, bool asyncLoading = true);
156+
FMOD::Sound * LoadAndReleaseSample(bool abortGameForInvalidSound, bool asyncLoading);
157157
#pragma endregion
158158

159159
#pragma region Class Info

0 commit comments

Comments
 (0)