mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-03-23 03:12:38 +00:00
Checkpoint: Add FluidSynth and Timidity support
This commit is contained in:
parent
8ee27d3297
commit
28545822ba
5 changed files with 112 additions and 9 deletions
|
@ -30,7 +30,8 @@ typedef enum {
|
|||
MU_MP3_MAD_UNUSED, // use MU_MP3 instead
|
||||
MU_FLAC,
|
||||
MU_MODPLUG_UNUSED, // use MU_MOD instead
|
||||
MU_GME
|
||||
MU_GME,
|
||||
MU_MID_EX // Non-native MIDI
|
||||
} musictype_t;
|
||||
|
||||
/** \brief Sound subsystem runing and waiting
|
||||
|
|
14
src/m_menu.c
14
src/m_menu.c
|
@ -1318,6 +1318,14 @@ static menuitem_t OP_SoundOptionsMenu[] =
|
|||
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "MIDI Music Volume", &cv_midimusicvolume, 80},
|
||||
|
||||
{IT_STRING | IT_CVAR, NULL, "Closed Captioning", &cv_closedcaptioning, 100},
|
||||
|
||||
#ifdef HAVE_MIXERX
|
||||
{IT_HEADER, NULL, "Advanced", NULL, 118},
|
||||
|
||||
{IT_STRING | IT_CVAR, NULL, "MIDI Player", &cv_midiplayer, 130},
|
||||
{IT_STRING | IT_CVAR | IT_CV_STRING, NULL, "FluidSynth Sound Font File", &cv_midisoundfontpath, 140},
|
||||
{IT_STRING | IT_CVAR | IT_CV_STRING, NULL, "TiMidity++ Config Folder", &cv_miditimiditypath, 168}
|
||||
#endif
|
||||
};
|
||||
|
||||
static menuitem_t OP_DataOptionsMenu[] =
|
||||
|
@ -9484,7 +9492,7 @@ static void M_ToggleDigital(INT32 choice)
|
|||
else
|
||||
{
|
||||
digital_disabled = true;
|
||||
if (S_MusicType() != MU_MID)
|
||||
if (S_MusicType() != MU_MID && S_MusicType() != MU_MID_EX)
|
||||
{
|
||||
if (midi_disabled)
|
||||
S_StopMusic();
|
||||
|
@ -9523,7 +9531,7 @@ static void M_ToggleMIDI(INT32 choice)
|
|||
|
||||
case KEY_LEFTARROW:
|
||||
case KEY_RIGHTARROW:
|
||||
if (S_MusicType() != MU_MID && S_MusicType() != MU_NONE)
|
||||
if (S_MusicType() != MU_MID && S_MusicType() != MU_MID_EX && S_MusicType() != MU_NONE)
|
||||
S_StartSound(NULL, sfx_menu1);
|
||||
break;
|
||||
|
||||
|
@ -9551,7 +9559,7 @@ static void M_ToggleMIDI(INT32 choice)
|
|||
else
|
||||
{
|
||||
midi_disabled = true;
|
||||
if (S_MusicType() == MU_MID)
|
||||
if (S_MusicType() == MU_MID || S_MusicType() == MU_MID_EX)
|
||||
{
|
||||
if (digital_disabled)
|
||||
S_StopMusic();
|
||||
|
|
|
@ -1587,6 +1587,7 @@ void S_SetMusicVolume(INT32 digvolume, INT32 seqvolume)
|
|||
switch(I_SongType())
|
||||
{
|
||||
case MU_MID:
|
||||
case MU_MID_EX:
|
||||
//case MU_MOD:
|
||||
//case MU_GME:
|
||||
I_SetMusicVolume(seqvolume&31);
|
||||
|
|
|
@ -27,6 +27,12 @@ extern consvar_t stereoreverse;
|
|||
extern consvar_t cv_soundvolume, cv_closedcaptioning, cv_digmusicvolume, cv_midimusicvolume;
|
||||
extern consvar_t cv_numChannels;
|
||||
|
||||
#ifdef HAVE_MIXERX
|
||||
extern consvar_t cv_midiplayer;
|
||||
extern consvar_t cv_midisoundfontpath;
|
||||
extern consvar_t cv_miditimiditypath;
|
||||
#endif
|
||||
|
||||
#ifdef SNDSERV
|
||||
extern consvar_t sndserver_cmd, sndserver_arg;
|
||||
#endif
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#pragma warning(default : 4214 4244)
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef HAVE_MIXERX
|
||||
#include "SDL_mixer_ext.h"
|
||||
#else
|
||||
#include "SDL_mixer.h"
|
||||
|
@ -76,13 +76,55 @@ static Music_Emu *gme;
|
|||
static INT32 current_track;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MIXERX
|
||||
static void change_midiplayer(void)
|
||||
{
|
||||
if (I_SongType() != MU_MID_EX)
|
||||
return;
|
||||
|
||||
if (Mix_GetMidiPlayer() != cv_midiplayer.value)
|
||||
{
|
||||
Mix_SetMidiPlayer(cv_midiplayer.value);
|
||||
S_Init();
|
||||
}
|
||||
}
|
||||
|
||||
static void change_midisoundfontpath(void)
|
||||
{
|
||||
if (I_SongType() != MU_MID_EX)
|
||||
return;
|
||||
|
||||
if (stricmp(Mix_GetSoundFonts(), cv_midisoundfontpath.string))
|
||||
{
|
||||
Mix_SetSoundFonts(cv_midisoundfontpath.string);
|
||||
S_Init();
|
||||
}
|
||||
}
|
||||
|
||||
static void change_miditimiditypath(void)
|
||||
{
|
||||
if (I_SongType() != MU_MID_EX)
|
||||
return;
|
||||
|
||||
Mix_Timidity_addToPathList(cv_miditimiditypath.string);
|
||||
S_Init();
|
||||
}
|
||||
|
||||
static CV_PossibleValue_t midiplayer_cons_t[] = {{MIDI_OPNMIDI, "OPNMIDI"}, {MIDI_Fluidsynth, "Fluidsynth"}, {MIDI_Timidity, "Timidity"}, {MIDI_Native, "Native"}, {0, NULL}};
|
||||
consvar_t cv_midiplayer = {"midi_player", "OPNMIDI" /*MIDI_OPNMIDI*/, CV_CALL|CV_SAVE, midiplayer_cons_t, change_midiplayer, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_midisoundfontpath = {"midi_soundfont_path", "sf2/soundfont.sf2", CV_CALL|CV_SAVE, NULL, change_midisoundfontpath, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_miditimiditypath = {"midi_timidity_path", "./timidity", CV_CALL|CV_SAVE, NULL, change_miditimiditypath, 0, NULL, NULL, 0, 0, NULL};
|
||||
#endif
|
||||
|
||||
/// ------------------------
|
||||
/// Audio System
|
||||
/// ------------------------
|
||||
|
||||
void I_StartupSound(void)
|
||||
{
|
||||
I_Assert(!sound_started);
|
||||
//I_Assert(!sound_started);
|
||||
if (sound_started)
|
||||
return;
|
||||
|
||||
// EE inits audio first so we're following along.
|
||||
if (SDL_WasInit(SDL_INIT_AUDIO) == SDL_INIT_AUDIO)
|
||||
|
@ -101,7 +143,12 @@ void I_StartupSound(void)
|
|||
Mix_Init(MIX_INIT_FLAC|MIX_INIT_MOD|MIX_INIT_MP3|MIX_INIT_OGG);
|
||||
#endif
|
||||
#if HAVE_MIXERX
|
||||
Mix_SetMidiPlayer(MIDI_OPNMIDI);
|
||||
CV_RegisterVar(&cv_midiplayer);
|
||||
CV_RegisterVar(&cv_midisoundfontpath);
|
||||
CV_RegisterVar(&cv_miditimiditypath);
|
||||
Mix_SetMidiPlayer(cv_midiplayer.value);
|
||||
Mix_SetSoundFonts(cv_midisoundfontpath.string);
|
||||
Mix_Timidity_addToPathList(cv_miditimiditypath.string);
|
||||
#endif
|
||||
|
||||
if (Mix_OpenAudio(44100, AUDIO_S16SYS, 2, 2048) < 0)
|
||||
|
@ -506,6 +553,33 @@ void I_ShutdownMusic(void)
|
|||
music = NULL;
|
||||
}
|
||||
|
||||
#ifdef HAVE_MIXERX
|
||||
UINT8 I_SetMidiPlayer(int player)
|
||||
{
|
||||
return Mix_SetMidiPlayer(player);
|
||||
}
|
||||
|
||||
UINT8 I_GetMidiPlayer(void)
|
||||
{
|
||||
return Mix_GetMidiPlayer();
|
||||
}
|
||||
|
||||
boolean I_SetMidiSoundfontPath(const char *path)
|
||||
{
|
||||
return Mix_SetSoundFonts(path);
|
||||
}
|
||||
|
||||
const char *I_GetMidiSoundfontPath(void)
|
||||
{
|
||||
return Mix_GetSoundFonts();
|
||||
}
|
||||
|
||||
void I_SetMidiTimidityPath(const char *path)
|
||||
{
|
||||
Mix_Timidity_addToPathList(path);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// ------------------------
|
||||
/// Music Properties
|
||||
/// ------------------------
|
||||
|
@ -520,7 +594,14 @@ musictype_t I_SongType(void)
|
|||
if (!music)
|
||||
return MU_NONE;
|
||||
else if (Mix_GetMusicType(music) == MUS_MID)
|
||||
{
|
||||
#ifdef HAVE_MIXERX
|
||||
if (Mix_GetMidiPlayer() != MIDI_Native)
|
||||
return MU_MID_EX;
|
||||
else
|
||||
#endif
|
||||
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)
|
||||
|
@ -672,6 +753,14 @@ boolean I_LoadSong(char *data, size_t len)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MIXERX
|
||||
if (Mix_GetMidiPlayer() != cv_midiplayer.value)
|
||||
Mix_SetMidiPlayer(cv_midiplayer.value);
|
||||
if (stricmp(Mix_GetSoundFonts(), cv_midisoundfontpath.string))
|
||||
Mix_SetSoundFonts(cv_midisoundfontpath.string);
|
||||
Mix_Timidity_addToPathList(cv_miditimiditypath.string); // this overwrites previous custom path
|
||||
#endif
|
||||
|
||||
music = Mix_LoadMUS_RW(SDL_RWFromMem(data, len), SDL_FALSE);
|
||||
if (!music)
|
||||
{
|
||||
|
@ -749,8 +838,6 @@ boolean I_PlaySong(boolean looping)
|
|||
if (loop_point != 0.0f)
|
||||
Mix_HookMusicFinished(music_loop);
|
||||
|
||||
CONS_Printf("X Song length %.4f\n", Mix_GetMusicTotalTime(music));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue