###### Sound #####
-OBJ_SND_COMMON=snd_main.o snd_mem.o snd_mix.o snd_ogg.o snd_wav.o
+OBJ_SND_COMMON=snd_main.o snd_mem.o snd_mix.o snd_ogg.o snd_wav.o $(OBJ_SND_XMP)
# No sound
OBJ_SND_NULL=snd_null.o
# Open Sound System (Linux, FreeBSD and Solaris)
OBJ_SND_OSS=$(OBJ_SND_COMMON) snd_oss.o
-LIB_SND_OSS=$(LIB_SND_XMP)
+LIB_SND_OSS=
# Advanced Linux Sound Architecture (Linux)
OBJ_SND_ALSA=$(OBJ_SND_COMMON) snd_alsa.o
-LIB_SND_ALSA=-lasound $(LIB_SND_XMP)
+LIB_SND_ALSA=-lasound
# Core Audio (Mac OS X)
OBJ_SND_COREAUDIO=$(OBJ_SND_COMMON) snd_coreaudio.o
-LIB_SND_COREAUDIO=-framework CoreAudio $(LIB_SND_XMP)
+LIB_SND_COREAUDIO=-framework CoreAudio
# BSD / Sun audio API (NetBSD and OpenBSD)
OBJ_SND_BSD=$(OBJ_SND_COMMON) snd_bsd.o
-LIB_SND_BSD=$(LIB_SND_XMP)
+LIB_SND_BSD=
# DirectX and Win32 WAVE output (Win32)
OBJ_SND_WIN=$(OBJ_SND_COMMON) snd_win.o
-LIB_SND_WIN=$(LIB_SND_XMP)
+LIB_SND_WIN=
###### Common objects and flags #####
$(CHECKLEVEL2)
$(DO_CC) $(CFLAGS_SSE)
+snd_xmp.o: snd_xmp.c
+ $(CHECKLEVEL2)
+ $(DO_CC) $(CFLAGS_SND_XMP)
+
+#this checks USEXMP when compiling so it needs the XMP flags as well
+snd_main.o: snd_main.c
+ $(CHECKLEVEL2)
+ $(DO_CC) $(CFLAGS_SND_XMP)
+
+#this checks USEXMP when compiling so it needs the XMP flags as well
+snd_mem.o: snd_mem.c
+ $(CHECKLEVEL2)
+ $(DO_CC) $(CFLAGS_SND_XMP)
+
darkplaces.o: %.o : %.rc
$(CHECKLEVEL2)
$(WINDRES) -o $@ $<
//#define XMP_MAX_ENV_POINTS 32 /* Max number of envelope points */
#define XMP_MAX_MOD_LENGTH 256 /* Max number of patterns in module */
//#define XMP_MAX_CHANNELS 64 /* Max number of channels in module */
-//#define XMP_MAX_SRATE 49170 /* max sampling rate (Hz) */
-//#define XMP_MIN_SRATE 4000 /* min sampling rate (Hz) */
+#define XMP_MAX_SRATE 49170 /* max sampling rate (Hz) */
+#define XMP_MIN_SRATE 4000 /* min sampling rate (Hz) */
//#define XMP_MIN_BPM 20 /* min BPM */
#define XMP_MAX_FRAMESIZE (5 * XMP_MAX_SRATE * 2 / XMP_MIN_BPM)
}
// start playing the loaded file
- if (sfx->format.width == 1) { format |= XMP_FORMAT_8BIT; } // else 16bit
+ if (sfx->format.width == 1) { format |= XMP_FORMAT_8BIT | XMP_FORMAT_UNSIGNED; } // else 16bit
if (sfx->format.channels == 1) { format |= XMP_FORMAT_MONO; } // else stereo
- if (qxmp_start_player(per_ch->playercontext, sfx->format.speed, format) < 0) // FIXME: only if speed is in XMP acceptable range, else default to 48khz and let DP mix
+
+ if (qxmp_start_player(per_ch->playercontext, sfx->format.speed, format) < 0)
+ {
+ Mem_Free(per_ch);
+ return;
+ }
+ /* percentual left/right channel separation, default is 70. */
+ if (sfx->format.channels == 2 && (qxmp_set_player(per_ch->playercontext, XMP_PLAYER_MIX, 50) != 0))
+ {
+ Mem_Free(per_ch);
+ return;
+ }
+ /* interpolation type, default is XMP_INTERP_LINEAR */
+ if (qxmp_set_player(per_ch->playercontext, XMP_PLAYER_INTERP, XMP_INTERP_SPLINE) != 0)
{
Mem_Free(per_ch);
return;
// set dp sfx
sfx->memsize += sizeof(*per_sfx);
sfx->memsize += filesize; // total memory used (including sfx_t and fetcher data)
-// sfx->format // format describing the audio data that fetcher->getsamplesfloat shall return
- sfx->format.speed = 48000; // default to this sample rate
- sfx->format.width = 2; // default to 16 bit samples
-// sfx->format.width = 1; // 8-bit
- sfx->format.channels = 2; // default to stereo
-// sfx->format.channels = 1; // mono
+ if (S_GetSoundRate() > XMP_MAX_SRATE)
+ sfx->format.speed = 48000;
+ else if (S_GetSoundRate() < XMP_MIN_SRATE)
+ sfx->format.speed = 8000;
+ else
+ sfx->format.speed = S_GetSoundRate();
+ sfx->format.width = S_GetSoundWidth(); // 2 = 16 bit samples
+ sfx->format.channels = S_GetSoundChannels();
sfx->flags |= SFXFLAG_STREAMED; // cf SFXFLAG_* defines
-// sfx->total_length // in (pcm) sample frames
- sfx->total_length = 1<<30; // 2147384647; // they always loop (FIXME this breaks after 6 hours, we need support for a real "infinite" value!)
+ sfx->total_length = 1<<30; // 2147384647; // in (pcm) sample frames - they always loop (FIXME this breaks after 6 hours, we need support for a real "infinite" value!)
sfx->loopstart = sfx->total_length; // (modplug does it) in sample frames. equals total_length if not looped
sfx->fetcher_data = per_sfx;
sfx->fetcher = &xmp_fetcher;
-// sfx->volume_mult // for replay gain (multiplier to apply)
-// sfx->volume_peak // for replay gain (highest peak); if set to 0, ReplayGain isn't supported
+ sfx->volume_peak = 0;
qxmp_get_module_info(xc, &mi);
if (developer_loading.integer >= 2)