aboutsummaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
Diffstat (limited to 'sound')
-rw-r--r--sound/module.mk1
-rw-r--r--sound/musicplugin.cpp48
-rw-r--r--sound/musicplugin.h60
-rw-r--r--sound/null.cpp18
-rw-r--r--sound/softsynth/adlib.cpp27
-rw-r--r--sound/softsynth/fluidsynth.cpp17
-rw-r--r--sound/softsynth/mt32.cpp27
-rw-r--r--sound/softsynth/ym2612.cpp27
8 files changed, 162 insertions, 63 deletions
diff --git a/sound/module.mk b/sound/module.mk
index 2f3dc1f987..d99013e7d0 100644
--- a/sound/module.mk
+++ b/sound/module.mk
@@ -15,6 +15,7 @@ MODULE_OBJS := \
mixer.o \
mp3.o \
mpu401.o \
+ musicplugin.o \
null.o \
voc.o \
vorbis.o \
diff --git a/sound/musicplugin.cpp b/sound/musicplugin.cpp
new file mode 100644
index 0000000000..b4754230da
--- /dev/null
+++ b/sound/musicplugin.cpp
@@ -0,0 +1,48 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "sound/musicplugin.h"
+
+MusicDevice::MusicDevice(MusicPluginObject const *musicPlugin, Common::String name, MusicType mt) :
+ _musicDriverName(musicPlugin->getName()), _musicDriverId(musicPlugin->getId()),
+ _name(name), _type(mt) {
+}
+
+Common::String MusicDevice::getCompleteName() {
+ Common::String name;
+
+ if (_name.empty()) {
+ // Default device, just show the driver name
+ name = _musicDriverName;
+ } else {
+ // Show both device and driver names
+ name = _name;
+ name += " [";
+ name += _musicDriverName;
+ name += "]";
+ }
+
+ return name;
+}
diff --git a/sound/musicplugin.h b/sound/musicplugin.h
index 316ee1fbf3..bdbd07ad31 100644
--- a/sound/musicplugin.h
+++ b/sound/musicplugin.h
@@ -29,6 +29,51 @@
#include "sound/mididrv.h"
/**
+ * Music types that music drivers can implement and engines can rely on.
+ */
+enum MusicType {
+ MT_PCSPK = 1, // PC Speaker
+ MT_PCJR = 2, // PCjr
+ MT_ADLIB = 3, // AdLib
+ MT_TOWNS = 4, // FM-TOWNS
+ MT_GM = 5, // General MIDI
+ MT_MT32 = 6, // MT-32
+ MT_GS = 7 // Roland GS
+};
+
+class MusicPluginObject;
+
+/**
+ * Description of a Music device. Used to list the devices a Music driver
+ * can manage and their capabilities.
+ * A device with an empty name means the default device.
+ */
+class MusicDevice {
+public:
+ MusicDevice(MusicPluginObject const *musicPlugin, Common::String name, MusicType mt);
+
+ Common::String &getName() { return _name; }
+ Common::String &getMusicDriverName() { return _musicDriverName; }
+ Common::String &getMusicDriverId() { return _musicDriverId; }
+ MusicType getMusicType() { return _type; }
+
+ /**
+ * Returns a user readable string that contains the name of the current
+ * device name (if it isn't the default one) and the name of the driver.
+ */
+ Common::String getCompleteName();
+
+private:
+ Common::String _name;
+ Common::String _musicDriverName;
+ Common::String _musicDriverId;
+ MusicType _type;
+};
+
+/** List of music devices. */
+typedef Common::List<MusicDevice> MusicDevices;
+
+/**
* A MusicPluginObject is essentially a factory for MidiDriver instances with
* the added ability of listing the available devices and their capabilities.
*/
@@ -43,20 +88,9 @@ public:
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.
+ * Returns a list of the available devices.
*/
- virtual Common::StringList getDevices() const {
- Common::StringList dev;
- dev.push_back("");
- return dev;
- }
+ virtual MusicDevices getDevices() const = 0;
/**
* Tries to instantiate a MIDI Driver instance based on the settings of
diff --git a/sound/null.cpp b/sound/null.cpp
index 763299d5a3..7559a6d816 100644
--- a/sound/null.cpp
+++ b/sound/null.cpp
@@ -37,19 +37,16 @@ public:
class NullMusicPlugin : public MusicPluginObject {
public:
- virtual const char *getName() const {
+ const char *getName() const {
return "No music";
}
- virtual const char *getId() const {
+ 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;
+ MusicDevices getDevices() const;
+ PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
};
PluginError NullMusicPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
@@ -58,6 +55,13 @@ PluginError NullMusicPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mi
return kNoError;
}
+MusicDevices NullMusicPlugin::getDevices() const {
+ MusicDevices devices;
+ // TODO: return a different music type?
+ devices.push_back(MusicDevice(this, "", MT_GM));
+ return devices;
+}
+
MidiDriver *MidiDriver_NULL_create(Audio::Mixer *mixer) {
MidiDriver *mididriver;
diff --git a/sound/softsynth/adlib.cpp b/sound/softsynth/adlib.cpp
index beedaf5c3b..3898956e15 100644
--- a/sound/softsynth/adlib.cpp
+++ b/sound/softsynth/adlib.cpp
@@ -1518,24 +1518,27 @@ void MidiDriver_ADLIB::adlib_note_on(int chan, byte note, int mod) {
// Plugin interface
-class AdlibMusicPlugin : public MusicPluginObject {
+class AdlibEmuMusicPlugin : public MusicPluginObject {
public:
- virtual const char *getName() const {
+ const char *getName() const {
return "AdLib Emulator";
}
- virtual const char *getId() const {
+ const char *getId() const {
return "adlib";
}
- virtual int getCapabilities() const {
- return MDT_ADLIB;
- }
-
- virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
+ MusicDevices getDevices() const;
+ PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
};
-PluginError AdlibMusicPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
+MusicDevices AdlibEmuMusicPlugin::getDevices() const {
+ MusicDevices devices;
+ devices.push_back(MusicDevice(this, "", MT_ADLIB));
+ return devices;
+}
+
+PluginError AdlibEmuMusicPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
*mididriver = new MidiDriver_ADLIB(mixer);
return kNoError;
@@ -1544,14 +1547,14 @@ PluginError AdlibMusicPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **m
MidiDriver *MidiDriver_ADLIB_create(Audio::Mixer *mixer) {
MidiDriver *mididriver;
- AdlibMusicPlugin p;
+ AdlibEmuMusicPlugin p;
p.createInstance(mixer, &mididriver);
return mididriver;
}
//#if PLUGIN_ENABLED_DYNAMIC(ADLIB)
- //REGISTER_PLUGIN_DYNAMIC(ADLIB, PLUGIN_TYPE_MUSIC, AdlibMusicPlugin);
+ //REGISTER_PLUGIN_DYNAMIC(ADLIB, PLUGIN_TYPE_MUSIC, AdlibEmuMusicPlugin);
//#else
- REGISTER_PLUGIN_STATIC(ADLIB, PLUGIN_TYPE_MUSIC, AdlibMusicPlugin);
+ REGISTER_PLUGIN_STATIC(ADLIB, PLUGIN_TYPE_MUSIC, AdlibEmuMusicPlugin);
//#endif
diff --git a/sound/softsynth/fluidsynth.cpp b/sound/softsynth/fluidsynth.cpp
index f2dcb2de7a..eff9f4123c 100644
--- a/sound/softsynth/fluidsynth.cpp
+++ b/sound/softsynth/fluidsynth.cpp
@@ -221,21 +221,24 @@ void MidiDriver_FluidSynth::generateSamples(int16 *data, int len) {
class FluidSynthMusicPlugin : public MusicPluginObject {
public:
- virtual const char *getName() const {
+ const char *getName() const {
return "FluidSynth";
}
- virtual const char *getId() const {
+ const char *getId() const {
return "fluidsynth";
}
- virtual int getCapabilities() const {
- return MDT_MIDI;
- }
-
- virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
+ MusicDevices getDevices() const;
+ PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
};
+MusicDevices FluidSynthMusicPlugin::getDevices() const {
+ MusicDevices devices;
+ devices.push_back(MusicDevice(this, "", MT_GM));
+ return devices;
+}
+
PluginError FluidSynthMusicPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
*mididriver = new MidiDriver_FluidSynth(mixer);
diff --git a/sound/softsynth/mt32.cpp b/sound/softsynth/mt32.cpp
index 112fbb4bfe..053df544b1 100644
--- a/sound/softsynth/mt32.cpp
+++ b/sound/softsynth/mt32.cpp
@@ -483,24 +483,27 @@ void MidiDriver_ThreadedMT32::onTimer() {
// Plugin interface
-class MT32MusicPlugin : public MusicPluginObject {
+class MT32EmuMusicPlugin : public MusicPluginObject {
public:
- virtual const char *getName() const {
+ const char *getName() const {
return "MT-32 Emulator";
}
- virtual const char *getId() const {
+ const char *getId() const {
return "mt32";
}
- virtual int getCapabilities() const {
- return MDT_MIDI;
- }
-
- virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
+ MusicDevices getDevices() const;
+ PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
};
-PluginError MT32MusicPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
+MusicDevices MT32EmuMusicPlugin::getDevices() const {
+ MusicDevices devices;
+ devices.push_back(MusicDevice(this, "", MT_MT32));
+ return devices;
+}
+
+PluginError MT32EmuMusicPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
*mididriver = new MidiDriver_MT32(mixer);
return kNoError;
@@ -513,16 +516,16 @@ MidiDriver *MidiDriver_MT32_create(Audio::Mixer *mixer) {
MidiDriver *mididriver;
- MT32MusicPlugin p;
+ MT32EmuMusicPlugin p;
p.createInstance(mixer, &mididriver);
return mididriver;
}
//#if PLUGIN_ENABLED_DYNAMIC(MT32)
- //REGISTER_PLUGIN_DYNAMIC(MT32, PLUGIN_TYPE_MUSIC, MT32MusicPlugin);
+ //REGISTER_PLUGIN_DYNAMIC(MT32, PLUGIN_TYPE_MUSIC, MT32EmuMusicPlugin);
//#else
- REGISTER_PLUGIN_STATIC(MT32, PLUGIN_TYPE_MUSIC, MT32MusicPlugin);
+ REGISTER_PLUGIN_STATIC(MT32, PLUGIN_TYPE_MUSIC, MT32EmuMusicPlugin);
//#endif
#endif
diff --git a/sound/softsynth/ym2612.cpp b/sound/softsynth/ym2612.cpp
index 186300e1fe..2a08bf631e 100644
--- a/sound/softsynth/ym2612.cpp
+++ b/sound/softsynth/ym2612.cpp
@@ -755,24 +755,27 @@ void MidiDriver_YM2612::removeLookupTables() {
// Plugin interface
-class TownsMusicPlugin : public MusicPluginObject {
+class TownsEmuMusicPlugin : public MusicPluginObject {
public:
- virtual const char *getName() const {
+ const char *getName() const {
return "FM Towns Emulator";
}
- virtual const char *getId() const {
+ const char *getId() const {
return "towns";
}
- virtual int getCapabilities() const {
- return MDT_TOWNS;
- }
-
- virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
+ MusicDevices getDevices() const;
+ PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
};
-PluginError TownsMusicPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
+MusicDevices TownsEmuMusicPlugin::getDevices() const {
+ MusicDevices devices;
+ devices.push_back(MusicDevice(this, "", MT_TOWNS));
+ return devices;
+}
+
+PluginError TownsEmuMusicPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
*mididriver = new MidiDriver_YM2612(mixer);
return kNoError;
@@ -781,14 +784,14 @@ PluginError TownsMusicPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **m
MidiDriver *MidiDriver_YM2612_create(Audio::Mixer *mixer) {
MidiDriver *mididriver;
- TownsMusicPlugin p;
+ TownsEmuMusicPlugin p;
p.createInstance(mixer, &mididriver);
return mididriver;
}
//#if PLUGIN_ENABLED_DYNAMIC(TOWNS)
- //REGISTER_PLUGIN_DYNAMIC(TOWNS, PLUGIN_TYPE_MUSIC, TownsMusicPlugin);
+ //REGISTER_PLUGIN_DYNAMIC(TOWNS, PLUGIN_TYPE_MUSIC, TownsEmuMusicPlugin);
//#else
- REGISTER_PLUGIN_STATIC(TOWNS, PLUGIN_TYPE_MUSIC, TownsMusicPlugin);
+ REGISTER_PLUGIN_STATIC(TOWNS, PLUGIN_TYPE_MUSIC, TownsEmuMusicPlugin);
//#endif