ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

Abstract MIDI Driver Class. More...

#include <mididrv.h>

Inheritance diagram for MidiDriver:
Collaboration diagram for MidiDriver:

List of all members.

Public Types

enum  DeviceStringType { kDriverName, kDriverId, kDeviceName, kDeviceId }
enum  { MERR_CANNOT_CONNECT = 1, MERR_DEVICE_NOT_AVAILABLE = 3, MERR_ALREADY_OPEN = 4 }
 

Error codes returned by open.

More...
enum  { PROP_OLD_ADLIB = 2, PROP_CHANNEL_MASK = 3, PROP_SCUMM_OPL3 = 4 }
typedef uint32 DeviceHandle
 The device handle.

Public Member Functions

void midiDriverCommonSend (uint32 b)
 Common operations to be done by all drivers on start of send.
void midiDriverCommonSysEx (const byte *msg, uint16 length)
 Common operations to be done by all drivers on start of sysEx.
 MidiDriver ()
virtual ~MidiDriver ()
virtual int open ()=0
 Open the midi driver.
virtual bool isOpen () const =0
 Check whether the midi driver has already been opened.
virtual void close ()=0
 Close the midi driver.
virtual uint32 property (int prop, uint32 param)
 Get or set a property.
virtual void setPitchBendRange (byte channel, uint range)
void initMT32 (bool initForGM)
 Initializes the MT-32 MIDI device.
void sendMT32Reset ()
 Send a Roland MT-32 reset sysEx to the midi device.
void initGM (bool initForMT32, bool enableGS)
 Initializes the General MIDI device.
void sendGMReset ()
 Send a General MIDI reset sysEx to the midi device.
virtual void sysEx_customInstrument (byte channel, uint32 type, const byte *instr)
virtual void setTimerCallback (void *timer_param, Common::TimerManager::TimerProc timer_proc)=0
virtual uint32 getBaseTempo ()=0
 The time in microseconds between invocations of the timer callback.
virtual MidiChannelallocateChannel ()=0
virtual MidiChannelgetPercussionChannel ()=0
virtual void setEngineSoundFont (Common::SeekableReadStream *soundFontData)
virtual bool acceptsSoundFontData ()

Static Public Member Functions

static Common::String musicType2GUIO (uint32 musicType)
static MidiDrivercreateMidi (DeviceHandle handle)
 Create music driver matching the given device handle, or NULL if there is no match.
static DeviceHandle detectDevice (int flags)
 Returns device handle based on the present devices and the flags parameter.
static DeviceHandle getDeviceHandle (const Common::String &identifier)
 Find the music driver matching the given driver name/description.
static bool checkDevice (DeviceHandle handle)
 Check whether the device with the given handle is available.
static MusicType getMusicType (DeviceHandle handle)
 Get the music type matching the given device handle, or MT_AUTO if there is no match.
static Common::String getDeviceString (DeviceHandle handle, DeviceStringType type)
 Get the device description string matching the given device handle and the given type.
static const char * getErrorName (int error_code)
 Retrieve a string representation of an error code.

Static Public Attributes

static const byte _mt32ToGm [128]
static const byte _gmToMt32 [128]
static const byte _mt32DefaultInstruments [8]
static const byte _mt32DefaultPanning [8]
static const uint8 _gsDrumkitFallbackMap [128]

Protected Member Functions

byte correctInstrumentBank (byte outputChannel, byte patchId)
 Checks if the currently selected GS bank / instrument variation on the specified channel is valid for the specified patch.

Protected Attributes

bool _reversePanning
bool _scaleGSPercussionVolumeToMT32
byte _gsBank [16]

Static Private Attributes

static bool _forceTypeMT32 = false

Detailed Description

Abstract MIDI Driver Class.

Todo:
Rename MidiDriver to MusicDriver

Definition at line 229 of file mididrv.h.


Member Typedef Documentation

The device handle.

The value 0 is reserved for an invalid device for now. TODO: Maybe we should use -1 (i.e. 0xFFFFFFFF) as invalid device?

Definition at line 238 of file mididrv.h.


Member Enumeration Documentation

anonymous enum

Error codes returned by open.

Can be converted to a string with getErrorName().

Enumerator:
MERR_CANNOT_CONNECT 
MERR_DEVICE_NOT_AVAILABLE 
MERR_ALREADY_OPEN 

Definition at line 307 of file mididrv.h.

anonymous enum
Enumerator:
PROP_OLD_ADLIB 
PROP_CHANNEL_MASK 
PROP_SCUMM_OPL3 

Definition at line 314 of file mididrv.h.

Enumerator:
kDriverName 
kDriverId 
kDeviceName 
kDeviceId 

Definition at line 240 of file mididrv.h.


Constructor & Destructor Documentation

MidiDriver::MidiDriver (  )  [inline]

