- converted the 3 new CVARs in the audio code.

This commit is contained in:
Christoph Oelckers 2019-10-24 23:20:02 +02:00
parent e8cf6c3d32
commit 60fc828a89
3 changed files with 18 additions and 31 deletions

View file

@ -37,6 +37,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "midi.h" #include "midi.h"
#include "midifuncs.h" #include "midifuncs.h"
#include "opl3.h" #include "opl3.h"
#include "c_cvars.h"
CUSTOM_CVARD(Bool, mus_al_stereo, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "enable/disable OPL3 stereo mode")
{
AL_Stereo = self;
AL_SetStereo(AL_Stereo);
}
CVARD(Bool, mus_al_additivemode, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable alternate additive AdLib timbre mode")
enum enum
{ {
@ -200,7 +210,6 @@ static int AL_LeftPort = ADLIB_PORT;
static int AL_RightPort = ADLIB_PORT; static int AL_RightPort = ADLIB_PORT;
int AL_Stereo = TRUE; int AL_Stereo = TRUE;
static int AL_MaxMidiChannel = 16; static int AL_MaxMidiChannel = 16;
int AL_AdditiveMode;
// TODO: clean up this shit... // TODO: clean up this shit...
#define OFFSET(structure, offset) (*((char **)&(structure)[offset])) #define OFFSET(structure, offset) (*((char **)&(structure)[offset]))
@ -335,7 +344,7 @@ static void AL_SetVoiceVolume(int const voice)
uint32_t t2; uint32_t t2;
// amplitude // amplitude
if (AL_AdditiveMode) if (mus_al_additivemode)
t1 = (uint32_t)VoiceLevel[slot][port] * (velocity + 0x80); t1 = (uint32_t)VoiceLevel[slot][port] * (velocity + 0x80);
t2 = (Channel[channel].Volume * t1) >> 15; t2 = (Channel[channel].Volume * t1) >> 15;

View file

@ -48,40 +48,11 @@ const char *FX_ErrorString(int const 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();
else if (!Bstrcasecmp(parm->name, "mus_al_stereo"))
AL_SetStereo(AL_Stereo);
return r;
}
int FX_Init(int numvoices, int numchannels, int mixrate, void *initdata) int FX_Init(int numvoices, int numchannels, int 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, -1, 10 },
{ "mus_al_stereo", "enable/disable OPL3 stereo mode", (void *)&AL_Stereo, CVAR_BOOL | CVAR_FUNCPTR, 0, 1 },
{ "mus_al_additivemode", "enable/disable alternate additive AdLib timbre mode", (void *)&AL_AdditiveMode, CVAR_BOOL, 0, 1 },
};
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;

View file

@ -42,6 +42,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "pragmas.h" #include "pragmas.h"
#include "sndcards.h" #include "sndcards.h"
#include "driver_adlib.h" #include "driver_adlib.h"
#include "c_cvars.h"
CUSTOM_CVARD(Int, mus_emidicard, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "force a specific EMIDI instrument set")
{
ASS_EMIDICard = clamp(*self, -1, 10);
}
extern int MV_MixRate; extern int MV_MixRate;
extern int ASS_MIDISoundDriver; extern int ASS_MIDISoundDriver;