diff options
-rw-r--r-- | backends/midi/alsa.cpp | 14 | ||||
-rw-r--r-- | backends/midi/camd.cpp | 14 | ||||
-rw-r--r-- | backends/midi/coreaudio.cpp | 14 | ||||
-rw-r--r-- | backends/midi/coremidi.cpp | 14 | ||||
-rw-r--r-- | backends/midi/dmedia.cpp | 14 | ||||
-rw-r--r-- | backends/midi/quicktime.cpp | 14 | ||||
-rw-r--r-- | backends/midi/seq.cpp | 14 | ||||
-rw-r--r-- | backends/midi/timidity.cpp | 14 | ||||
-rw-r--r-- | backends/midi/windows.cpp | 14 | ||||
-rw-r--r-- | backends/midi/ypa1.cpp | 14 | ||||
-rw-r--r-- | backends/midi/zodiac.cpp | 14 | ||||
-rw-r--r-- | base/plugins.cpp | 56 | ||||
-rw-r--r-- | base/plugins.h | 2 | ||||
-rw-r--r-- | sound/mididrv.cpp | 2 | ||||
-rw-r--r-- | sound/mididrv.h | 2 | ||||
-rw-r--r-- | sound/midiplugin.h | 31 | ||||
-rw-r--r-- | sound/null.cpp | 44 | ||||
-rw-r--r-- | sound/softsynth/adlib.cpp | 46 | ||||
-rw-r--r-- | sound/softsynth/fluidsynth.cpp | 46 | ||||
-rw-r--r-- | sound/softsynth/mt32.cpp | 45 | ||||
-rw-r--r-- | sound/softsynth/ym2612.cpp | 43 |
21 files changed, 446 insertions, 25 deletions
diff --git a/backends/midi/alsa.cpp b/backends/midi/alsa.cpp index fc43925643..6b0e424d68 100644 --- a/backends/midi/alsa.cpp +++ b/backends/midi/alsa.cpp @@ -247,6 +247,14 @@ public: return "ALSA"; } + virtual const char *getId() const { + return "alsa"; + } + + virtual int getCapabilities() const { + return MDT_MIDI; + } + virtual Common::StringList getDevices() const; virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const; @@ -309,4 +317,10 @@ MidiDriver *MidiDriver_ALSA_create(Audio::Mixer *mixer) { return mididriver; } +//#if PLUGIN_ENABLED_DYNAMIC(ALSA) + //REGISTER_PLUGIN_DYNAMIC(ALSA, PLUGIN_TYPE_MIDI, AlsaMidiPlugin); +//#else + REGISTER_PLUGIN_STATIC(ALSA, PLUGIN_TYPE_MIDI, AlsaMidiPlugin); +//#endif + #endif diff --git a/backends/midi/camd.cpp b/backends/midi/camd.cpp index 2b5ea0e065..6aa79eb260 100644 --- a/backends/midi/camd.cpp +++ b/backends/midi/camd.cpp @@ -172,6 +172,14 @@ public: return "CAMD"; } + virtual const char *getId() const { + return "camd"; + } + + virtual int getCapabilities() const { + return MDT_MIDI; + } + //virtual Common::StringList getDevices() const; virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const; @@ -192,4 +200,10 @@ MidiDriver *MidiDriver_CAMD_create(Audio::Mixer *mixer) { return mididriver; } +//#if PLUGIN_ENABLED_DYNAMIC(CAMD) + //REGISTER_PLUGIN_DYNAMIC(CAMD, PLUGIN_TYPE_MIDI, CamdMidiPlugin); +//#else + REGISTER_PLUGIN_STATIC(CAMD, PLUGIN_TYPE_MIDI, CamdMidiPlugin); +//#endif + #endif diff --git a/backends/midi/coreaudio.cpp b/backends/midi/coreaudio.cpp index 0e8409b3d8..8e00c24a1f 100644 --- a/backends/midi/coreaudio.cpp +++ b/backends/midi/coreaudio.cpp @@ -202,6 +202,14 @@ public: return "CoreAudio"; } + virtual const char *getId() const { + return "core"; + } + + virtual int getCapabilities() const { + return MDT_MIDI; + } + virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const; }; @@ -220,4 +228,10 @@ MidiDriver *MidiDriver_CORE_create(Audio::Mixer *mixer) { return mididriver; } +//#if PLUGIN_ENABLED_DYNAMIC(COREAUDIO) + //REGISTER_PLUGIN_DYNAMIC(COREAUDIO, PLUGIN_TYPE_MIDI, CoreAudioMidiPlugin); +//#else + REGISTER_PLUGIN_STATIC(COREAUDIO, PLUGIN_TYPE_MIDI, CoreAudioMidiPlugin); +//#endif + #endif // MACOSX diff --git a/backends/midi/coremidi.cpp b/backends/midi/coremidi.cpp index b16e2a91af..efbdaad4e4 100644 --- a/backends/midi/coremidi.cpp +++ b/backends/midi/coremidi.cpp @@ -185,6 +185,14 @@ public: return "CoreMIDI"; } + virtual const char *getId() const { + return "coremidi"; + } + + virtual int getCapabilities() const { + return MDT_MIDI; + } + virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const; }; @@ -203,4 +211,10 @@ MidiDriver *MidiDriver_CoreMIDI_create(Audio::Mixer *mixer) { return mididriver; } +//#if PLUGIN_ENABLED_DYNAMIC(COREMIDI) + //REGISTER_PLUGIN_DYNAMIC(COREMIDI, PLUGIN_TYPE_MIDI, CoreMIDIMidiPlugin); +//#else + REGISTER_PLUGIN_STATIC(COREMIDI, PLUGIN_TYPE_MIDI, CoreMIDIMidiPlugin); +//#endif + #endif // MACOSX diff --git a/backends/midi/dmedia.cpp b/backends/midi/dmedia.cpp index 0891af4ecb..885081e3e0 100644 --- a/backends/midi/dmedia.cpp +++ b/backends/midi/dmedia.cpp @@ -184,6 +184,14 @@ public: return "DMedia"; } + virtual const char *getId() const { + return "dmedia"; + } + + virtual int getCapabilities() const { + return MDT_MIDI; + } + virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const; }; @@ -202,4 +210,10 @@ MidiDriver *MidiDriver_DMEDIA_create(Audio::Mixer *mixer) { return mididriver; } +//#if PLUGIN_ENABLED_DYNAMIC(DMEDIA) + //REGISTER_PLUGIN_DYNAMIC(DMEDIA, PLUGIN_TYPE_MIDI, DMediaMidiPlugin); +//#else + REGISTER_PLUGIN_STATIC(DMEDIA, PLUGIN_TYPE_MIDI, DMediaMidiPlugin); +//#endif + #endif diff --git a/backends/midi/quicktime.cpp b/backends/midi/quicktime.cpp index 592d86c76b..950dfa632c 100644 --- a/backends/midi/quicktime.cpp +++ b/backends/midi/quicktime.cpp @@ -259,6 +259,14 @@ public: return "QuickTime"; } + virtual const char *getId() const { + return "qt"; + } + + virtual int getCapabilities() const { + return MDT_MIDI; + } + virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const; }; @@ -277,4 +285,10 @@ MidiDriver *MidiDriver_QT_create(Audio::Mixer *mixer) { return mididriver; } +//#if PLUGIN_ENABLED_DYNAMIC(QT) + //REGISTER_PLUGIN_DYNAMIC(QT, PLUGIN_TYPE_MIDI, QuickTimeMidiPlugin); +//#else + REGISTER_PLUGIN_STATIC(QT, PLUGIN_TYPE_MIDI, QuickTimeMidiPlugin); +//#endif + #endif // MACOSX || macintosh diff --git a/backends/midi/seq.cpp b/backends/midi/seq.cpp index 23baf60ea4..07dfc25142 100644 --- a/backends/midi/seq.cpp +++ b/backends/midi/seq.cpp @@ -179,6 +179,14 @@ public: return "SEQ"; } + virtual const char *getId() const { + return "seq"; + } + + virtual int getCapabilities() const { + return MDT_MIDI; + } + virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const; }; @@ -197,4 +205,10 @@ MidiDriver *MidiDriver_SEQ_create(Audio::Mixer *mixer) { return mididriver; } +//#if PLUGIN_ENABLED_DYNAMIC(SEQ) + //REGISTER_PLUGIN_DYNAMIC(SEQ, PLUGIN_TYPE_MIDI, SeqMidiPlugin); +//#else + REGISTER_PLUGIN_STATIC(SEQ, PLUGIN_TYPE_MIDI, SeqMidiPlugin); +//#endif + #endif diff --git a/backends/midi/timidity.cpp b/backends/midi/timidity.cpp index f146900a12..842fb358bf 100644 --- a/backends/midi/timidity.cpp +++ b/backends/midi/timidity.cpp @@ -520,6 +520,14 @@ public: return "TiMidity"; } + virtual const char *getId() const { + return "timidity"; + } + + virtual int getCapabilities() const { + return MDT_MIDI; + } + virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const; }; @@ -538,4 +546,10 @@ MidiDriver *MidiDriver_TIMIDITY_create(Audio::Mixer *mixer) { return mididriver; } +//#if PLUGIN_ENABLED_DYNAMIC(TIMIDITY) + //REGISTER_PLUGIN_DYNAMIC(TIMIDITY, PLUGIN_TYPE_MIDI, TimidityMidiPlugin); +//#else + REGISTER_PLUGIN_STATIC(TIMIDITY, PLUGIN_TYPE_MIDI, TimidityMidiPlugin); +//#endif + #endif // defined (UNIX) diff --git a/backends/midi/windows.cpp b/backends/midi/windows.cpp index 8c1d3bd9ed..083f0eaf96 100644 --- a/backends/midi/windows.cpp +++ b/backends/midi/windows.cpp @@ -153,6 +153,14 @@ public: return "Windows MIDI"; } + virtual const char *getId() const { + return "windows"; + } + + virtual int getCapabilities() const { + return MDT_MIDI; + } + virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const; }; @@ -171,4 +179,10 @@ MidiDriver *MidiDriver_WIN_create(Audio::Mixer *mixer) { return mididriver; } +//#if PLUGIN_ENABLED_DYNAMIC(WINDOWS) + //REGISTER_PLUGIN_DYNAMIC(WINDOWS, PLUGIN_TYPE_MIDI, WindowsMidiPlugin); +//#else + REGISTER_PLUGIN_STATIC(WINDOWS, PLUGIN_TYPE_MIDI, WindowsMidiPlugin); +//#endif + #endif diff --git a/backends/midi/ypa1.cpp b/backends/midi/ypa1.cpp index 416215424e..37d90d45b0 100644 --- a/backends/midi/ypa1.cpp +++ b/backends/midi/ypa1.cpp @@ -112,6 +112,14 @@ public: return "Yamaha Pa1"; } + virtual const char *getId() const { + return "ypa1"; + } + + virtual int getCapabilities() const { + return MDT_MIDI; + } + virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const; }; @@ -129,3 +137,9 @@ MidiDriver *MidiDriver_YamahaPa1_create(Audio::Mixer *mixer) { return mididriver; } + +//#if PLUGIN_ENABLED_DYNAMIC(YPA1) + //REGISTER_PLUGIN_DYNAMIC(YPA1, PLUGIN_TYPE_MIDI, YamahaPa1MidiPlugin); +//#else + REGISTER_PLUGIN_STATIC(YPA1, PLUGIN_TYPE_MIDI, YamahaPa1MidiPlugin); +//#endif diff --git a/backends/midi/zodiac.cpp b/backends/midi/zodiac.cpp index 0cc848f1d5..f27c042de8 100644 --- a/backends/midi/zodiac.cpp +++ b/backends/midi/zodiac.cpp @@ -130,6 +130,14 @@ public: return "Tapwave Zodiac"; } + virtual const char *getId() const { + return "zodiac"; + } + + virtual int getCapabilities() const { + return MDT_MIDI; + } + virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const; }; @@ -148,4 +156,10 @@ MidiDriver *MidiDriver_Zodiac_create(Audio::Mixer *mixer) { return mididriver; } +//#if PLUGIN_ENABLED_DYNAMIC(ZODIAC) + //REGISTER_PLUGIN_DYNAMIC(ZODIAC, PLUGIN_TYPE_MIDI, ZodiacMidiPlugin); +//#else + REGISTER_PLUGIN_STATIC(ZODIAC, PLUGIN_TYPE_MIDI, ZodiacMidiPlugin); +//#endif + #endif diff --git a/base/plugins.cpp b/base/plugins.cpp index c39b877eb8..7dae94e006 100644 --- a/base/plugins.cpp +++ b/base/plugins.cpp @@ -33,6 +33,7 @@ int pluginTypeVersions[PLUGIN_TYPE_MAX] = { PLUGIN_TYPE_ENGINE_VERSION, + PLUGIN_TYPE_MIDI_VERSION, }; @@ -82,6 +83,7 @@ public: // "Loader" for the static plugins. // Iterate over all registered (static) plugins and load them. + // Engine plugins #if PLUGIN_ENABLED_STATIC(SCUMM) LINK_PLUGIN(SCUMM) #endif @@ -140,6 +142,49 @@ public: LINK_PLUGIN(TOUCHE) #endif + // MIDI plugins + // TODO: Use defines to disable or enable each MIDI driver as a + // static/dynamic plugin, like it's done for the engines + LINK_PLUGIN(NULL) + #if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__SYMBIAN32__) + LINK_PLUGIN(WINDOWS) + #endif + #if defined(UNIX) && defined(USE_ALSA) + LINK_PLUGIN(ALSA) + #endif + #if defined(UNIX) && !defined(__BEOS__) && !defined(__MAEMO__) + LINK_PLUGIN(SEQ) + #endif + #if defined(IRIX) + LINK_PLUGIN(DMEDIA) + #endif + #if defined(__amigaos4__) + LINK_PLUGIN(CAMD) + #endif + #if defined(MACOSX) + LINK_PLUGIN(COREAUDIO) + LINK_PLUGIN(COREMIDI) + LINK_PLUGIN(QUICKTIME) + #endif + #if defined(PALMOS_MODE) + # if defined(COMPILE_CLIE) + LINK_PLUGIN(YPA1) + # elif defined(COMPILE_ZODIAC) && (!defined(ENABLE_SCUMM) || !defined(PALMOS_ARM)) + LINK_PLUGIN(ZODIAC) + # endif + #endif + #ifdef USE_FLUIDSYNTH + LINK_PLUGIN(FLUIDSYNTH) + #endif + #ifdef USE_MT32EMU + LINK_PLUGIN(MT32) + #endif + LINK_PLUGIN(ADLIB) + LINK_PLUGIN(TOWNS) + #if defined (UNIX) + LINK_PLUGIN(TIMIDITY) + #endif + return pl; } }; @@ -336,3 +381,14 @@ GameList EngineManager::detectGames(const FSList &fslist) const { const EnginePlugin::list &EngineManager::getPlugins() const { return (const EnginePlugin::list&)PluginManager::instance().getPlugins(PLUGIN_TYPE_ENGINE); } + + +// MIDI plugins + +#include "sound/midiplugin.h" + +DECLARE_SINGLETON(MidiManager); + +const MidiPlugin::list &MidiManager::getPlugins() const { + return (const MidiPlugin::list&)PluginManager::instance().getPlugins(PLUGIN_TYPE_MIDI); +} diff --git a/base/plugins.h b/base/plugins.h index 92b317498f..b64334074c 100644 --- a/base/plugins.h +++ b/base/plugins.h @@ -63,6 +63,7 @@ enum PluginType { PLUGIN_TYPE_ENGINE = 0, + PLUGIN_TYPE_MIDI, PLUGIN_TYPE_MAX }; @@ -70,6 +71,7 @@ enum PluginType { // TODO: Make the engine API version depend on ScummVM's version // because of the backlinking #define PLUGIN_TYPE_ENGINE_VERSION 1 +#define PLUGIN_TYPE_MIDI_VERSION 1 extern int pluginTypeVersions[PLUGIN_TYPE_MAX]; diff --git a/sound/mididrv.cpp b/sound/mididrv.cpp index 52cf5d0e65..358d42d751 100644 --- a/sound/mididrv.cpp +++ b/sound/mididrv.cpp @@ -216,7 +216,7 @@ int MidiDriver::detectMusicDriver(int flags) { MidiDriver *MidiDriver::createMidi(int midiDriver) { switch (midiDriver) { - case MD_NULL: return MidiDriver_NULL_create(); + case MD_NULL: return MidiDriver_NULL_create(g_system->getMixer()); case MD_ADLIB: return MidiDriver_ADLIB_create(g_system->getMixer()); diff --git a/sound/mididrv.h b/sound/mididrv.h index 77b10518bc..12513268a8 100644 --- a/sound/mididrv.h +++ b/sound/mididrv.h @@ -268,7 +268,7 @@ public: // Factory functions, for faster compile -extern MidiDriver *MidiDriver_NULL_create(); +extern MidiDriver *MidiDriver_NULL_create(Audio::Mixer *mixer); extern MidiDriver *MidiDriver_ADLIB_create(Audio::Mixer *mixer); extern MidiDriver *MidiDriver_WIN_create(Audio::Mixer *mixer); extern MidiDriver *MidiDriver_SEQ_create(Audio::Mixer *mixer); diff --git a/sound/midiplugin.h b/sound/midiplugin.h index f36aa2c822..c3b407a142 100644 --- a/sound/midiplugin.h +++ b/sound/midiplugin.h @@ -37,6 +37,18 @@ public: virtual ~MidiPluginObject() {} /** + * Returns a unique string identifier which will be used to save the + * selected MIDI driver to the config file. + */ + virtual const char *getId() const = 0; + + /** + * Returns the type kind of music supported by this driver, as specified + * by the MidiDriverFlags enum. + */ + virtual int getCapabilities() const = 0; + + /** * Returns a list of the available devices. The empty string means the * default device. */ @@ -59,4 +71,23 @@ public: virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const = 0; }; + +// MIDI plugins + +typedef PluginSubclass<MidiPluginObject> MidiPlugin; + +/** + * Singleton class which manages all MIDI plugins. + */ +class MidiManager : public Common::Singleton<MidiManager> { +private: + friend class Common::Singleton<SingletonBaseType>; + +public: + const MidiPlugin::list &getPlugins() const; +}; + +/** Convenience shortcut for accessing the MIDI manager. */ +#define MidiMan MidiManager::instance() + #endif diff --git a/sound/null.cpp b/sound/null.cpp index 49c57052f9..9bb3a76344 100644 --- a/sound/null.cpp +++ b/sound/null.cpp @@ -22,6 +22,7 @@ * $Id$ */ +#include "sound/midiplugin.h" #include "sound/mpu401.h" /* NULL driver */ @@ -31,12 +32,49 @@ public: void send(uint32 b) { } }; -MidiDriver *MidiDriver_NULL_create() { - return new MidiDriver_NULL(); + +// Plugin interface + +class NullMidiPlugin : public MidiPluginObject { +public: + virtual const char *getName() const { + return "No music"; + } + + virtual const char *getId() const { + return "null"; + } + + virtual int getCapabilities() const { + return MDT_MIDI | MDT_PCSPK | MDT_ADLIB | MDT_TOWNS; + } + + virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const; +}; + +PluginError NullMidiPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const { + *mididriver = new MidiDriver_NULL(); + + return kNoError; +} + +MidiDriver *MidiDriver_NULL_create(Audio::Mixer *mixer) { + MidiDriver *mididriver; + + NullMidiPlugin p; + p.createInstance(mixer, &mididriver); + + return mididriver; } #ifdef DISABLE_ADLIB MidiDriver *MidiDriver_ADLIB_create(Audio::Mixer *mixer) { - return new MidiDriver_NULL(); + return MidiDriver_NULL_create(mixer); } #endif + +//#if PLUGIN_ENABLED_DYNAMIC(NULL) + //REGISTER_PLUGIN_DYNAMIC(NULL, PLUGIN_TYPE_MIDI, NullMidiPlugin); +//#else + REGISTER_PLUGIN_STATIC(NULL, PLUGIN_TYPE_MIDI, NullMidiPlugin); +//#endif diff --git a/sound/softsynth/adlib.cpp b/sound/softsynth/adlib.cpp index 1cf4c2b179..3936843f52 100644 --- a/sound/softsynth/adlib.cpp +++ b/sound/softsynth/adlib.cpp @@ -25,6 +25,7 @@ #include "sound/softsynth/emumidi.h" #include "common/util.h" #include "sound/fmopl.h" +#include "sound/midiplugin.h" #ifdef DEBUG_ADLIB static int tick; @@ -970,10 +971,6 @@ MidiChannel *MidiDriver_ADLIB::allocateChannel() { return NULL; } -MidiDriver *MidiDriver_ADLIB_create(Audio::Mixer *mixer) { - return new MidiDriver_ADLIB(mixer); -} - // All the code brought over from IMuseAdlib void MidiDriver_ADLIB::adlib_write(byte port, byte value) { @@ -1517,3 +1514,44 @@ void MidiDriver_ADLIB::adlib_note_on(int chan, byte note, int mod) { curnote_table[chan] = code; adlib_playnote(chan, (int16) channel_table_2[chan] + code); } + + +// Plugin interface + +class AdlibMidiPlugin : public MidiPluginObject { +public: + virtual const char *getName() const { + return "AdLib Emulator"; + } + + virtual const char *getId() const { + return "adlib"; + } + + virtual int getCapabilities() const { + return MDT_ADLIB; + } + + virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const; +}; + +PluginError AdlibMidiPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const { + *mididriver = new MidiDriver_ADLIB(mixer); + + return kNoError; +} + +MidiDriver *MidiDriver_ADLIB_create(Audio::Mixer *mixer) { + MidiDriver *mididriver; + + AdlibMidiPlugin p; + p.createInstance(mixer, &mididriver); + + return mididriver; +} + +//#if PLUGIN_ENABLED_DYNAMIC(ADLIB) + //REGISTER_PLUGIN_DYNAMIC(ADLIB, PLUGIN_TYPE_MIDI, AdlibMidiPlugin); +//#else + REGISTER_PLUGIN_STATIC(ADLIB, PLUGIN_TYPE_MIDI, AdlibMidiPlugin); +//#endif diff --git a/sound/softsynth/fluidsynth.cpp b/sound/softsynth/fluidsynth.cpp index 4a61cd023b..ae89a8df8a 100644 --- a/sound/softsynth/fluidsynth.cpp +++ b/sound/softsynth/fluidsynth.cpp @@ -27,6 +27,7 @@ #ifdef USE_FLUIDSYNTH #include "common/config-manager.h" +#include "sound/midiplugin.h" #include "sound/mpu401.h" #include "sound/softsynth/emumidi.h" @@ -211,12 +212,49 @@ MidiChannel *MidiDriver_FluidSynth::getPercussionChannel() { return &_midiChannels[9]; } -MidiDriver *MidiDriver_FluidSynth_create(Audio::Mixer *mixer) { - return new MidiDriver_FluidSynth(mixer); -} - void MidiDriver_FluidSynth::generateSamples(int16 *data, int len) { fluid_synth_write_s16(_synth, len, data, 0, 2, data, 1, 2); } + +// Plugin interface + +class FluidSynthMidiPlugin : public MidiPluginObject { +public: + virtual const char *getName() const { + return "FluidSynth"; + } + + virtual const char *getId() const { + return "fluidsynth"; + } + + virtual int getCapabilities() const { + return MDT_MIDI; + } + + virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const; +}; + +PluginError FluidSynthMidiPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const { + *mididriver = new MidiDriver_FluidSynth(mixer); + + return kNoError; +} + +MidiDriver *MidiDriver_FluidSynth_create(Audio::Mixer *mixer) { + MidiDriver *mididriver; + + FluidSynthMidiPlugin p; + p.createInstance(mixer, &mididriver); + + return mididriver; +} + +//#if PLUGIN_ENABLED_DYNAMIC(FLUIDSYNTH) + //REGISTER_PLUGIN_DYNAMIC(FLUIDSYNTH, PLUGIN_TYPE_MIDI, FluidSynthMidiPlugin); +//#else + REGISTER_PLUGIN_STATIC(FLUIDSYNTH, PLUGIN_TYPE_MIDI, FluidSynthMidiPlugin); +//#endif + #endif diff --git a/sound/softsynth/mt32.cpp b/sound/softsynth/mt32.cpp index 706db826af..2c9c4f24be 100644 --- a/sound/softsynth/mt32.cpp +++ b/sound/softsynth/mt32.cpp @@ -29,6 +29,7 @@ #include "sound/softsynth/mt32/mt32emu.h" #include "sound/softsynth/emumidi.h" +#include "sound/midiplugin.h" #include "sound/mpu401.h" #include "common/config-manager.h" @@ -479,17 +480,49 @@ void MidiDriver_ThreadedMT32::onTimer() { } #endif -//////////////////////////////////////// -// -// MidiDriver_MT32 factory -// -//////////////////////////////////////// + +// Plugin interface + +class MT32MidiPlugin : public MidiPluginObject { +public: + virtual const char *getName() const { + return "MT-32 Emulator"; + } + + virtual const char *getId() const { + return "mt32"; + } + + virtual int getCapabilities() const { + return MDT_MIDI; + } + + virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const; +}; + +PluginError MT32MidiPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const { + *mididriver = new MidiDriver_MT32(mixer); + + return kNoError; +} MidiDriver *MidiDriver_MT32_create(Audio::Mixer *mixer) { // HACK: It will stay here until engine plugin loader overhaul if (ConfMan.hasKey("extrapath")) Common::File::addDefaultDirectory(ConfMan.get("extrapath")); - return new MidiDriver_MT32(mixer); + + MidiDriver *mididriver; + + MT32MidiPlugin p; + p.createInstance(mixer, &mididriver); + + return mididriver; } +//#if PLUGIN_ENABLED_DYNAMIC(MT32) + //REGISTER_PLUGIN_DYNAMIC(MT32, PLUGIN_TYPE_MIDI, MT32MidiPlugin); +//#else + REGISTER_PLUGIN_STATIC(MT32, PLUGIN_TYPE_MIDI, MT32MidiPlugin); +//#endif + #endif diff --git a/sound/softsynth/ym2612.cpp b/sound/softsynth/ym2612.cpp index 1e985aeb1c..3fcc2c3fc4 100644 --- a/sound/softsynth/ym2612.cpp +++ b/sound/softsynth/ym2612.cpp @@ -26,6 +26,7 @@ #include "sound/softsynth/ym2612.h" #include "common/util.h" +#include "sound/midiplugin.h" //////////////////////////////////////// // @@ -751,13 +752,43 @@ void MidiDriver_YM2612::removeLookupTables() { sintbl = powtbl = frequencyTable = keycodeTable = keyscaleTable = attackOut = 0; } -//////////////////////////////////////// -// -// MidiDriver_YM2612 factory -// -//////////////////////////////////////// + +// Plugin interface + +class TownsMidiPlugin : public MidiPluginObject { +public: + virtual const char *getName() const { + return "FM Towns Emulator"; + } + + virtual const char *getId() const { + return "towns"; + } + + virtual int getCapabilities() const { + return MDT_TOWNS; + } + + virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const; +}; + +PluginError TownsMidiPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const { + *mididriver = new MidiDriver_YM2612(mixer); + + return kNoError; +} MidiDriver *MidiDriver_YM2612_create(Audio::Mixer *mixer) { - return new MidiDriver_YM2612(mixer); + MidiDriver *mididriver; + + TownsMidiPlugin p; + p.createInstance(mixer, &mididriver); + + return mididriver; } +//#if PLUGIN_ENABLED_DYNAMIC(TOWNS) + //REGISTER_PLUGIN_DYNAMIC(TOWNS, PLUGIN_TYPE_MIDI, TownsMidiPlugin); +//#else + REGISTER_PLUGIN_STATIC(TOWNS, PLUGIN_TYPE_MIDI, TownsMidiPlugin); +//#endif |