Definition at line 290 of file mididrv.h.

virtual MidiDriver::~MidiDriver (  )  [inline, virtual]

Definition at line 294 of file mididrv.h.


Member Function Documentation

virtual bool MidiDriver::acceptsSoundFontData (  )  [inline, virtual]

Definition at line 395 of file mididrv.h.

virtual MidiChannel* MidiDriver::allocateChannel (  )  [pure virtual]
bool MidiDriver::checkDevice ( MidiDriver::DeviceHandle  handle  )  [static]

Check whether the device with the given handle is available.

Definition at line 438 of file mididrv.cpp.

virtual void MidiDriver::close (  )  [pure virtual]

Close the midi driver.

byte MidiDriver::correctInstrumentBank ( byte  outputChannel,
byte  patchId 
) [protected]

Checks if the currently selected GS bank / instrument variation on the specified channel is valid for the specified patch.

If this is not the case, the correct bank will be returned which can be set by sending a bank select message. If no correction is needed, 0xFF will be returned. This emulates the fallback functionality of the Roland SC-55 v1.2x, on which some games rely to correct wrong bank selects.

Definition at line 537 of file mididrv.cpp.

MidiDriver * MidiDriver::createMidi ( MidiDriver::DeviceHandle  handle  )  [static]

Create music driver matching the given device handle, or NULL if there is no match.

Definition at line 426 of file mididrv.cpp.

MidiDriver::DeviceHandle MidiDriver::detectDevice ( int  flags  )  [static]

Returns device handle based on the present devices and the flags parameter.

Definition at line 174 of file mididrv.cpp.

virtual uint32 MidiDriver::getBaseTempo (  )  [pure virtual]

The time in microseconds between invocations of the timer callback.

MidiDriver::DeviceHandle MidiDriver::getDeviceHandle ( const Common::String identifier  )  [static]

Find the music driver matching the given driver name/description.

Definition at line 449 of file mididrv.cpp.

Common::String MidiDriver::getDeviceString ( DeviceHandle  handle,
DeviceStringType  type 
) [static]

Get the device description string matching the given device handle and the given type.

Definition at line 149 of file mididrv.cpp.

static const char* MidiDriver::getErrorName ( int  error_code  )  [static]

Retrieve a string representation of an error code.

MusicType MidiDriver::getMusicType ( MidiDriver::DeviceHandle  handle  )  [static]

Get the music type matching the given device handle, or MT_AUTO if there is no match.

Definition at line 131 of file mididrv.cpp.

virtual MidiChannel* MidiDriver::getPercussionChannel (  )  [pure virtual]
void MidiDriver::initGM ( bool  initForMT32,
bool  enableGS 
)

Initializes the General MIDI device.

The device will be reset. If the initForMT32 parameter is specified, the device will be set up for MT-32 MIDI data. If the device supports Roland GS, the enableGS parameter can be specified for enhanced GS MT-32 compatiblity.

Parameters:
initForMT32 True if the device should be initialized for MT-32 mapping
enableGS True if the device should be initialized for GS MT-32 mapping

Definition at line 529 of file mididrv.cpp.

void MidiDriver::initMT32 ( bool  initForGM  ) 

Initializes the MT-32 MIDI device.

The device will be reset and, if the parameter is specified, set up for General MIDI data.

Parameters:
initForGM True if the MT-32 should be initialized for GM mapping

Definition at line 470 of file mididrv.cpp.

virtual bool MidiDriver::isOpen (  )  const [pure virtual]

Check whether the midi driver has already been opened.

void MidiDriver::midiDriverCommonSend ( uint32  b  ) 

Common operations to be done by all drivers on start of send.

Definition at line 588 of file mididrv.cpp.

void MidiDriver::midiDriverCommonSysEx ( const byte msg,
uint16  length 
)

Common operations to be done by all drivers on start of sysEx.

Definition at line 592 of file mididrv.cpp.

Common::String MidiDriver::musicType2GUIO ( uint32  musicType  )  [static]

Definition at line 118 of file mididrv.cpp.

virtual int MidiDriver::open (  )  [pure virtual]

Open the midi driver.

Returns:
0 if successful, otherwise an error code.
virtual uint32 MidiDriver::property ( int  prop,
uint32  param 
) [inline, virtual]

Get or set a property.

Definition at line 337 of file mididrv.h.

void MidiDriver::sendGMReset (  ) 

Send a General MIDI reset sysEx to the midi device.

Definition at line 533 of file mididrv.cpp.

void MidiDriver::sendMT32Reset (  ) 

Send a Roland MT-32 reset sysEx to the midi device.

Definition at line 523 of file mididrv.cpp.

virtual void MidiDriver::setEngineSoundFont ( Common::SeekableReadStream soundFontData  )  [inline, virtual]

Definition at line 392 of file mididrv.h.

