commit 2c2bfe845a64e7b68a375f00f3c84a8378661b8c
Author: Jonathan Dowland <jon+github@alcopop.org>
AuthorDate: Wed Jul 1 23:22:46 2015 +0100
Commit: Jonathan Dowland <jon+github@alcopop.org>
CommitDate: Wed Jul 8 21:02:01 2015 +0100
Make pitch-shifting optional (default to off)
---
src/i_sdlsound.c | 15 +++++++++------
src/i_sound.c | 5 +++++
src/i_sound.h | 1 +
src/m_config.c | 8 ++++++++
src/setup/sound.c | 4 ++++
5 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/src/i_sdlsound.c b/src/i_sdlsound.c
index a1d4b87a..142b5b0a 100644
--- a/src/i_sdlsound.c
+++ b/src/i_sdlsound.c
@@ -951,13 +951,16 @@ static int I_SDL_StartSound(sfxinfo_t *sfxinfo, int channel, int vol, int sep, i
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
diff --git a/src/i_sound.c b/src/i_sound.c
index d27d253e..e7757d7a 100644
--- a/src/i_sound.c
+++ b/src/i_sound.c
@@ -48,6 +48,10 @@ int snd_maxslicetime_ms = 28;
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 @@ void I_BindSoundVariables(void)
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);
diff --git a/src/i_sound.h b/src/i_sound.h
index b8b03c80..55af15d8 100644
--- a/src/i_sound.h
+++ b/src/i_sound.h
@@ -233,6 +233,7 @@ extern int snd_samplerate;
extern int snd_cachesize;
extern int snd_maxslicetime_ms;
extern char *snd_musiccmd;
+extern int snd_pitchshift;
void I_BindSoundVariables(void);
diff --git a/src/m_config.c b/src/m_config.c
index a993eebd..3393b57f 100644
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -808,6 +808,14 @@ static default_t extra_defaults_list[] =
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.
diff --git a/src/setup/sound.c b/src/setup/sound.c
index fe9b2c78..3f6a3871 100644
--- a/src/setup/sound.c
+++ b/src/setup/sound.c
@@ -85,6 +85,7 @@ int opl_io_port = 0x388;
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 @@ void ConfigSound(void)
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)
@@ -380,6 +382,8 @@ void BindSoundVariables(void)
M_BindIntVariable("snd_cachesize", &snd_cachesize);
M_BindIntVariable("opl_io_port", &opl_io_port);
+ M_BindIntVariable("snd_pitchshift", &snd_pitchshift);
+
if (gamemission == strife)
{
M_BindIntVariable("voice_volume", &voiceVolume);