diff --git a/MacOSX/QuakeSpasm.xcodeproj/project.pbxproj b/MacOSX/QuakeSpasm.xcodeproj/project.pbxproj
index 10895131..012f8d3f 100644
--- a/MacOSX/QuakeSpasm.xcodeproj/project.pbxproj
+++ b/MacOSX/QuakeSpasm.xcodeproj/project.pbxproj
@@ -826,7 +826,10 @@
GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
- GCC_PREPROCESSOR_DEFINITIONS = SDL_FRAMEWORK;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ SDL_FRAMEWORK,
+ USE_CODEC_VORBIS,
+ );
GCC_VERSION = com.apple.compilers.llvmgcc42;
HEADER_SEARCH_PATHS = (
codecs/include,
@@ -859,7 +862,7 @@
"$(FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1)",
);
FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SRCROOT)\"";
- GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
+ GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
GCC_MODEL_TUNING = G5;
GCC_PREPROCESSOR_DEFINITIONS = (
USE_CODEC_MP3,
@@ -914,6 +917,7 @@
x86_64,
i386,
);
+ COPY_PHASE_STRIP = NO;
FRAMEWORK_SEARCH_PATHS = (
/Library/Frameworks,
"$(FRAMEWORK_SEARCH_PATHS)",
@@ -948,9 +952,9 @@
ARCHS = (
x86_64,
i386,
- ppc,
);
- DEPLOYMENT_POSTPROCESSING = YES;
+ COPY_PHASE_STRIP = NO;
+ DEPLOYMENT_POSTPROCESSING = NO;
FRAMEWORK_SEARCH_PATHS = (
/Library/Frameworks,
"$(FRAMEWORK_SEARCH_PATHS)",
@@ -1000,7 +1004,7 @@
"SDKROOT[arch=i386]" = "$(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk";
"SDKROOT[arch=ppc]" = "$(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk";
"SDKROOT[arch=x86_64]" = "$(DEVELOPER_SDK_DIR)/MacOSX10.6.sdk";
- VALID_ARCHS = "i386 x86_64 ppc";
+ VALID_ARCHS = "i386 x86_64";
};
name = Release;
};
diff --git a/MacOSX/QuakeSpasm.xcodeproj/xcshareddata/xcschemes/QuakeSpasm.xcscheme b/MacOSX/QuakeSpasm.xcodeproj/xcshareddata/xcschemes/QuakeSpasm.xcscheme
index 90de0538..d9dbfb1c 100644
--- a/MacOSX/QuakeSpasm.xcodeproj/xcshareddata/xcschemes/QuakeSpasm.xcscheme
+++ b/MacOSX/QuakeSpasm.xcodeproj/xcshareddata/xcschemes/QuakeSpasm.xcscheme
@@ -21,8 +21,8 @@
@@ -38,8 +38,8 @@
+
+
diff --git a/Quake/q_sound.h b/Quake/q_sound.h
index ace02814..7e560717 100644
--- a/Quake/q_sound.h
+++ b/Quake/q_sound.h
@@ -168,6 +168,7 @@ extern vec3_t listener_right;
extern vec3_t listener_up;
extern cvar_t sndspeed;
+extern cvar_t snd_mixspeed;
extern cvar_t sfxvolume;
extern cvar_t loadas8bit;
diff --git a/Quake/snd_dma.c b/Quake/snd_dma.c
index 2c4d57d0..542a0b65 100644
--- a/Quake/snd_dma.c
+++ b/Quake/snd_dma.c
@@ -76,6 +76,7 @@ cvar_t precache = {"precache", "1", CVAR_NONE};
cvar_t loadas8bit = {"loadas8bit", "0", CVAR_NONE};
cvar_t sndspeed = {"sndspeed", "11025", CVAR_NONE};
+cvar_t snd_mixspeed = {"snd_mixspeed", "44100", CVAR_NONE};
static cvar_t nosound = {"nosound", "0", CVAR_NONE};
static cvar_t ambient_level = {"ambient_level", "0.3", CVAR_NONE};
@@ -161,6 +162,7 @@ void S_Init (void)
Cvar_RegisterVariable(&snd_show);
Cvar_RegisterVariable(&_snd_mixahead);
Cvar_RegisterVariable(&sndspeed);
+ Cvar_RegisterVariable(&snd_mixspeed);
if (safemode || COM_CheckParm("-nosound"))
return;
@@ -178,6 +180,12 @@ void S_Init (void)
{
Cvar_SetQuick (&sndspeed, com_argv[i+1]);
}
+
+ i = COM_CheckParm("-mixspeed");
+ if (i && i < com_argc-1)
+ {
+ Cvar_SetQuick (&snd_mixspeed, com_argv[i+1]);
+ }
if (host_parms->memsize < 0x800000)
{
diff --git a/Quake/snd_mix.c b/Quake/snd_mix.c
index f5f791aa..15d75f80 100644
--- a/Quake/snd_mix.c
+++ b/Quake/snd_mix.c
@@ -149,6 +149,128 @@ static void S_TransferPaintBuffer (int endtime)
}
}
+/*
+==============
+S_MakeBlackmanWindowKernel
+
+Based on equation 16-4 from
+"The Scientist and Engineer's Guide to Digital Signal Processing"
+
+kernel has room for M+1 floats,
+f_c is the filter cutoff frequency, as a fraction of the samplerate
+==============
+*/
+static void S_MakeBlackmanWindowKernel(float *kernel, int M, float f_c)
+{
+ int i;
+ for (i = 0; i <= M; i++)
+ {
+ if (i == M/2)
+ {
+ kernel[i] = 2 * M_PI * f_c;
+ }
+ else
+ {
+ kernel[i] = ( sin(2 * M_PI * f_c * (i - M/2.0)) / (i - (M/2.0)) )
+ * (0.42 - 0.5*cos(2 * M_PI * i / (double)M)
+ + 0.08*cos(4 * M_PI * i / (double)M) );
+ }
+ }
+
+// normalize the kernel so all of the values sum to 1
+ {
+ float sum = 0;
+ for (i = 0; i <= M; i++)
+ {
+ sum += kernel[i];
+ }
+
+ for (i = 0; i <= M; i++)
+ {
+ kernel[i] /= sum;
+ }
+ }
+}
+
+// must be divisible by 4
+#define FILTER_KERNEL_SIZE 48
+
+/*
+==============
+S_LowpassFilter
+
+lowpass filters 24-bit integer samples in 'data' (stored in 32-bit ints).
+
+f_c is the filter cutoff frequency, as a fraction of the samplerate
+memory must be an array of FILTER_KERNEL_SIZE floats
+==============
+*/
+static void S_LowpassFilter(float f_c, int *data, int stride, int count,
+ float *memory)
+{
+ int i;
+
+// M is the "kernel size" parameter for makekernel() - must be even.
+// FILTER_KERNEL_SIZE size is M+1, rounded up to be divisible by 4
+ const int M = FILTER_KERNEL_SIZE - 2;
+
+ float input[FILTER_KERNEL_SIZE + count];
+
+ static float kernel[FILTER_KERNEL_SIZE];
+ static float kernel_fc;
+
+ if (f_c <= 0 || f_c > 0.5)
+ return;
+
+ if (count < FILTER_KERNEL_SIZE)
+ {
+ Con_Warning("S_LowpassFilter: not enough samples");
+ return;
+ }
+
+// prepare the kernel
+
+ if (kernel_fc != f_c)
+ {
+ S_MakeBlackmanWindowKernel(kernel, M, f_c);
+ kernel_fc = f_c;
+ }
+
+// set up the input buffer
+// memory holds the previous FILTER_KERNEL_SIZE samples of input.
+
+ for (i=0; i> 1;
+ paintbuffer[i].right = CLAMP(-32768 << 8, paintbuffer[i].right, 32767 << 8) >> 1;
+ }
+
+ // apply a lowpass filter
+ if (sndspeed.value < shm->speed)
+ {
+ static float memory_l[FILTER_KERNEL_SIZE];
+ static float memory_r[FILTER_KERNEL_SIZE];
+
+ const float cutoff_freq = (sndspeed.value * 0.45) / shm->speed;
+
+ S_LowpassFilter(cutoff_freq, (int *)paintbuffer, 2, end - paintedtime, memory_l);
+ S_LowpassFilter(cutoff_freq, ((int *)paintbuffer) + 1, 2, end - paintedtime, memory_r);
+ }
+
+ // paint in the music
+ if (s_rawend >= paintedtime)
+ { // copy from the streaming sound source
+ int s;
+ int stop;
+
+ stop = (end < s_rawend) ? end : s_rawend;
+
+ for (i = paintedtime; i < stop; i++)
+ {
+ s = i & (MAX_RAW_SAMPLES - 1);
+ // lower music by 6db to match sfx
+ paintbuffer[i - paintedtime].left += s_rawsamples[s].left >> 1;
+ paintbuffer[i - paintedtime].right += s_rawsamples[s].right >> 1;
+ }
+ // if (i != end)
+ // Con_Printf ("partial stream\n");
+ // else
+ // Con_Printf ("full stream\n");
+ }
+
// transfer out according to DMA format
S_TransferPaintBuffer(end);
paintedtime = end;
diff --git a/Quake/snd_sdl.c b/Quake/snd_sdl.c
index 8f554e38..6ffe97da 100644
--- a/Quake/snd_sdl.c
+++ b/Quake/snd_sdl.c
@@ -86,7 +86,7 @@ qboolean SNDDMA_Init (dma_t *dma)
}
/* Set up the desired format */
- desired.freq = tmp = sndspeed.value;
+ desired.freq = tmp = snd_mixspeed.value;
desired.format = (loadas8bit.value) ? AUDIO_U8 : AUDIO_S16SYS;
desired.channels = 2; /* = desired_channels; */
if (desired.freq <= 11025)