mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 21:11:39 +00:00
- integrated ADL as a proper device in the MIDI device list.
- resorted the MIDI device menu option by device types (i.e. all SW synths first, FM synths second) - allow setting the ADL bank.
This commit is contained in:
parent
fd801b8b94
commit
2d2d44baad
5 changed files with 49 additions and 37 deletions
|
@ -325,7 +325,7 @@ public:
|
|||
~ADLMIDIDevice();
|
||||
|
||||
int Open(MidiCallback, void *userdata);
|
||||
int GetDeviceType() const override { return MDEV_OPL; }
|
||||
int GetDeviceType() const override { return MDEV_ADL; }
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -162,6 +162,7 @@ enum EMidiDevice
|
|||
MDEV_FLUIDSYNTH = 4,
|
||||
MDEV_GUS = 5,
|
||||
MDEV_WILDMIDI = 6,
|
||||
MDEV_ADL = 7,
|
||||
|
||||
MDEV_COUNT
|
||||
};
|
||||
|
|
|
@ -54,6 +54,14 @@ enum
|
|||
ME_PITCHWHEEL = 0xE0
|
||||
};
|
||||
|
||||
CUSTOM_CVAR(Int, adl_bank, 14, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
if (currSong != nullptr && currSong->GetDeviceType() == MDEV_ADL)
|
||||
{
|
||||
MIDIDeviceChanged(-1, true);
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// ADLMIDIDevice Constructor
|
||||
|
@ -61,6 +69,7 @@ enum
|
|||
//==========================================================================
|
||||
|
||||
ADLMIDIDevice::ADLMIDIDevice(const char *args)
|
||||
:SoftSynthMIDIDevice(44100)
|
||||
{
|
||||
Renderer = adl_init(44100); // todo: make it configurable
|
||||
if (Renderer != nullptr)
|
||||
|
@ -163,18 +172,11 @@ void ADLMIDIDevice::HandleLongEvent(const uint8_t *data, int len)
|
|||
|
||||
void ADLMIDIDevice::ComputeOutput(float *buffer, int len)
|
||||
{
|
||||
if (shortbuffer.Size() < len*2) shortbuffer.Resize(len*2);
|
||||
auto result = adl_generate(Renderer, len, &shortbuffer[0]);
|
||||
for(int i=0; i<result*2; i++)
|
||||
if ((int)shortbuffer.Size() < len*2) shortbuffer.Resize(len*2);
|
||||
auto result = adl_generate(Renderer, len*2, &shortbuffer[0]);
|
||||
for(int i=0; i<result; i++)
|
||||
{
|
||||
buffer[i] = shortbuffer[i] * (1.f/32768.f);
|
||||
buffer[i] = shortbuffer[i] * (5.f/32768.f);
|
||||
}
|
||||
/*
|
||||
for (int i = result; i < len; i++) // The backend cannot deal with gaps.
|
||||
{
|
||||
buffer[i*2] = shortbuffer[(result-1)*2] * (1.f / 32768.f);
|
||||
buffer[i * 2+1] = shortbuffer[(result - 1) * 2+1] * (1.f / 32768.f);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
|
|
@ -50,21 +50,23 @@
|
|||
static uint32_t nummididevices;
|
||||
static bool nummididevicesset;
|
||||
|
||||
#define NUM_DEF_DEVICES 5
|
||||
#define NUM_DEF_DEVICES 6
|
||||
|
||||
static void AddDefaultMidiDevices(FOptionValues *opt)
|
||||
{
|
||||
FOptionValues::Pair *pair = &opt->mValues[opt->mValues.Reserve(NUM_DEF_DEVICES)];
|
||||
pair[0].Text = "FluidSynth";
|
||||
pair[0].Value = -5.0;
|
||||
pair[1].Text = "GUS";
|
||||
pair[1].Value = -4.0;
|
||||
pair[2].Text = "OPL Synth Emulation";
|
||||
pair[2].Value = -3.0;
|
||||
pair[3].Text = "TiMidity++";
|
||||
pair[3].Value = -2.0;
|
||||
pair[4].Text = "WildMidi";
|
||||
pair[4].Value = -6.0;
|
||||
pair[1].Text = "TiMidity++";
|
||||
pair[1].Value = -2.0;
|
||||
pair[2].Text = "WildMidi";
|
||||
pair[2].Value = -6.0;
|
||||
pair[3].Text = "GUS";
|
||||
pair[3].Value = -4.0;
|
||||
pair[4].Text = "OPL Synth Emulation";
|
||||
pair[4].Value = -3.0;
|
||||
pair[5].Text = "libADL";
|
||||
pair[5].Value = -7.0;
|
||||
|
||||
}
|
||||
|
||||
|
@ -115,7 +117,7 @@ CUSTOM_CVAR (Int, snd_mididevice, DEF_MIDIDEV, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
|||
if (!nummididevicesset)
|
||||
return;
|
||||
|
||||
if ((self >= (signed)nummididevices) || (self < -6))
|
||||
if ((self >= (signed)nummididevices) || (self < -7))
|
||||
{
|
||||
// Don't do repeated message spam if there is no valid device.
|
||||
if (self != 0)
|
||||
|
@ -199,6 +201,7 @@ CCMD (snd_listmididevices)
|
|||
MIDIOUTCAPS caps;
|
||||
MMRESULT res;
|
||||
|
||||
PrintMidiDevice(-7, "libADL", MIDIDEV_FMSYNTH, 0);
|
||||
PrintMidiDevice (-6, "WildMidi", MIDIDEV_SWSYNTH, 0);
|
||||
PrintMidiDevice (-5, "FluidSynth", MIDIDEV_SWSYNTH, 0);
|
||||
PrintMidiDevice (-4, "Gravis Ultrasound Emulation", MIDIDEV_SWSYNTH, 0);
|
||||
|
@ -227,8 +230,8 @@ CCMD (snd_listmididevices)
|
|||
|
||||
CUSTOM_CVAR(Int, snd_mididevice, DEF_MIDIDEV, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
{
|
||||
if (self < -6)
|
||||
self = -6;
|
||||
if (self < -7)
|
||||
self = -7;
|
||||
else if (self > -2)
|
||||
self = -2;
|
||||
else
|
||||
|
@ -242,6 +245,7 @@ void I_BuildMIDIMenuList (FOptionValues *opt)
|
|||
|
||||
CCMD (snd_listmididevices)
|
||||
{
|
||||
Printf("%s-7. libADL\n", -6 == snd_mididevice ? TEXTCOLOR_BOLD : "");
|
||||
Printf("%s-6. WildMidi\n", -6 == snd_mididevice ? TEXTCOLOR_BOLD : "");
|
||||
Printf("%s-5. FluidSynth\n", -5 == snd_mididevice ? TEXTCOLOR_BOLD : "");
|
||||
Printf("%s-4. Gravis Ultrasound Emulation\n", -4 == snd_mididevice ? TEXTCOLOR_BOLD : "");
|
||||
|
|
|
@ -165,6 +165,7 @@ EMidiDevice MIDIStreamer::SelectMIDIDevice(EMidiDevice device)
|
|||
case -4: return MDEV_GUS;
|
||||
case -5: return MDEV_FLUIDSYNTH;
|
||||
case -6: return MDEV_WILDMIDI;
|
||||
case -7: return MDEV_ADL;
|
||||
default:
|
||||
#ifdef _WIN32
|
||||
return MDEV_MMAPI;
|
||||
|
@ -194,39 +195,43 @@ MIDIDevice *MIDIStreamer::CreateMIDIDevice(EMidiDevice devtype, int samplerate)
|
|||
selectedDevice = devtype;
|
||||
try
|
||||
{
|
||||
switch (devtype)
|
||||
{
|
||||
case MDEV_GUS:
|
||||
switch (devtype)
|
||||
{
|
||||
case MDEV_GUS:
|
||||
dev = new TimidityMIDIDevice(Args, samplerate);
|
||||
break;
|
||||
|
||||
case MDEV_MMAPI:
|
||||
#ifdef _WIN32
|
||||
case MDEV_ADL:
|
||||
dev = new ADLMIDIDevice(Args);
|
||||
break;
|
||||
|
||||
case MDEV_MMAPI:
|
||||
|
||||
#ifdef _WIN32
|
||||
dev = CreateWinMIDIDevice(mididevice);
|
||||
break;
|
||||
#endif
|
||||
// Intentional fall-through for non-Windows systems.
|
||||
// Intentional fall-through for non-Windows systems.
|
||||
|
||||
case MDEV_FLUIDSYNTH:
|
||||
case MDEV_FLUIDSYNTH:
|
||||
dev = new FluidSynthMIDIDevice(Args, samplerate);
|
||||
break;
|
||||
|
||||
case MDEV_OPL:
|
||||
case MDEV_OPL:
|
||||
dev = new OPLMIDIDevice(Args);
|
||||
break;
|
||||
*/
|
||||
|
||||
case MDEV_TIMIDITY:
|
||||
case MDEV_TIMIDITY:
|
||||
dev = CreateTimidityPPMIDIDevice(Args, samplerate);
|
||||
break;
|
||||
|
||||
case MDEV_WILDMIDI:
|
||||
case MDEV_WILDMIDI:
|
||||
dev = new WildMIDIDevice(Args, samplerate);
|
||||
break;
|
||||
|
||||
default:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (CRecoverableError &err)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue