mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-18 07:22:28 +00:00
Added I_GetMusicType and removed midimode variable
* Revised S_PlayMusic arguments * Now music plays again!
This commit is contained in:
parent
9a5fc5f66a
commit
55f3803e4b
3 changed files with 48 additions and 15 deletions
|
@ -18,6 +18,21 @@
|
|||
#include "sounds.h"
|
||||
#include "command.h"
|
||||
|
||||
// copied from SDL mixer, plus GME
|
||||
typedef enum {
|
||||
MU_NONE,
|
||||
MU_CMD,
|
||||
MU_WAV,
|
||||
MU_MOD,
|
||||
MU_MID,
|
||||
MU_OGG,
|
||||
MU_MP3,
|
||||
MU_MP3_MAD_UNUSED, // use MU_MP3 instead
|
||||
MU_FLAC,
|
||||
MU_MODPLUG_UNUSED, // use MU_MOD instead
|
||||
MU_GME
|
||||
} musictype_t;
|
||||
|
||||
/** \brief Sound subsystem runing and waiting
|
||||
*/
|
||||
extern UINT8 sound_started;
|
||||
|
@ -108,6 +123,9 @@ void I_SetSfxVolume(UINT8 volume);
|
|||
//
|
||||
// MUSIC I/O
|
||||
//
|
||||
|
||||
musictype_t I_GetMusicType(void);
|
||||
|
||||
/** \brief Init the music systems
|
||||
*/
|
||||
void I_InitMusic(void);
|
||||
|
|
|
@ -1359,7 +1359,7 @@ static void S_UnloadMusic(void)
|
|||
music_name[0] = 0;
|
||||
}
|
||||
|
||||
static boolean S_PlayMusic(const char *mname, boolean looping)
|
||||
static boolean S_PlayMusic(boolean looping)
|
||||
{
|
||||
if (nodigimusic || digital_disabled)
|
||||
return false; // try midi
|
||||
|
@ -1370,8 +1370,6 @@ static boolean S_PlayMusic(const char *mname, boolean looping)
|
|||
return false;
|
||||
}
|
||||
|
||||
strncpy(music_name, mname, 7);
|
||||
music_name[6] = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1390,11 +1388,18 @@ void S_ChangeMusic(const char *mmusic, UINT16 mflags, boolean looping)
|
|||
if (strncmp(music_name, mmusic, 6))
|
||||
{
|
||||
S_StopMusic(); // shutdown old music
|
||||
if (!S_LoadMusic(mmusic) && !S_PlayMusic(mmusic, looping))
|
||||
|
||||
if (!S_LoadMusic(mmusic))
|
||||
{
|
||||
CONS_Alert(CONS_ERROR, M_GetText("Music lump %.6s not found!\n"), mmusic);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!S_PlayMusic(looping))
|
||||
{
|
||||
CONS_Alert(CONS_ERROR, "Music cannot be played!\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
I_SetSongTrack(mflags & MUSIC_TRACKMASK);
|
||||
}
|
||||
|
|
|
@ -62,7 +62,6 @@
|
|||
|
||||
UINT8 sound_started = false;
|
||||
|
||||
static boolean midimode;
|
||||
static Mix_Music *music;
|
||||
static UINT8 music_volume, midi_volume, sfx_volume;
|
||||
static float loop_point;
|
||||
|
@ -87,7 +86,6 @@ void I_StartupSound(void)
|
|||
return;
|
||||
}
|
||||
|
||||
midimode = false;
|
||||
music = NULL;
|
||||
music_volume = midi_volume = sfx_volume = 0;
|
||||
|
||||
|
@ -436,6 +434,25 @@ void I_SetSfxVolume(UINT8 volume)
|
|||
// Music
|
||||
//
|
||||
|
||||
musictype_t I_GetMusicType(void)
|
||||
{
|
||||
#ifdef HAVE_LIBGME
|
||||
if (gme)
|
||||
return MU_GME;
|
||||
else
|
||||
#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_UNUSED)
|
||||
return MU_MOD;
|
||||
else if (Mix_GetMusicType(music) == MUS_MP3 || Mix_GetMusicType(music) == MUS_MP3_MAD_UNUSED)
|
||||
return MU_MP3;
|
||||
else
|
||||
return (musictype_t)Mix_GetMusicType(music);
|
||||
}
|
||||
|
||||
// Music hooks
|
||||
static void music_loop(void)
|
||||
{
|
||||
|
@ -474,8 +491,6 @@ FUNCMATH void I_InitMusic(void)
|
|||
|
||||
void I_ShutdownMusic(void)
|
||||
{
|
||||
if (midimode)
|
||||
return;
|
||||
#ifdef HAVE_LIBGME
|
||||
if (gme)
|
||||
{
|
||||
|
@ -510,7 +525,7 @@ void I_ResumeSong(void)
|
|||
void I_SetDigMusicVolume(UINT8 volume)
|
||||
{
|
||||
music_volume = volume;
|
||||
if (midimode || !music)
|
||||
if (I_GetMusicType() == MU_MID || !music)
|
||||
return;
|
||||
Mix_VolumeMusic((UINT32)volume*128/31);
|
||||
}
|
||||
|
@ -741,8 +756,6 @@ boolean I_PlaySong(boolean looping)
|
|||
|
||||
void I_StopSong(void)
|
||||
{
|
||||
if (midimode)
|
||||
return;
|
||||
#ifdef HAVE_LIBGME
|
||||
if (gme)
|
||||
{
|
||||
|
@ -768,16 +781,13 @@ void I_SetMIDIMusicVolume(UINT8 volume)
|
|||
midi_volume = 31;
|
||||
//midi_volume = volume;
|
||||
|
||||
if (!midimode || !music)
|
||||
if (I_GetMusicType() != MU_MID || !music)
|
||||
return;
|
||||
Mix_VolumeMusic((UINT32)midi_volume*128/31);
|
||||
}
|
||||
|
||||
void I_UnloadSong(void)
|
||||
{
|
||||
if (!midimode || !music)
|
||||
return;
|
||||
|
||||
Mix_FreeMusic(music);
|
||||
music = NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue