foxygit / doom Log in
commit 79ffc9dbd24613e9f200db4ed9a66f2383048097
Author:     Jonathan Dowland <jon+github@alcopop.org>
AuthorDate: Fri Jun 26 06:39:28 2015 +0100
Commit:     Jonathan Dowland <jon+github@alcopop.org>
CommitDate: Wed Jul 1 08:47:18 2015 +0100

    Define NORM_PITCH in i_sound.h

    The four game engines and the back-end sound driver need to agree
    on what NORM_PITCH is, so define it in i_sound.h, which is the one
    header they all have in common. Remove other definitions and use
    it in a few places where a bare constant was used instead.
---
 src/doom/s_sound.c    | 1 -
 src/heretic/s_sound.c | 4 ++--
 src/hexen/s_sound.c   | 4 ++--
 src/i_sound.h         | 2 ++
 src/strife/s_sound.c  | 1 -
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/doom/s_sound.c b/src/doom/s_sound.c
index bccb41a8..83f691e0 100644
--- a/src/doom/s_sound.c
+++ b/src/doom/s_sound.c
@@ -59,7 +59,6 @@

 #define S_STEREO_SWING (96 * FRACUNIT)

-#define NORM_PITCH 128
 #define NORM_PRIORITY 64
 #define NORM_SEP 128

diff --git a/src/heretic/s_sound.c b/src/heretic/s_sound.c
index 988dc039..23f341e4 100644
--- a/src/heretic/s_sound.c
+++ b/src/heretic/s_sound.c
@@ -270,7 +270,7 @@ void S_StartSound(void *_origin, int sound_id)

     // TODO: Play pitch-shifted sounds as in Vanilla Heretic

-    channel[i].pitch = (byte) (127 + (M_Random() & 7) - (M_Random() & 7));
+    channel[i].pitch = (byte) (NORM_PITCH + (M_Random() & 7) - (M_Random() & 7));
     channel[i].handle = I_StartSound(&S_sfx[sound_id], i, vol, sep);
     channel[i].mo = origin;
     channel[i].sound_id = sound_id;
@@ -328,7 +328,7 @@ void S_StartSoundAtVolume(void *_origin, int sound_id, int volume)
     }

     // TODO: Pitch shifting.
-    channel[i].pitch = (byte) (127 - (M_Random() & 3) + (M_Random() & 3));
+    channel[i].pitch = (byte) (NORM_PITCH - (M_Random() & 3) + (M_Random() & 3));
     channel[i].handle = I_StartSound(&S_sfx[sound_id], i, volume, 128);
     channel[i].mo = origin;
     channel[i].sound_id = sound_id;
diff --git a/src/hexen/s_sound.c b/src/hexen/s_sound.c
index 60666566..189d59f9 100644
--- a/src/hexen/s_sound.c
+++ b/src/hexen/s_sound.c
@@ -502,11 +502,11 @@ void S_StartSoundAtVolume(mobj_t * origin, int sound_id, int volume)
 // TODO
     if (S_sfx[sound_id].changePitch)
     {
-        Channel[i].pitch = (byte) (127 + (M_Random() & 7) - (M_Random() & 7));
+        Channel[i].pitch = (byte) (NORM_PITCH + (M_Random() & 7) - (M_Random() & 7));
     }
     else
     {
-        Channel[i].pitch = 127;
+        Channel[i].pitch = NORM_PITCH;
     }
 #endif
     if (S_sfx[sound_id].lumpnum == 0)
diff --git a/src/i_sound.h b/src/i_sound.h
index 4e5a8040..e3f29c4f 100644
--- a/src/i_sound.h
+++ b/src/i_sound.h
@@ -22,6 +22,8 @@

 #include "doomtype.h"

+// so that the individual game logic and sound driver code agree
+#define NORM_PITCH 127

 //
 // SoundFX struct.
diff --git a/src/strife/s_sound.c b/src/strife/s_sound.c
index 525d5a34..3ef6e31c 100644
--- a/src/strife/s_sound.c
+++ b/src/strife/s_sound.c
@@ -60,7 +60,6 @@

 #define S_STEREO_SWING (96 * FRACUNIT)

-#define NORM_PITCH 128
 #define NORM_PRIORITY 64
 #define NORM_SEP 128