Skip to content

Commit

Permalink
ChaosMod/EffectSound3D: Adjust sound pitch to game pitch
Browse files Browse the repository at this point in the history
  • Loading branch information
pongo1231 committed Jan 17, 2025
1 parent a8958c0 commit 75b6c32
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
7 changes: 5 additions & 2 deletions ChaosMod/Components/EffectSound/EffectSound3D.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#include <stdafx.h>

#include "Util/Camera.h"

#include "EffectSound3D.h"

#include "Memory/Hooks/AudioPitchHook.h"
#include "Util/Camera.h"

#define MINIAUDIO_IMPLEMENTATION
#include <miniaudio.h>

Expand Down Expand Up @@ -92,6 +93,8 @@ void EffectSound3D::OnRun()
ma_sound_start(&sound.Handle);

ma_sound_set_rolloff(&sound.Handle, .1f);
ma_sound_set_pitch(&sound.Handle,
1.f + (!Hooks::GetTargetAudioPitch() ? 0.f : Hooks::GetTargetAudioPitch() * .0001f));

switch (sound.PlayOptions.PlayType)
{
Expand Down
5 changes: 5 additions & 0 deletions ChaosMod/Memory/Hooks/AudioPitchHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ namespace Hooks
ms_TargetPitch = pitch;
}

int GetTargetAudioPitch()
{
return !ms_EnabledHook ? 0.f : ms_TargetPitch;
}

void ResetAudioPitch()
{
ms_EnabledHook = false;
Expand Down
2 changes: 1 addition & 1 deletion ChaosMod/Memory/Hooks/AudioPitchHook.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
namespace Hooks
{
void SetAudioPitch(int pitch);

int GetTargetAudioPitch();
void ResetAudioPitch();
}

0 comments on commit 75b6c32

Please sign in to comment.