virtual void MidiDriver::setPitchBendRange ( byte  channel,
uint  range 
) [inline, virtual]

Definition at line 343 of file mididrv.h.

virtual void MidiDriver::setTimerCallback ( void *  timer_param,
Common::TimerManager::TimerProc  timer_proc 
) [pure virtual]
virtual void MidiDriver::sysEx_customInstrument ( byte  channel,
uint32  type,
const byte instr 
) [inline, virtual]

Definition at line 379 of file mididrv.h.


Member Data Documentation

bool MidiDriver::_forceTypeMT32 = false [static, private]

Definition at line 287 of file mididrv.h.

const byte MidiDriver::_gmToMt32 [static]
Initial value:
 {

      5,   1,   2,   7,   3,   5,  16,  21,  22, 101, 101,  97, 104, 103, 102,  20, 
      8,   9,  11,  12,  14,  15,  87,  15,  59,  60,  61,  62,  67,  44,  79,  23, 
     64,  67,  66,  70,  68,  69,  28,  31,  52,  54,  55,  56,  49,  51,  57, 112, 
     48,  50,  45,  26,  34,  35,  45, 122,  89,  90,  94,  81,  92,  95,  24,  25, 
     80,  78,  79,  78,  84,  85,  86,  82,  74,  72,  76,  77, 110, 107, 108,  76, 
     47,  44, 111,  45,  44,  34,  44,  30,  32,  33,  88,  34,  35,  35,  38,  33, 
     41,  36, 100,  37,  40,  34,  43,  40,  63,  21,  99, 105, 103,  86,  55,  84, 
    101, 103, 100, 120, 117, 113,  99, 128, 128, 128, 128, 124, 123, 128, 128, 128, 
}

Definition at line 297 of file mididrv.h.

byte MidiDriver::_gsBank[16] [protected]

Definition at line 279 of file mididrv.h.

Initial value:
 {
     0,  0,  0,  0,  0,  0,  0,  0, 
     8,  8,  8,  8,  8,  8,  8,  8, 
    16, 16, 16, 16, 16, 16, 16, 16, 
    24, 25, 24, 24, 24, 24, 24, 24, 
    32, 32, 32, 32, 32, 32, 32, 32, 
    40, 40, 40, 40, 40, 40, 40, 40, 
    48, 48, 48, 48, 48, 48, 48, 48, 
    56, 56, 56, 56, 56, 56, 56, 56, 
     0,  0,  0,  0,  0,  0,  0,  0, 
     0,  0,  0,  0,  0,  0,  0,  0, 
     0,  0,  0,  0,  0,  0,  0,  0, 
     0,  0,  0,  0,  0,  0,  0,  0, 
     0,  0,  0,  0,  0,  0,  0,  0, 
     0,  0,  0,  0,  0,  0,  0,  0, 
     0,  0,  0,  0,  0,  0,  0,  0, 
     0,  0,  0,  0,  0,  0,  0, 127 
}

Definition at line 301 of file mididrv.h.

Initial value:
 {
    0x44, 0x30, 0x5F, 0x4E, 0x29, 0x03, 0x6E, 0x7A
}

Definition at line 298 of file mididrv.h.

Initial value:
 {
    
    0x40, 0x49, 0x40, 0x49, 0x25, 0x5B, 0x00, 0x7F
}

Definition at line 299 of file mididrv.h.

const byte MidiDriver::_mt32ToGm [static]
Initial value:
 {

      0,   1,   0,   2,   4,   4,   5,   3,  16,  17,  18,  16,  16,  19,  20,  21, 
      6,   6,   6,   7,   7,   7,   8, 112,  62,  62,  63,  63,  38,  38,  39,  39, 
     88,  95,  52,  98,  97,  99,  14,  54, 102,  96,  53, 102,  81, 100,  14,  80, 
     48,  48,  49,  45,  41,  40,  42,  42,  43,  46,  45,  24,  25,  28,  27, 104, 
     32,  32,  34,  33,  36,  37,  35,  35,  79,  73,  72,  72,  74,  75,  64,  65, 
     66,  67,  71,  71,  68,  69,  70,  22,  56,  59,  57,  57,  60,  60,  58,  61, 
     61,  11,  11,  98,  14,   9,  14,  13,  12, 107, 107,  77,  78,  78,  76,  76, 
     47, 117, 127, 118, 118, 116, 115, 119, 115, 112,  55, 124, 123,   0,  14, 117  
}

Definition at line 296 of file mididrv.h.

bool MidiDriver::_reversePanning [protected]

Definition at line 275 of file mididrv.h.

Definition at line 277 of file mididrv.h.


The documentation for this class was generated from the following files:


Generated on Sat Sep 19 2020 05:04:01 for ResidualVM by doxygen 1.7.1
curved edge   curved edge