shithub: choc

Download patch

ref: 2c2bfe845a64e7b68a375f00f3c84a8378661b8c
parent: bb403e304ada52eee1921f577ba99dfb444d4e39
author: Jonathan Dowland <jon+github@alcopop.org>
date: Wed Jul 1 19:22:46 EDT 2015

Make pitch-shifting optional (default to off)

--- a/src/i_sdlsound.c
+++ b/src/i_sdlsound.c
@@ -951,13 +951,16 @@
             return -1;
         }
 
-        newsnd = PitchShift(snd, pitch);
-
-        if(newsnd)
+        if(snd_pitchshift)
         {
-            LockAllocatedSound(newsnd);
-            UnlockAllocatedSound(snd);
-            snd = newsnd;
+            newsnd = PitchShift(snd, pitch);
+
+            if(newsnd)
+            {
+                LockAllocatedSound(newsnd);
+                UnlockAllocatedSound(snd);
+                snd = newsnd;
+            }
         }
     }
     else
--- a/src/i_sound.c
+++ b/src/i_sound.c
@@ -48,6 +48,10 @@
 
 char *snd_musiccmd = "";
 
+// Whether to vary the pitch of sound effects
+
+int snd_pitchshift = 0;
+
 // Low-level sound and music modules we are using
 
 static sound_module_t *sound_module;
@@ -448,6 +452,7 @@
     M_BindIntVariable("snd_samplerate",          &snd_samplerate);
     M_BindIntVariable("snd_cachesize",           &snd_cachesize);
     M_BindIntVariable("opl_io_port",             &opl_io_port);
+    M_BindIntVariable("snd_pitchshift",          &snd_pitchshift);
 
     M_BindStringVariable("timidity_cfg_path",    &timidity_cfg_path);
     M_BindStringVariable("gus_patch_path",       &gus_patch_path);
--- a/src/i_sound.h
+++ b/src/i_sound.h
@@ -233,6 +233,7 @@
 extern int snd_cachesize;
 extern int snd_maxslicetime_ms;
 extern char *snd_musiccmd;
+extern int snd_pitchshift;
 
 void I_BindSoundVariables(void);
 
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -809,6 +809,14 @@
     CONFIG_VARIABLE_INT(snd_maxslicetime_ms),
 
     //!
+    // If non-zero, sound effects will have their pitch varied up or
+    // down by a random amount during play. If zero, sound effects
+    // play back at their default pitch. The default is zero.
+    //
+
+    CONFIG_VARIABLE_INT(snd_pitchshift),
+
+    //!
     // External command to invoke to perform MIDI playback. If set to
     // the empty string, SDL_mixer's internal MIDI playback is used.
     // This only has any effect when snd_musicdevice is set to General
--- a/src/setup/sound.c
+++ b/src/setup/sound.c
@@ -85,6 +85,7 @@
 int snd_cachesize = 64 * 1024 * 1024;
 int snd_maxslicetime_ms = 28;
 char *snd_musiccmd = "";
+int snd_pitchshift = 0;
 
 static int numChannels = 8;
 static int sfxVolume = 8;
@@ -314,6 +315,7 @@
                    TXT_NewSpinControl(&numChannels, 1, 8),
                    TXT_NewLabel("SFX volume"),
                    TXT_NewSpinControl(&sfxVolume, 0, 15),
+                   TXT_NewCheckBox("Pitch-shift sounds", &snd_pitchshift),
                    NULL);
 
     if (gamemission == strife)
@@ -379,6 +381,8 @@
 
     M_BindIntVariable("snd_cachesize",            &snd_cachesize);
     M_BindIntVariable("opl_io_port",              &opl_io_port);
+
+    M_BindIntVariable("snd_pitchshift",           &snd_pitchshift);
 
     if (gamemission == strife)
     {