summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/i_sdlsound.c40
-rw-r--r--src/m_config.c13
2 files changed, 47 insertions, 6 deletions
diff --git a/src/i_sdlsound.c b/src/i_sdlsound.c
index 8ce6cab0..5a7de5bb 100644
--- a/src/i_sdlsound.c
+++ b/src/i_sdlsound.c
@@ -39,6 +39,7 @@
#endif
#include "deh_main.h"
+#include "i_system.h"
#include "s_sound.h"
#include "m_argv.h"
#include "w_wad.h"
@@ -93,6 +94,33 @@ static void ReleaseSoundOnChannel(int channel)
#ifdef HAVE_LIBSAMPLERATE
+// Returns the conversion mode for libsamplerate to use.
+
+static int SRC_ConversionMode(void)
+{
+ switch (use_libsamplerate)
+ {
+ // 0 = disabled
+
+ default:
+ case 0:
+ return -1;
+
+ // Ascending numbers give higher quality
+
+ case 1:
+ return SRC_LINEAR;
+ case 2:
+ return SRC_ZERO_ORDER_HOLD;
+ case 3:
+ return SRC_SINC_FASTEST;
+ case 4:
+ return SRC_SINC_MEDIUM_QUALITY;
+ case 5:
+ return SRC_SINC_BEST_QUALITY;
+ }
+}
+
// libsamplerate-based generic sound expansion function for any sample rate
// unsigned 8 bits --> signed 16 bits
// mono --> stereo
@@ -132,7 +160,7 @@ static uint32_t ExpandSoundData_SRC(byte *data,
// Do the sound conversion
- retn = src_simple(&src_data, SRC_SINC_BEST_QUALITY, 1);
+ retn = src_simple(&src_data, SRC_ConversionMode(), 1);
assert(retn == 0);
// Convert the result back into 16-bit integers.
@@ -614,14 +642,20 @@ static boolean I_SDL_InitSound(void)
Mix_QuerySpec(&mixer_freq, &mixer_format, &mixer_channels);
#ifdef HAVE_LIBSAMPLERATE
- if (use_libsamplerate)
+ if (use_libsamplerate != 0)
{
+ if (SRC_ConversionMode() < 0)
+ {
+ I_Error("I_SDL_InitSound: Invalid value for use_libsamplerate: %i",
+ use_libsamplerate);
+ }
+
ExpandSoundData = ExpandSoundData_SRC;
I_PrecacheSounds();
}
#else
- if (use_libsamplerate)
+ if (use_libsamplerate != 0)
{
fprintf(stderr, "I_SDL_InitSound: use_libsamplerate=%i, but "
"libsamplerate support not compiled in.\n",
diff --git a/src/m_config.c b/src/m_config.c
index 15ff2fde..4066cb3c 100644
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -697,9 +697,16 @@ static default_t extra_defaults_list[] =
CONFIG_VARIABLE_INT(dclick_use, dclick_use),
//!
- // If non-zero, libsamplerate is used to resample sound effects to
- // the output sample rate. This has no effect if libsamplerate
- // support has not been compiled into the game.
+ // Controls whether libsamplerate support is used for performing
+ // sample rate conversions of sound effects. Support for this
+ // must be compiled into the program.
+ //
+ // If zero, libsamplerate support is disabled. If non-zero,
+ // libsamplerate is enabled. Increasing values roughly correspond
+ // to higher quality conversion; the higher the quality, the
+ // slower the conversion process. Linear conversion = 1;
+ // Zero order hold = 2; Fast Sinc filter = 3; Medium quality
+ // Sinc filter = 4; High quality Sinc filter = 5.
//
CONFIG_VARIABLE_INT(use_libsamplerate, use_libsamplerate),