Merge branch 'tinnitus' into 'master'

Reduce song and sound volume

See merge request KartKrew/Kart!316
This commit is contained in:
James R 2020-09-25 16:59:47 -04:00
commit 2ec6038793
12 changed files with 104 additions and 255 deletions

View file

@ -130,15 +130,9 @@ INT32 postimgparam[MAXSPLITSCREENPLAYERS];
// whether the respective sound system is disabled
// or they're init'ed, but the player just toggled them
#ifdef _XBOX
#ifndef NO_MIDI
boolean midi_disabled = true;
#endif
boolean sound_disabled = true;
boolean digital_disabled = true;
#else
#ifndef NO_MIDI
boolean midi_disabled = false;
#endif
boolean sound_disabled = false;
boolean digital_disabled = false;
#endif
@ -1388,17 +1382,11 @@ void D_SRB2Main(void)
{
sound_disabled = true;
digital_disabled = true;
#ifndef NO_MIDI
midi_disabled = true;
#endif
}
if (M_CheckParm("-noaudio")) // combines -nosound and -nomusic
{
sound_disabled = true;
digital_disabled = true;
#ifndef NO_MIDI
midi_disabled = true;
#endif
}
else
{
@ -1407,25 +1395,14 @@ void D_SRB2Main(void)
if (M_CheckParm("-nomusic")) // combines -nomidimusic and -nodigmusic
{
digital_disabled = true;
#ifndef NO_MIDI
midi_disabled = true;
#endif
}
else
{
#ifndef NO_MIDI
if (M_CheckParm("-nomidimusic"))
midi_disabled = true; // WARNING: DOS version initmusic in I_StartupSound
#endif
if (M_CheckParm("-nodigmusic"))
digital_disabled = true; // WARNING: DOS version initmusic in I_StartupSound
}
}
if (!( sound_disabled && digital_disabled
#ifndef NO_MIDI
&& midi_disabled
#endif
))
if (!( sound_disabled && digital_disabled ))
{
CONS_Printf("S_InitSfxChannels(): Setting up sound channels.\n");
I_StartupSound();

View file

@ -1106,9 +1106,6 @@ void D_RegisterClientCommands(void)
// s_sound.c
CV_RegisterVar(&cv_soundvolume);
CV_RegisterVar(&cv_digmusicvolume);
#ifndef NO_MIDI
CV_RegisterVar(&cv_midimusicvolume);
#endif
CV_RegisterVar(&cv_numChannels);
// i_cdmus.c

View file

@ -636,9 +636,6 @@ extern const char *compdate, *comptime, *comprevision, *compbranch;
/// SRB2Kart: Camera always has noclip.
#define NOCLIPCAM
/// SRB2Kart: MIDI support is shitty and busted and we don't want it, lets throw it behind a define
#define NO_MIDI
/// FINALLY some real clipping that doesn't make walls dissappear AND speeds the game up
/// (that was the original comment from SRB2CB, sadly it is a lie and actually slows game down)
/// on the bright side it fixes some weird issues with translucent walls
@ -649,6 +646,11 @@ extern const char *compdate, *comptime, *comprevision, *compbranch;
/// Hardware renderer: OpenGL
#define GL_SHADERS
/// Divide volume of music and sounds by this much (loudest sounds on earth)
#define VOLUME_DIVIDER 4
#define USER_VOLUME_SCALE 2
#define MAX_VOLUME ( 100 * VOLUME_DIVIDER / USER_VOLUME_SCALE )
#if defined (HAVE_CURL) && ! defined (NONET)
#define MASTERSERVER
#else

View file

@ -110,11 +110,6 @@ extern boolean forceresetplayers, deferencoremode;
// Internal parameters for sound rendering.
// ========================================
#ifdef NO_MIDI
#define midi_disabled true
#else
extern boolean midi_disabled;
#endif
extern boolean sound_disabled;
extern boolean digital_disabled;

View file

@ -24,7 +24,6 @@ typedef enum {
MU_CMD,
MU_WAV,
MU_MOD,
MU_MID,
MU_OGG,
MU_MP3,
MU_MP3_MAD_UNUSED, // use MU_MP3 instead
@ -118,7 +117,7 @@ void I_UpdateSoundParams(INT32 handle, UINT8 vol, UINT8 sep, UINT8 pitch);
\return void
*/
void I_SetSfxVolume(UINT8 volume);
void I_SetSfxVolume(int volume);
/// ------------------------
// MUSIC SYSTEM
@ -227,7 +226,7 @@ void I_ResumeSong(void);
\return void
*/
void I_SetMusicVolume(UINT8 volume);
void I_SetMusicVolume(int volume);
boolean I_SetSongTrack(INT32 track);

View file

@ -1955,8 +1955,6 @@ static int lib_sMusicInfo(lua_State *L)
static int lib_sMusicExists(lua_State *L)
{
boolean checkMIDI = lua_opttrueboolean(L, 2);
boolean checkDigi = lua_opttrueboolean(L, 3);
#ifdef MUSICSLOT_COMPATIBILITY
const char *music_name;
UINT32 music_num;
@ -1985,7 +1983,7 @@ static int lib_sMusicExists(lua_State *L)
const char *music_name = luaL_checkstring(L, 1);
#endif
NOHUD
lua_pushboolean(L, S_MusicExists(music_name, checkMIDI, checkDigi));
lua_pushboolean(L, S_MusicExists(music_name));
return 1;
}

View file

@ -2379,6 +2379,11 @@ static void M_ChangeCvar(INT32 choice)
||((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_INVISSLIDER)
||((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_NOMOD))
{
if (cv == &cv_digmusicvolume || cv == &cv_soundvolume)
{
choice *= 5;
}
CV_SetValue(cv,cv->value+choice);
}
else if (cv->flags & CV_FLOAT)

View file

@ -49,15 +49,12 @@ extern INT32 msg_id;
static INT32 S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, INT32 *vol, INT32 *sep, INT32 *pitch, sfxinfo_t *sfxinfo);
#endif
CV_PossibleValue_t soundvolume_cons_t[] = {{0, "MIN"}, {31, "MAX"}, {0, NULL}};
CV_PossibleValue_t soundvolume_cons_t[] = {{0, "MIN"}, {MAX_VOLUME, "MAX"}, {0, NULL}};
static void SetChannelsNum(void);
static void Command_Tunes_f(void);
static void Command_RestartAudio_f(void);
// Sound system toggles
#ifndef NO_MIDI
static void GameMIDIMusic_OnChange(void);
#endif
static void GameSounds_OnChange(void);
static void GameDigiMusic_OnChange(void);
@ -95,11 +92,8 @@ consvar_t stereoreverse = {"stereoreverse", "Off", CV_SAVE, CV_OnOff, NULL, 0, N
static consvar_t precachesound = {"precachesound", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
// actual general (maximum) sound & music volume, saved into the config
consvar_t cv_soundvolume = {"soundvolume", "18", CV_SAVE, soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_digmusicvolume = {"digmusicvolume", "18", CV_SAVE, soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
#ifndef NO_MIDI
consvar_t cv_midimusicvolume = {"midimusicvolume", "18", CV_SAVE, soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
#endif
consvar_t cv_soundvolume = {"soundvolume", "50", CV_SAVE, soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_digmusicvolume = {"musicvolume", "50", CV_SAVE, soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
// number of channels available
#if defined (_WIN32_WCE) || defined (DC) || defined (PSP) || defined(GP2X)
consvar_t cv_numChannels = {"snd_channels", "8", CV_SAVE|CV_CALL, CV_Unsigned, SetChannelsNum, 0, NULL, NULL, 0, 0, NULL};
@ -112,9 +106,6 @@ consvar_t surround = {"surround", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL,
// Sound system toggles, saved into the config
consvar_t cv_gamedigimusic = {"digimusic", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, GameDigiMusic_OnChange, 0, NULL, NULL, 0, 0, NULL};
#ifndef NO_MIDI
consvar_t cv_gamemidimusic = {"midimusic", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, GameMIDIMusic_OnChange, 0, NULL, NULL, 0, 0, NULL};
#endif
consvar_t cv_gamesounds = {"sounds", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, GameSounds_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_playmusicifunfocused = {"playmusicifunfocused", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, PlayMusicIfUnfocused_OnChange, 0, NULL, NULL, 0, 0, NULL};
@ -130,8 +121,6 @@ consvar_t cv_music_resync_threshold = {"music_resync_threshold", "100", CV_SAVE|
consvar_t cv_music_resync_powerups_only = {"music_resync_powerups_only", "No", CV_SAVE|CV_CALL, CV_YesNo, I_UpdateSongLagConditions, 0, NULL, NULL, 0, 0, NULL};
#define S_MAX_VOLUME 127
// when to clip out sounds
// Does not fit the large outdoor areas.
// added 2-2-98 in 8 bit volume control (before (1200*0x10000))
@ -289,9 +278,6 @@ void S_RegisterSoundStuff(void)
//CV_RegisterVar(&cv_resetmusic);
CV_RegisterVar(&cv_gamesounds);
CV_RegisterVar(&cv_gamedigimusic);
#ifndef NO_MIDI
CV_RegisterVar(&cv_gamemidimusic);
#endif
CV_RegisterVar(&cv_playmusicifunfocused);
CV_RegisterVar(&cv_playsoundifunfocused);
@ -907,9 +893,6 @@ void S_StopSound(void *origin)
//
static INT32 actualsfxvolume; // check for change through console
static INT32 actualdigmusicvolume;
#ifndef NO_MIDI
static INT32 actualmidimusicvolume;
#endif
void S_UpdateSounds(void)
{
@ -936,10 +919,6 @@ void S_UpdateSounds(void)
S_SetSfxVolume (cv_soundvolume.value);
if (actualdigmusicvolume != cv_digmusicvolume.value)
S_SetDigMusicVolume (cv_digmusicvolume.value);
#ifndef NO_MIDI
if (actualmidimusicvolume != cv_midimusicvolume.value)
S_SetMIDIMusicVolume (cv_midimusicvolume.value);
#endif
// We're done now, if we're not in a level.
if (gamestate != GS_LEVEL)
@ -1174,17 +1153,14 @@ void S_UpdateSounds(void)
void S_SetSfxVolume(INT32 volume)
{
if (volume < 0 || volume > 31)
CONS_Alert(CONS_WARNING, "sfxvolume should be between 0-31\n");
CV_SetValue(&cv_soundvolume, volume&0x1F);
actualsfxvolume = cv_soundvolume.value; // check for change of var
CV_SetValue(&cv_soundvolume, volume);
actualsfxvolume = cv_soundvolume.value * USER_VOLUME_SCALE;
#ifdef HW3SOUND
hws_mode == HWS_DEFAULT_MODE ? I_SetSfxVolume(volume&0x1F) : HW3S_SetSfxVolume(volume&0x1F);
#else
// now hardware volume
I_SetSfxVolume(volume&0x1F);
I_SetSfxVolume(volume);
#endif
}
@ -1580,6 +1556,7 @@ static UINT32 queue_fadeinms;
musicdef_t *musicdefstart = NULL; // First music definition
struct cursongcredit cursongcredit; // Currently displayed song credit info
int musicdef_volume;
//
// search for music definition in wad
@ -1688,6 +1665,8 @@ void S_LoadMusicDefs(UINT16 wadnum)
}
}
def->volume = DEFAULT_MUSICDEF_VOLUME;
skip_lump:
stoken = strtok(NULL, "\r\n ");
line++;
@ -1722,6 +1701,8 @@ skip_lump:
for (value = def->source; *value; value++)
if (*value == '_') *value = ' '; // turn _ into spaces.
//CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source);
} else if (!stricmp(stoken, "volume")) {
def->volume = atoi(value);
} else {
CONS_Alert(CONS_WARNING, "MUSICDEF: Invalid field '%s'. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line);
}
@ -1787,14 +1768,9 @@ boolean S_DigMusicDisabled(void)
return digital_disabled;
}
boolean S_MIDIMusicDisabled(void)
{
return midi_disabled; // SRB2Kart: defined as "true" w/ NO_MIDI
}
boolean S_MusicDisabled(void)
{
return (midi_disabled && digital_disabled);
return digital_disabled;
}
boolean S_MusicPlaying(void)
@ -1830,12 +1806,9 @@ boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping)
return (boolean)mname[0];
}
boolean S_MusicExists(const char *mname, boolean checkMIDI, boolean checkDigi)
boolean S_MusicExists(const char *mname)
{
return (
(checkDigi ? W_CheckNumForName(va("O_%s", mname)) != LUMPERROR : false)
|| (checkMIDI ? W_CheckNumForName(va("D_%s", mname)) != LUMPERROR : false)
);
return W_CheckNumForName(va("O_%s", mname)) != LUMPERROR;
}
/// ------------------------
@ -1890,22 +1863,11 @@ static boolean S_LoadMusic(const char *mname)
if (!S_DigMusicDisabled() && S_DigExists(mname))
mlumpnum = W_GetNumForName(va("o_%s", mname));
else if (!S_MIDIMusicDisabled() && S_MIDIExists(mname))
mlumpnum = W_GetNumForName(va("d_%s", mname));
else if (S_DigMusicDisabled() && S_DigExists(mname))
{
CONS_Alert(CONS_NOTICE, "Digital music is disabled!\n");
return false;
}
else if (S_MIDIMusicDisabled() && S_MIDIExists(mname))
{
#ifdef NO_MIDI
CONS_Alert(CONS_ERROR, "A MIDI music lump %.6s was found,\nbut SRB2Kart does not support MIDI output.\nWe apologise for the inconvenience.\n", mname);
#else
CONS_Alert(CONS_NOTICE, "MIDI music is disabled!\n");
#endif
return false;
}
else
{
CONS_Alert(CONS_ERROR, M_GetText("Music lump %.6s not found!\n"), mname);
@ -2049,6 +2011,19 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32
music_flags = mflags;
music_looping = looping;
musicdef_volume = DEFAULT_MUSICDEF_VOLUME;
{
musicdef_t *def;
for (def = musicdefstart; def; def = def->next)
{
if (strcasecmp(def->name, music_name) == 0)
{
musicdef_volume = def->volume;
}
}
}
if (!S_PlayMusic(looping, fadeinms))
{
CONS_Alert(CONS_ERROR, "Music %.6s could not be played!\n", newmusic);
@ -2142,50 +2117,19 @@ void S_EnableSound(void)
}
}
void S_SetMusicVolume(INT32 digvolume, INT32 seqvolume)
void S_SetMusicVolume(INT32 digvolume)
{
if (digvolume < 0)
digvolume = cv_digmusicvolume.value;
#ifdef NO_MIDI
(void)seqvolume;
#else
if (seqvolume < 0)
seqvolume = cv_midimusicvolume.value;
#endif
if (digvolume < 0 || digvolume > 31)
CONS_Alert(CONS_WARNING, "digmusicvolume should be between 0-31\n");
CV_SetValue(&cv_digmusicvolume, digvolume&31);
actualdigmusicvolume = cv_digmusicvolume.value; //check for change of var
#ifndef NO_MIDI
if (seqvolume < 0 || seqvolume > 31)
CONS_Alert(CONS_WARNING, "midimusicvolume should be between 0-31\n");
CV_SetValue(&cv_midimusicvolume, seqvolume&31);
actualmidimusicvolume = cv_midimusicvolume.value; //check for change of var
#endif
CV_SetValue(&cv_digmusicvolume, digvolume);
actualdigmusicvolume = cv_digmusicvolume.value * USER_VOLUME_SCALE;
#ifdef DJGPPDOS
digvolume = 31;
#ifndef NO_MIDI
seqvolume = 31;
#endif
#endif
switch(I_SongType())
{
#ifndef NO_MIDI
case MU_MID:
//case MU_MOD:
//case MU_GME:
I_SetMusicVolume(seqvolume&31);
break;
#endif
default:
I_SetMusicVolume(digvolume&31);
break;
}
I_SetMusicVolume(digvolume);
}
void
@ -2362,11 +2306,7 @@ static void Command_RestartAudio_f(void)
// These must be called or no sound and music until manually set.
I_SetSfxVolume(cv_soundvolume.value);
#ifdef NO_MIDI
S_SetMusicVolume(cv_digmusicvolume.value, -1);
#else
S_SetMusicVolume(cv_digmusicvolume.value, cv_midimusicvolume.value);
#endif
S_SetMusicVolume(cv_digmusicvolume.value);
S_StartSound(NULL, sfx_strpst);
@ -2410,71 +2350,10 @@ void GameDigiMusic_OnChange(void)
else
{
digital_disabled = true;
if (S_MusicType() != MU_MID)
{
if (midi_disabled)
S_StopMusic();
else
{
char mmusic[7];
UINT16 mflags;
boolean looping;
if (S_MusicInfo(mmusic, &mflags, &looping) && S_MIDIExists(mmusic))
{
S_StopMusic();
S_ChangeMusic(mmusic, mflags, looping);
}
else
S_StopMusic();
}
}
S_StopMusic();
}
}
#ifndef NO_MIDI
void GameMIDIMusic_OnChange(void)
{
if (M_CheckParm("-nomusic") || M_CheckParm("-noaudio"))
return;
else if (M_CheckParm("-nomidimusic"))
return;
if (midi_disabled)
{
midi_disabled = false;
I_InitMusic();
if (Playing())
P_RestoreMusic(&players[consoleplayer]);
else
S_ChangeMusicInternal("titles", looptitle);
}
else
{
midi_disabled = true;
if (S_MusicType() == MU_MID)
{
if (digital_disabled)
S_StopMusic();
else
{
char mmusic[7];
UINT16 mflags;
boolean looping;
if (S_MusicInfo(mmusic, &mflags, &looping) && S_DigExists(mmusic))
{
S_StopMusic();
S_ChangeMusic(mmusic, mflags, looping);
}
else
S_StopMusic();
}
}
}
}
#endif
static void PlayMusicIfUnfocused_OnChange(void)
{
if (window_notinfocus)

View file

@ -23,15 +23,18 @@
// mask used to indicate sound origin is player item pickup
#define PICKUP_SOUND 0x8000
//
#define SOUND_VOLUME_RANGE 256
#define MAX_SOUND_VOLUME 255
#define DEFAULT_MUSICDEF_VOLUME ( 100 / VOLUME_DIVIDER )
extern consvar_t stereoreverse;
extern consvar_t cv_soundvolume, cv_digmusicvolume;//, cv_midimusicvolume;
extern consvar_t cv_numChannels;
extern consvar_t surround;
//extern consvar_t cv_resetmusic;
extern consvar_t cv_gamedigimusic;
#ifndef NO_MIDI
extern consvar_t cv_gamemidimusic;
#endif
extern consvar_t cv_gamesounds;
extern consvar_t cv_playmusicifunfocused;
extern consvar_t cv_playsoundifunfocused;
@ -115,16 +118,14 @@ void S_StopSound(void *origin);
//
boolean S_DigMusicDisabled(void);
boolean S_MIDIMusicDisabled(void);
boolean S_MusicDisabled(void);
boolean S_MusicPlaying(void);
boolean S_MusicPaused(void);
musictype_t S_MusicType(void);
const char *S_MusicName(void);
boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping);
boolean S_MusicExists(const char *mname, boolean checkMIDI, boolean checkDigi);
#define S_DigExists(a) S_MusicExists(a, false, true)
#define S_MIDIExists(a) S_MusicExists(a, true, false)
boolean S_MusicExists(const char *mname);
#define S_DigExists S_MusicExists
//
// Music Effects
@ -139,6 +140,7 @@ typedef struct musicdef_s
char name[7];
//char usage[256];
char source[256];
int volume;
struct musicdef_s *next;
} musicdef_t;
@ -151,6 +153,7 @@ extern struct cursongcredit
} cursongcredit;
extern musicdef_t *musicdefstart;
extern int musicdef_volume;
void S_LoadMusicDefs(UINT16 wadnum);
void S_InitMusicDefs(void);
@ -232,10 +235,9 @@ void S_UpdateSounds(void);
FUNCMATH fixed_t S_CalculateSoundDistance(fixed_t px1, fixed_t py1, fixed_t pz1, fixed_t px2, fixed_t py2, fixed_t pz2);
void S_SetSfxVolume(INT32 volume);
void S_SetMusicVolume(INT32 digvolume, INT32 seqvolume);
#define S_SetDigMusicVolume(a) S_SetMusicVolume(a,-1)
#define S_SetMIDIMusicVolume(a) S_SetMusicVolume(-1,a)
#define S_InitMusicVolume() S_SetMusicVolume(-1,-1)
void S_SetMusicVolume(INT32 digvolume);
#define S_SetDigMusicVolume S_SetMusicVolume
#define S_InitMusicVolume() S_SetMusicVolume(-1)
INT32 S_OriginPlaying(void *origin);
INT32 S_IdPlaying(sfxenum_t id);

View file

@ -84,7 +84,9 @@ static UINT32 stutter_threshold_user;
static UINT32 stutter_threshold;
static Mix_Music *music;
static UINT8 music_volume, sfx_volume, internal_volume;
static int music_volume;
static int sfx_volume;
static int internal_volume;
static float loop_point;
static float song_length; // length in seconds
static boolean songpaused;
@ -221,6 +223,15 @@ void I_UpdateSound(void)
/// SFX
/// ------------------------
static int
get_real_sfx_volume (int vol)
{
const int scale = SOUND_VOLUME_RANGE / MIX_MAX_VOLUME;
const int divider = VOLUME_DIVIDER * scale;
const int volume = ( vol + 1 ) / divider * sfx_volume / 100;
return volume;
}
// this is as fast as I can possibly make it.
// sorry. more asm needed.
static Mix_Chunk *ds2chunk(void *stream)
@ -476,7 +487,8 @@ void I_FreeSfx(sfxinfo_t *sfx)
INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority, INT32 channel)
{
UINT8 volume = (((UINT16)vol + 1) * (UINT16)sfx_volume) / 62; // (256 * 31) / 62 == 127
//UINT8 volume = (((UINT16)vol + 1) * (UINT16)sfx_volume) / 62; // (256 * 31) / 62 == 127
UINT8 volume = get_real_sfx_volume(vol);
INT32 handle = Mix_PlayChannel(channel, S_sfx[id].data, 0);
Mix_Volume(handle, volume);
Mix_SetPanning(handle, min((UINT16)(0xff-sep)<<1, 0xff), min((UINT16)(sep)<<1, 0xff));
@ -497,13 +509,14 @@ boolean I_SoundIsPlaying(INT32 handle)
void I_UpdateSoundParams(INT32 handle, UINT8 vol, UINT8 sep, UINT8 pitch)
{
UINT8 volume = (((UINT16)vol + 1) * (UINT16)sfx_volume) / 62; // (256 * 31) / 62 == 127
//UINT8 volume = (((UINT16)vol + 1) * (UINT16)sfx_volume) / 62; // (256 * 31) / 62 == 127
UINT8 volume = get_real_sfx_volume(vol);
Mix_Volume(handle, volume);
Mix_SetPanning(handle, min((UINT16)(0xff-sep)<<1, 0xff), min((UINT16)(sep)<<1, 0xff));
(void)pitch;
}
void I_SetSfxVolume(UINT8 volume)
void I_SetSfxVolume(int volume)
{
sfx_volume = volume;
}
@ -512,18 +525,17 @@ void I_SetSfxVolume(UINT8 volume)
/// Music Utilities
/// ------------------------
static UINT32 get_real_volume(UINT8 volume)
static UINT32 get_real_volume(int volume)
{
#ifdef _WIN32
if (I_SongType() == MU_MID)
// HACK: Until we stop using native MIDI,
// disable volume changes
return ((UINT32)31*128/31); // volume = 31
else
#endif
{
// convert volume to mixer's 128 scale
// then apply internal_volume as a percentage
return ((UINT32)volume*128/31) * (UINT32)internal_volume / 100;
//return ((UINT32)volume*128/31) * (UINT32)internal_volume / 100;
return MIX_MAX_VOLUME
* musicdef_volume / 100
* internal_volume / 100
* volume / 100;
}
}
static UINT32 get_adjusted_position(UINT32 position)
@ -583,7 +595,7 @@ static void count_music_bytes(int chan, void *stream, int len, void *udata)
(void)stream;
(void)udata;
if (!music || I_SongType() == MU_GME || I_SongType() == MU_MOD || I_SongType() == MU_MID)
if (!music || I_SongType() == MU_GME || I_SongType() == MU_MOD)
return;
music_bytes += len;
@ -686,8 +698,6 @@ musictype_t I_SongType(void)
#endif
if (!music)
return MU_NONE;
else if (Mix_GetMusicType(music) == MUS_MID)
return MU_MID;
else if (Mix_GetMusicType(music) == MUS_MOD || Mix_GetMusicType(music) == MUS_MODPLUG)
return MU_MOD;
else if (Mix_GetMusicType(music) == MUS_MP3 || Mix_GetMusicType(music) == MUS_MP3_MAD)
@ -770,7 +780,7 @@ UINT32 I_GetSongLength(void)
}
else
#endif
if (!music || I_SongType() == MU_MOD || I_SongType() == MU_MID)
if (!music || I_SongType() == MU_MOD)
return 0;
else
{
@ -785,7 +795,7 @@ UINT32 I_GetSongLength(void)
boolean I_SetSongLoopPoint(UINT32 looppoint)
{
if (!music || I_SongType() == MU_GME || I_SongType() == MU_MOD || I_SongType() == MU_MID || !is_looping)
if (!music || I_SongType() == MU_GME || I_SongType() == MU_MOD || !is_looping)
return false;
else
{
@ -821,7 +831,7 @@ UINT32 I_GetSongLoopPoint(void)
}
else
#endif
if (!music || I_SongType() == MU_MOD || I_SongType() == MU_MID)
if (!music || I_SongType() == MU_MOD)
return 0;
else
return (UINT32)(loop_point * 1000);
@ -855,7 +865,7 @@ boolean I_SetSongPosition(UINT32 position)
}
else
#endif
if (!music || I_SongType() == MU_MID)
if (!music)
return false;
else if (I_SongType() == MU_MOD)
return Mix_SetMusicPosition(position); // Goes by channels
@ -914,7 +924,7 @@ UINT32 I_GetSongPosition(void)
}
else
#endif
if (!music || I_SongType() == MU_MID)
if (!music)
return 0;
else
return music_bytes/44100.0L*1000.0L/4; //assume 44.1khz
@ -1096,12 +1106,12 @@ boolean I_PlaySong(boolean looping)
if (fpclassify(song_length) == FP_ZERO && (I_SongType() == MU_OGG || I_SongType() == MU_MP3 || I_SongType() == MU_FLAC))
CONS_Debug(DBG_DETAILED, "This song is missing a LENGTHMS= tag! Required to make seeking work properly.\n");
if (I_SongType() != MU_MOD && I_SongType() != MU_MID && Mix_PlayMusic(music, 0) == -1)
if (I_SongType() != MU_MOD && Mix_PlayMusic(music, 0) == -1)
{
CONS_Alert(CONS_ERROR, "Mix_PlayMusic: %s\n", Mix_GetError());
return false;
}
else if ((I_SongType() == MU_MOD || I_SongType() == MU_MID) && Mix_PlayMusic(music, looping ? -1 : 0) == -1) // if MOD, loop forever
else if (I_SongType() == MU_MOD && Mix_PlayMusic(music, looping ? -1 : 0) == -1) // if MOD, loop forever
{
CONS_Alert(CONS_ERROR, "Mix_PlayMusic: %s\n", Mix_GetError());
return false;
@ -1111,10 +1121,10 @@ boolean I_PlaySong(boolean looping)
I_SetMusicVolume(music_volume);
if (I_SongType() != MU_MOD && I_SongType() != MU_MID)
if (I_SongType() != MU_MOD)
Mix_HookMusicFinished(music_loop); // don't bother counting if MOD
if(I_SongType() != MU_MOD && I_SongType() != MU_MID && !Mix_RegisterEffect(MIX_CHANNEL_POST, count_music_bytes, NULL, NULL))
if(I_SongType() != MU_MOD && !Mix_RegisterEffect(MIX_CHANNEL_POST, count_music_bytes, NULL, NULL))
CONS_Alert(CONS_WARNING, "Error registering SDL music position counter: %s\n", Mix_GetError());
return true;
@ -1143,10 +1153,9 @@ void I_StopSong(void)
void I_PauseSong(void)
{
if(I_SongType() == MU_MID) // really, SDL Mixer? why can't you pause MIDI???
return;
// really, SRB2? why do you support MIDI???
if(I_SongType() != MU_GME && I_SongType() != MU_MOD && I_SongType() != MU_MID)
if(I_SongType() != MU_GME && I_SongType() != MU_MOD)
Mix_UnregisterEffect(MIX_CHANNEL_POST, count_music_bytes);
Mix_PauseMusic();
@ -1155,15 +1164,12 @@ void I_PauseSong(void)
void I_ResumeSong(void)
{
if (I_SongType() == MU_MID)
return;
if (I_SongType() != MU_GME && I_SongType() != MU_MOD && I_SongType() != MU_MID)
if (I_SongType() != MU_GME && I_SongType() != MU_MOD)
{
while(Mix_UnregisterEffect(MIX_CHANNEL_POST, count_music_bytes) != 0) { }
// HACK: fixes issue of multiple effect callbacks being registered
if(music && I_SongType() != MU_MOD && I_SongType() != MU_MID && !Mix_RegisterEffect(MIX_CHANNEL_POST, count_music_bytes, NULL, NULL))
if(music && I_SongType() != MU_MOD && !Mix_RegisterEffect(MIX_CHANNEL_POST, count_music_bytes, NULL, NULL))
CONS_Alert(CONS_WARNING, "Error registering SDL music position counter: %s\n", Mix_GetError());
}
@ -1171,19 +1177,12 @@ void I_ResumeSong(void)
songpaused = false;
}
void I_SetMusicVolume(UINT8 volume)
void I_SetMusicVolume(int volume)
{
if (!I_SongPlaying())
return;
#ifdef _WIN32
if (I_SongType() == MU_MID)
// HACK: Until we stop using native MIDI,
// disable volume changes
music_volume = 31;
else
#endif
music_volume = volume;
music_volume = volume;
Mix_VolumeMusic(get_real_volume(music_volume));
}

View file

@ -195,7 +195,7 @@ static void Snd_LockAudio(void) //Alam: Lock audio data and uninstall audio call
{
if (Snd_Mutex) SDL_LockMutex(Snd_Mutex);
else if (sound_disabled) return;
else if (midi_disabled && digital_disabled
else if (digital_disabled
#ifdef HW3SOUND
&& hws_mode == HWS_DEFAULT_MODE
#endif
@ -209,7 +209,7 @@ static void Snd_UnlockAudio(void) //Alam: Unlock audio data and reinstall audio
{
if (Snd_Mutex) SDL_UnlockMutex(Snd_Mutex);
else if (sound_disabled) return;
else if (midi_disabled && digital_disabled
else if (digital_disabled
#ifdef HW3SOUND
&& hws_mode == HWS_DEFAULT_MODE
#endif
@ -1153,7 +1153,7 @@ void I_ShutdownSound(void)
}
#endif
if (midi_disabled && digital_disabled)
if (digital_disabled)
SDL_CloseAudio();
CONS_Printf("%s", M_GetText("shut down\n"));
sound_started = false;
@ -1173,9 +1173,6 @@ void I_StartupSound(void)
const char *sdrv_name = NULL;
#endif
#ifndef HAVE_MIXER
#ifndef NO_MIDI
midi_disabled =
#endif
digital_disabled = true;
#endif

View file

@ -1710,7 +1710,6 @@ int W_VerifyNMUSlumps(const char *filename)
{
lumpchecklist_t NMUSlist[] =
{
{"D_", 2}, // MIDI music
{"O_", 2}, // Digital music
{"DS", 2}, // Sound effects