foxygit / doom Log in
commit 8a3621b237bdc5c7c2b9e7ea747045aa7950ad8c
Author:     Jonathan Dowland <jon+github@alcopop.org>
AuthorDate: Wed Jul 8 22:02:46 2015 +0100
Commit:     Jonathan Dowland <jon+github@alcopop.org>
CommitDate: Wed Jul 8 22:02:46 2015 +0100

    Enable pitch-shifting in Hexen

    Hexen modified the sfxinfo_t structure from Doom, removing the
    pitch member (which was used for sfx links, which aren't used
    in Hexen anyway) and adding 'changePitch', a flag which indicated
    whether a given sound effect should be shifted, or not.

    Rather than add the member back, overload the 'pitch' member to
    mean the same thing.

    The table of sfxinfo_t definitions was already writing the
    changePitch value into the pitch member, so no further changes
    are needed there.
---
 src/hexen/s_sound.c | 11 +++++------
 src/i_sound.h       |  2 +-
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/hexen/s_sound.c b/src/hexen/s_sound.c
index 2e1fcb67..56262f46 100644
--- a/src/hexen/s_sound.c
+++ b/src/hexen/s_sound.c
@@ -498,9 +498,8 @@ void S_StartSoundAtVolume(mobj_t * origin, int sound_id, int volume)
 //              vol = SoundCurve[dist];
     }

-#if 0
-// TODO
-    if (S_sfx[sound_id].changePitch)
+    // if the sfxinfo_t is marked as 'can be pitch shifted'
+    if (S_sfx[sound_id].pitch)
     {
         Channel[i].pitch = (byte) (NORM_PITCH + (M_Random() & 7) - (M_Random() & 7));
     }
@@ -508,7 +507,7 @@ void S_StartSoundAtVolume(mobj_t * origin, int sound_id, int volume)
     {
         Channel[i].pitch = NORM_PITCH;
     }
-#endif
+
     if (S_sfx[sound_id].lumpnum == 0)
     {
         S_sfx[sound_id].lumpnum = I_GetSfxLumpNum(&S_sfx[sound_id]);
@@ -518,7 +517,7 @@ void S_StartSoundAtVolume(mobj_t * origin, int sound_id, int volume)
                                      i,
                                      vol,
                                      sep,
-                                     NORM_PITCH);
+                                     Channel[i].pitch);
     Channel[i].sound_id = sound_id;
     Channel[i].priority = priority;
     Channel[i].volume = volume;
@@ -772,7 +771,7 @@ void S_UpdateSounds(mobj_t * listener)
                 if (sep > 192)
                     sep = 512 - sep;
             }
-            I_UpdateSoundParams(i, vol, sep /*, Channel[i].pitch */);
+            I_UpdateSoundParams(i, vol, sep);
             priority = S_sfx[Channel[i].sound_id].priority;
             priority *= PRIORITY_MAX_ADJUST - (dist / DIST_ADJUST);
             Channel[i].priority = priority;
diff --git a/src/i_sound.h b/src/i_sound.h
index 55af15d8..d1d4f407 100644
--- a/src/i_sound.h
+++ b/src/i_sound.h
@@ -46,7 +46,7 @@ struct sfxinfo_struct
     // referenced sound if a link
     sfxinfo_t *link;

-    // pitch if a link
+    // pitch if a link (Doom), whether to pitch-shift (Hexen)
     int pitch;

     // volume if a link