Some few changes

This commit is contained in:
Steel Titanium 2019-01-05 23:42:25 -05:00
parent db71ba71c9
commit 7d1e59d4ba
3 changed files with 30 additions and 17 deletions

View file

@ -42,10 +42,6 @@ extern INT32 msg_id;
#include "lua_hook.h" // MusicChange hook #include "lua_hook.h" // MusicChange hook
#endif #endif
#ifdef HAVE_OPENMPT
#include "libopenmpt/libopenmpt.h"
#endif
#ifdef HW3SOUND #ifdef HW3SOUND
// 3D Sound Interface // 3D Sound Interface
#include "hardware/hw3sound.h" #include "hardware/hw3sound.h"
@ -63,6 +59,8 @@ static void GameMIDIMusic_OnChange(void);
static void GameSounds_OnChange(void); static void GameSounds_OnChange(void);
static void GameDigiMusic_OnChange(void); static void GameDigiMusic_OnChange(void);
static void ModFilter_OnChange(void);
// commands for music and sound servers // commands for music and sound servers
#ifdef MUSSERV #ifdef MUSSERV
consvar_t musserver_cmd = {"musserver_cmd", "musserver", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t musserver_cmd = {"musserver_cmd", "musserver", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL};
@ -114,7 +112,7 @@ consvar_t cv_gamesounds = {"sounds", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff,
#ifdef HAVE_OPENMPT #ifdef HAVE_OPENMPT
static CV_PossibleValue_t interpolationfilter_cons_t[] = {{0, "Default"}, {1, "None"}, {2, "Linear"}, {4, "Cubic"}, {8, "Windowed sinc"}, {0, NULL}}; static CV_PossibleValue_t interpolationfilter_cons_t[] = {{0, "Default"}, {1, "None"}, {2, "Linear"}, {4, "Cubic"}, {8, "Windowed sinc"}, {0, NULL}};
consvar_t cv_modfilter = {"modfilter", "0", CV_SAVE, interpolationfilter_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_modfilter = {"modfilter", "0", CV_SAVE|CV_CALL, interpolationfilter_cons_t, ModFilter_OnChange, 0, NULL, NULL, 0, 0, NULL};
#endif #endif
#define S_MAX_VOLUME 127 #define S_MAX_VOLUME 127
@ -281,11 +279,6 @@ void S_RegisterSoundStuff(void)
COM_AddCommand("tunes", Command_Tunes_f); COM_AddCommand("tunes", Command_Tunes_f);
COM_AddCommand("restartaudio", Command_RestartAudio_f); COM_AddCommand("restartaudio", Command_RestartAudio_f);
#ifdef HAVE_OPENMPT
CV_RegisterVar(&cv_modfilter);
#endif
#if defined (macintosh) && !defined (HAVE_SDL) // mp3 playlist stuff #if defined (macintosh) && !defined (HAVE_SDL) // mp3 playlist stuff
{ {
INT32 i; INT32 i;
@ -1855,3 +1848,9 @@ void GameMIDIMusic_OnChange(void)
} }
} }
} }
void ModFilter_OnChange(void)
{
if (mod)
openmpt_module_set_render_param(mod, OPENMPT_MODULE_RENDER_INTERPOLATIONFILTER_LENGTH, cv_modfilter.value);
}

View file

@ -20,6 +20,11 @@
#include "command.h" #include "command.h"
#include "tables.h" // angle_t #include "tables.h" // angle_t
#ifdef HAVE_OPENMPT
#include "libopenmpt/libopenmpt.h"
openmpt_module *mod;
#endif
// mask used to indicate sound origin is player item pickup // mask used to indicate sound origin is player item pickup
#define PICKUP_SOUND 0x8000 #define PICKUP_SOUND 0x8000

View file

@ -108,7 +108,6 @@ static UINT16 current_track;
#endif #endif
#ifdef HAVE_OPENMPT #ifdef HAVE_OPENMPT
static openmpt_module *mod = 0;
int mod_err = OPENMPT_ERROR_OK; int mod_err = OPENMPT_ERROR_OK;
static const char *mod_err_str; static const char *mod_err_str;
static UINT16 current_subsong; static UINT16 current_subsong;
@ -652,9 +651,13 @@ static void mix_gme(void *udata, Uint8 *stream, int len)
// play gme into stream // play gme into stream
gme_play(gme, len/2, (short *)stream); gme_play(gme, len/2, (short *)stream);
// Limiter to prevent music from being disorted with some formats
if (music_volume >= 18)
music_volume = 18;
// apply volume to stream // apply volume to stream
for (i = 0, p = (short *)stream; i < len/2; i++, p++) for (i = 0, p = (short *)stream; i < len/2; i++, p++)
*p = ((INT32)*p) * (music_volume*internal_volume/100)*2 / 42; *p = ((INT32)*p) * (music_volume*internal_volume/100)*2 / 40;
} }
#endif #endif
@ -664,18 +667,20 @@ static void mix_openmpt(void *udata, Uint8 *stream, int len)
int i; int i;
short *p; short *p;
(void)udata;
if (!mod || songpaused) if (!mod || songpaused)
return; return;
(void)udata;
openmpt_module_set_render_param(mod, OPENMPT_MODULE_RENDER_INTERPOLATIONFILTER_LENGTH, cv_modfilter.value);
openmpt_module_set_repeat_count(mod, -1); // Always repeat
openmpt_module_read_interleaved_stereo(mod, SAMPLERATE, BUFFERSIZE, (short *)stream); openmpt_module_read_interleaved_stereo(mod, SAMPLERATE, BUFFERSIZE, (short *)stream);
// Limiter to prevent music from being disorted with some formats
if (music_volume >= 18)
music_volume = 18;
// apply volume to stream // apply volume to stream
for (i = 0, p = (short *)stream; i < len/2; i++, p++) for (i = 0, p = (short *)stream; i < len/2; i++, p++)
*p = ((INT32)*p) * (music_volume*internal_volume/100) / 31; *p = ((INT32)*p) * (music_volume*internal_volume/100)*2 / 40;
} }
#endif #endif
@ -1160,6 +1165,7 @@ boolean I_LoadSong(char *data, size_t len)
case MUS_MID: case MUS_MID:
case MUS_OGG: case MUS_OGG:
case MUS_MP3: case MUS_MP3:
case MUS_FLAC:
Mix_HookMusic(NULL, NULL); Mix_HookMusic(NULL, NULL);
break; break;
default: default:
@ -1295,6 +1301,9 @@ boolean I_PlaySong(boolean looping)
if (mod) if (mod)
{ {
openmpt_module_select_subsong(mod, 0); openmpt_module_select_subsong(mod, 0);
openmpt_module_set_render_param(mod, OPENMPT_MODULE_RENDER_INTERPOLATIONFILTER_LENGTH, cv_modfilter.value);
if (looping)
openmpt_module_set_repeat_count(mod, -1); // Always repeat
current_subsong = 0; current_subsong = 0;
Mix_HookMusic(mix_openmpt, mod); Mix_HookMusic(mix_openmpt, mod);
return true; return true;