diff --git a/src/sound/i_musicinterns.h b/src/sound/i_musicinterns.h index 65a631a47..3dc5b8384 100644 --- a/src/sound/i_musicinterns.h +++ b/src/sound/i_musicinterns.h @@ -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: diff --git a/src/sound/i_soundinternal.h b/src/sound/i_soundinternal.h index e1ae80290..5bdc023bc 100644 --- a/src/sound/i_soundinternal.h +++ b/src/sound/i_soundinternal.h @@ -162,6 +162,7 @@ enum EMidiDevice MDEV_FLUIDSYNTH = 4, MDEV_GUS = 5, MDEV_WILDMIDI = 6, + MDEV_ADL = 7, MDEV_COUNT }; diff --git a/src/sound/mididevices/music_adlmidi_mididevice.cpp b/src/sound/mididevices/music_adlmidi_mididevice.cpp index 9924ed1c6..c8cf5b8fc 100644 --- a/src/sound/mididevices/music_adlmidi_mididevice.cpp +++ b/src/sound/mididevices/music_adlmidi_mididevice.cpp @@ -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; imValues[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 : ""); diff --git a/src/sound/musicformats/music_midistream.cpp b/src/sound/musicformats/music_midistream.cpp index 4bc407c42..3a5697ac4 100644 --- a/src/sound/musicformats/music_midistream.cpp +++ b/src/sound/musicformats/music_midistream.cpp @@ -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) {