aboutsummaryrefslogtreecommitdiff
path: root/sound/softsynth
diff options
context:
space:
mode:
authorJordi Vilalta Prat2008-05-14 14:56:29 +0000
committerJordi Vilalta Prat2008-05-14 14:56:29 +0000
commiteb6c809d2b3ccf238fa5efbf45b6cd2b00a82cd9 (patch)
treed52fc76e91a873d7f457b6f97cb57039210895ee /sound/softsynth
parente2d58f4885352744c88892e93fe2cdd33ecfa1b0 (diff)
downloadscummvm-rg350-eb6c809d2b3ccf238fa5efbf45b6cd2b00a82cd9.tar.gz
scummvm-rg350-eb6c809d2b3ccf238fa5efbf45b6cd2b00a82cd9.tar.bz2
scummvm-rg350-eb6c809d2b3ccf238fa5efbf45b6cd2b00a82cd9.zip
- Added more information (ID and capabilities) to the MIDI drivers
- Added the MidiPlugin interface to the remaining MIDI drivers - Added an initial MidiManager to handle the MIDI plugins (just static plugins by now) svn-id: r32117
Diffstat (limited to 'sound/softsynth')
-rw-r--r--sound/softsynth/adlib.cpp46
-rw-r--r--sound/softsynth/fluidsynth.cpp46
-rw-r--r--sound/softsynth/mt32.cpp45
-rw-r--r--sound/softsynth/ym2612.cpp43
4 files changed, 160 insertions, 20 deletions
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