Add a cvar array for audiolib

git-svn-id: https://svn.eduke32.com/eduke32@8222 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2019-10-19 23:48:35 +00:00 committed by Christoph Oelckers
parent a2ab5492cc
commit 8a61ceeb36
3 changed files with 38 additions and 0 deletions

View file

@ -48,11 +48,39 @@ const char *FX_ErrorString(int ErrorNumber)
return ErrorString; return ErrorString;
} }
static int osdcmd_cvar_set_audiolib(osdcmdptr_t parm)
{
int32_t r = osdcmd_cvar_set(parm);
if (r != OSDCMD_OK) return r;
if (!Bstrcasecmp(parm->name, "mus_emidicard"))
{
MIDI_Restart();
return r;
}
return r;
}
int FX_Init(int numvoices, int numchannels, unsigned mixrate, void *initdata) int FX_Init(int numvoices, int numchannels, unsigned mixrate, void *initdata)
{ {
if (FX_Installed) if (FX_Installed)
FX_Shutdown(); FX_Shutdown();
else
{
static int init;
static osdcvardata_t cvars_audiolib[] = {
{ "mus_emidicard", "force a specific EMIDI instrument set", (void *)&ASS_EMIDICard, CVAR_INT | CVAR_FUNCPTR, 0, 10 },
};
if (!init++)
{
for (auto &i : cvars_audiolib)
OSD_RegisterCvar(&i, (i.flags & CVAR_FUNCPTR) ? osdcmd_cvar_set_audiolib : osdcmd_cvar_set);
}
}
int SoundCard = ASS_AutoDetect; int SoundCard = ASS_AutoDetect;
if (SoundCard == ASS_AutoDetect) { if (SoundCard == ASS_AutoDetect) {

View file

@ -89,6 +89,13 @@ static int _MIDI_Reset;
int MV_MIDIRenderTempo = -1; int MV_MIDIRenderTempo = -1;
int MV_MIDIRenderTimer; int MV_MIDIRenderTimer;
static char *_MIDI_SongPtr;
void MIDI_Restart(void)
{
MIDI_PlaySong(_MIDI_SongPtr, _MIDI_Loop);
}
static int _MIDI_ReadNumber(void *from, size_t size) static int _MIDI_ReadNumber(void *from, size_t size)
{ {
if (size > 4) if (size > 4)
@ -702,6 +709,8 @@ int MIDI_PlaySong(char *song, int loopflag)
if (B_UNBUF32(song) != MIDI_HEADER_SIGNATURE) if (B_UNBUF32(song) != MIDI_HEADER_SIGNATURE)
return MIDI_InvalidMidiFile; return MIDI_InvalidMidiFile;
_MIDI_SongPtr = song;
song += 4; song += 4;
int const headersize = _MIDI_ReadNumber(song, 4); int const headersize = _MIDI_ReadNumber(song, 4);
song += 4; song += 4;

View file

@ -65,5 +65,6 @@ void MIDI_PauseSong(void);
void MIDI_StopSong(void); void MIDI_StopSong(void);
int MIDI_PlaySong(char *song, int loopflag); int MIDI_PlaySong(char *song, int loopflag);
void MIDI_SetTempo(int tempo); void MIDI_SetTempo(int tempo);
void MIDI_Restart(void);
#endif #endif