1 /* ScummVM - Graphic Adventure Engine
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 #ifndef SOUND_MUSICPLUGIN_H
26 #define SOUND_MUSICPLUGIN_H
28 #include "base/plugins.h"
29 #include "sound/mididrv.h"
30 #include "common/list.h"
33 * Music types that music drivers can implement and engines can rely on.
36 MT_PCSPK
= 1, // PC Speaker
38 MT_ADLIB
= 3, // AdLib
39 MT_TOWNS
= 4, // FM-TOWNS
40 MT_GM
= 5, // General MIDI
42 MT_GS
= 7 // Roland GS
45 class MusicPluginObject
;
48 * Description of a Music device. Used to list the devices a Music driver
49 * can manage and their capabilities.
50 * A device with an empty name means the default device.
54 MusicDevice(MusicPluginObject
const *musicPlugin
, Common::String name
, MusicType mt
);
56 Common::String
&getName() { return _name
; }
57 Common::String
&getMusicDriverName() { return _musicDriverName
; }
58 Common::String
&getMusicDriverId() { return _musicDriverId
; }
59 MusicType
getMusicType() { return _type
; }
62 * Returns a user readable string that contains the name of the current
63 * device name (if it isn't the default one) and the name of the driver.
65 Common::String
getCompleteName();
69 Common::String _musicDriverName
;
70 Common::String _musicDriverId
;
74 /** List of music devices. */
75 typedef Common::List
<MusicDevice
> MusicDevices
;
78 * A MusicPluginObject is essentially a factory for MidiDriver instances with
79 * the added ability of listing the available devices and their capabilities.
81 class MusicPluginObject
: public PluginObject
{
83 virtual ~MusicPluginObject() {}
86 * Returns a unique string identifier which will be used to save the
87 * selected MIDI driver to the config file.
89 virtual const char *getId() const = 0;
92 * Returns a list of the available devices.
94 virtual MusicDevices
getDevices() const = 0;
97 * Tries to instantiate a MIDI Driver instance based on the settings of
98 * the currently active ConfMan target. That is, the MusicPluginObject
99 * should query the ConfMan singleton for the device name, port, etc.
101 * @param mixer Pointer to the global Mixer object
102 * @param mididriver Pointer to a pointer which the MusicPluginObject sets
103 * to the newly create MidiDriver, or 0 in case of an error
104 * @return a Common::Error describing the error which occurred, or kNoError
106 virtual Common::Error
createInstance(Audio::Mixer
*mixer
, MidiDriver
**mididriver
) const = 0;
112 typedef PluginSubclass
<MusicPluginObject
> MusicPlugin
;
115 * Singleton class which manages all Music plugins.
117 class MusicManager
: public Common::Singleton
<MusicManager
> {
119 friend class Common::Singleton
<SingletonBaseType
>;
122 const MusicPlugin::List
&getPlugins() const;
125 /** Convenience shortcut for accessing the Music manager. */
126 #define MusicMan MusicManager::instance()