From eb6c809d2b3ccf238fa5efbf45b6cd2b00a82cd9 Mon Sep 17 00:00:00 2001 From: Jordi Vilalta Prat Date: Wed, 14 May 2008 14:56:29 +0000 Subject: - 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 --- sound/softsynth/fluidsynth.cpp | 46 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) (limited to 'sound/softsynth/fluidsynth.cpp') 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 -- cgit v1.2.3