mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-03-19 09:21:47 +00:00
Consolidate I_SetDigMusicVolume and I_SetMIDIMusicVolume into one method
* In s_sound, they are merged to one method as well, but there are still two separate digvolume and seqvolume variables * Simplified Dig/MidiMusicDisabled in s_sound * Method reordering
This commit is contained in:
parent
14b393ab16
commit
701cc5a7dd
5 changed files with 102 additions and 66 deletions
|
@ -4057,11 +4057,9 @@ static void Command_RestartAudio_f(void)
|
|||
// These must be called or no sound and music until manually set.
|
||||
|
||||
I_SetSfxVolume(cv_soundvolume.value);
|
||||
I_SetDigMusicVolume(cv_digmusicvolume.value);
|
||||
I_SetMIDIMusicVolume(cv_midimusicvolume.value);
|
||||
S_SetMusicVolume(cv_digmusicvolume.value, cv_midimusicvolume.value);
|
||||
if (Playing()) // Gotta make sure the player is in a level
|
||||
P_RestoreMusic(&players[consoleplayer]);
|
||||
|
||||
}
|
||||
|
||||
/** Quits a game and returns to the title screen.
|
||||
|
|
|
@ -154,13 +154,13 @@ void I_ResumeSong(void);
|
|||
// MIDI I/O
|
||||
//
|
||||
|
||||
/** \brief The I_SetMIDIMusicVolume function
|
||||
/** \brief The I_SetMusicVolume function
|
||||
|
||||
\param volume volume to set at
|
||||
|
||||
\return void
|
||||
*/
|
||||
void I_SetMIDIMusicVolume(UINT8 volume);
|
||||
void I_SetMusicVolume(UINT8 volume);
|
||||
|
||||
/** \brief Registers a song handle to song data.
|
||||
|
||||
|
@ -210,14 +210,6 @@ boolean I_SetSongSpeed(float speed);
|
|||
|
||||
boolean I_SetSongTrack(INT32 track);
|
||||
|
||||
/** \brief The I_SetDigMusicVolume function
|
||||
|
||||
\param volume volume to set at
|
||||
|
||||
\return void
|
||||
*/
|
||||
void I_SetDigMusicVolume(UINT8 volume);
|
||||
|
||||
//
|
||||
// CD MUSIC I/O
|
||||
//
|
||||
|
|
|
@ -1312,19 +1312,54 @@ const char *compat_special_music_slots[16] =
|
|||
#define music_playing (music_name[0]) // String is empty if no music is playing
|
||||
|
||||
static char music_name[7]; // up to 6-character name
|
||||
|
||||
static boolean mus_forcemidi = 0; // force midi even when digital exists
|
||||
static boolean mus_paused = 0; // whether songs are mus_paused
|
||||
|
||||
/// ------------------------
|
||||
/// Music Status
|
||||
/// ------------------------
|
||||
|
||||
boolean S_DigMusicDisabled()
|
||||
{
|
||||
return (nodigimusic || digital_disabled);
|
||||
}
|
||||
|
||||
boolean S_MIDIMusicDisabled()
|
||||
{
|
||||
return (nomidimusic || music_disabled);
|
||||
}
|
||||
|
||||
boolean S_MusicDisabled()
|
||||
{
|
||||
return (
|
||||
(nodigimusic && nomidimusic) ||
|
||||
(music_disabled && digital_disabled) ||
|
||||
(nodigimusic && music_disabled) ||
|
||||
(nomidimusic && digital_disabled)
|
||||
);
|
||||
}
|
||||
|
||||
/// ------------------------
|
||||
/// Music Properties
|
||||
/// ------------------------
|
||||
|
||||
boolean S_SpeedMusic(float speed)
|
||||
{
|
||||
return I_SetSongSpeed(speed);
|
||||
}
|
||||
|
||||
/// ------------------------
|
||||
/// Music Routines
|
||||
/// ------------------------
|
||||
|
||||
static boolean S_LoadMusic(const char *mname)
|
||||
{
|
||||
lumpnum_t mlumpnum;
|
||||
void *mdata;
|
||||
|
||||
if (nomidimusic || music_disabled)
|
||||
return false; // didn't search.
|
||||
if (S_MusicDisabled())
|
||||
return false;
|
||||
|
||||
if (mus_forcemidi)
|
||||
if (S_DigMusicDisabled())
|
||||
{
|
||||
if (W_CheckNumForName(va("d_%s", mname)) == LUMPERROR)
|
||||
return false;
|
||||
|
@ -1370,12 +1405,13 @@ static boolean S_PlayMusic(boolean looping)
|
|||
return false;
|
||||
}
|
||||
|
||||
S_InitMusicVolume(); // switch between digi and sequence volume
|
||||
return true;
|
||||
}
|
||||
|
||||
void S_ChangeMusic(const char *mmusic, UINT16 mflags, boolean looping)
|
||||
{
|
||||
if ((nomidimusic || music_disabled) && (nodigimusic || digital_disabled))
|
||||
if (S_MusicDisabled())
|
||||
return;
|
||||
|
||||
// No Music (empty string)
|
||||
|
@ -1404,11 +1440,6 @@ void S_ChangeMusic(const char *mmusic, UINT16 mflags, boolean looping)
|
|||
I_SetSongTrack(mflags & MUSIC_TRACKMASK);
|
||||
}
|
||||
|
||||
boolean S_SpeedMusic(float speed)
|
||||
{
|
||||
return I_SetSongSpeed(speed);
|
||||
}
|
||||
|
||||
void S_StopMusic(void)
|
||||
{
|
||||
if (!music_playing)
|
||||
|
@ -1434,32 +1465,36 @@ void S_StopMusic(void)
|
|||
}
|
||||
}
|
||||
|
||||
void S_SetDigMusicVolume(INT32 volume)
|
||||
void S_SetMusicVolume(INT32 digvolume, INT32 seqvolume)
|
||||
{
|
||||
if (volume < 0 || volume > 31)
|
||||
CONS_Alert(CONS_WARNING, "musicvolume should be between 0-31\n");
|
||||
if (digvolume < 0)
|
||||
digvolume = cv_digmusicvolume.value;
|
||||
if (seqvolume < 0)
|
||||
seqvolume = cv_midimusicvolume.value;
|
||||
|
||||
CV_SetValue(&cv_digmusicvolume, volume&31);
|
||||
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
|
||||
|
||||
#ifdef DJGPPDOS
|
||||
I_SetDigMusicVolume(31); // Trick for buggy dos drivers. Win32 doesn't need this.
|
||||
#endif
|
||||
I_SetDigMusicVolume(volume&31);
|
||||
}
|
||||
|
||||
void S_SetMIDIMusicVolume(INT32 volume)
|
||||
{
|
||||
if (volume < 0 || volume > 31)
|
||||
CONS_Alert(CONS_WARNING, "musicvolume should be between 0-31\n");
|
||||
|
||||
CV_SetValue(&cv_midimusicvolume, volume&0x1f);
|
||||
if (digvolume < 0 || digvolume > 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
|
||||
|
||||
#ifdef DJGPPDOS
|
||||
I_SetMIDIMusicVolume(31); // Trick for buggy dos drivers. Win32 doesn't need this.
|
||||
digvolume = seqvolume = 31;
|
||||
#endif
|
||||
I_SetMIDIMusicVolume(volume&0x1f);
|
||||
|
||||
switch(I_GetMusicType())
|
||||
{
|
||||
case MU_MID:
|
||||
case MU_MOD:
|
||||
case MU_GME:
|
||||
I_SetMusicVolume(seqvolume&31);
|
||||
default:
|
||||
I_SetMusicVolume(digvolume&31);
|
||||
}
|
||||
}
|
||||
|
||||
/// ------------------------
|
||||
|
@ -1479,8 +1514,7 @@ void S_Init(INT32 sfxVolume, INT32 digMusicVolume, INT32 midiMusicVolume)
|
|||
return;
|
||||
|
||||
S_SetSfxVolume(sfxVolume);
|
||||
S_SetDigMusicVolume(digMusicVolume);
|
||||
S_SetMIDIMusicVolume(midiMusicVolume);
|
||||
S_SetMusicVolume(digMusicVolume, midiMusicVolume);
|
||||
|
||||
SetChannelsNum();
|
||||
|
||||
|
|
|
@ -125,6 +125,25 @@ void S_StartSoundAtVolume(const void *origin, sfxenum_t sound_id, INT32 volume);
|
|||
// Stop sound for thing at <origin>
|
||||
void S_StopSound(void *origin);
|
||||
|
||||
//
|
||||
// Music Status
|
||||
//
|
||||
|
||||
boolean S_DigMusicDisabled();
|
||||
boolean S_MIDIMusicDisabled();
|
||||
boolean S_MusicDisabled();
|
||||
|
||||
//
|
||||
// Music Properties
|
||||
//
|
||||
|
||||
// Set Speed of Music
|
||||
boolean S_SpeedMusic(float speed);
|
||||
|
||||
//
|
||||
// Music Routines
|
||||
//
|
||||
|
||||
// Start music track, arbitrary, given its name, and set whether looping
|
||||
// note: music flags 12 bits for tracknum (gme, other formats with more than one track)
|
||||
// 13-15 aren't used yet
|
||||
|
@ -132,9 +151,6 @@ void S_StopSound(void *origin);
|
|||
#define S_ChangeMusicInternal(a,b) S_ChangeMusic(a,0,b)
|
||||
void S_ChangeMusic(const char *mmusic, UINT16 mflags, boolean looping);
|
||||
|
||||
// Set Speed of Music
|
||||
boolean S_SpeedMusic(float speed);
|
||||
|
||||
// Stops the music.
|
||||
void S_StopMusic(void);
|
||||
|
||||
|
@ -149,9 +165,11 @@ 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_SetDigMusicVolume(INT32 volume);
|
||||
void S_SetMIDIMusicVolume(INT32 volume);
|
||||
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)
|
||||
|
||||
INT32 S_OriginPlaying(void *origin);
|
||||
INT32 S_IdPlaying(sfxenum_t id);
|
||||
|
|
|
@ -522,14 +522,6 @@ void I_ResumeSong(void)
|
|||
// Digital Music
|
||||
//
|
||||
|
||||
void I_SetDigMusicVolume(UINT8 volume)
|
||||
{
|
||||
music_volume = volume;
|
||||
if (I_GetMusicType() == MU_MID || !music)
|
||||
return;
|
||||
Mix_VolumeMusic((UINT32)volume*128/31);
|
||||
}
|
||||
|
||||
boolean I_SetSongSpeed(float speed)
|
||||
{
|
||||
if (speed > 250.0f)
|
||||
|
@ -773,17 +765,19 @@ void I_StopSong(void)
|
|||
music = NULL;
|
||||
}
|
||||
|
||||
void I_SetMIDIMusicVolume(UINT8 volume)
|
||||
void I_SetMusicVolume(UINT8 volume)
|
||||
{
|
||||
// HACK: Until we stop using native MIDI,
|
||||
// disable volume changes
|
||||
(void)volume;
|
||||
midi_volume = 31;
|
||||
//midi_volume = volume;
|
||||
|
||||
if (I_GetMusicType() != MU_MID || !music)
|
||||
if (!music)
|
||||
return;
|
||||
Mix_VolumeMusic((UINT32)midi_volume*128/31);
|
||||
|
||||
if (I_GetMusicType() == MU_MID)
|
||||
// HACK: Until we stop using native MIDI,
|
||||
// disable volume changes
|
||||
music_volume = 31;
|
||||
else
|
||||
music_volume = volume;
|
||||
|
||||
Mix_VolumeMusic((UINT32)music_volume*128/31);
|
||||
}
|
||||
|
||||
void I_UnloadSong(void)
|
||||
|
|
Loading…
Reference in a new issue