ScummVM API documentation
MidiDriver Class Referenceabstract

#include <mididrv.h>

Inheritance diagram for MidiDriver:
MidiDriver_BASE AGOS::MidiDriver_Accolade_Cms MidiDriver_Emulated MidiDriver_MPU401 MidiDriver_Multisource Queen::AdLibMidiDriver Scumm::IMuseDriver_Amiga Scumm::IMuseDriver_FMTowns Scumm::IMuseDriver_GMidi Scumm::Player_HE

Public Types

enum  DeviceStringType { kDriverName, kDriverId, kDeviceName, kDeviceId }
 
enum  { MERR_CANNOT_CONNECT = 1, MERR_DEVICE_NOT_AVAILABLE = 3, MERR_ALREADY_OPEN = 4 }
 
enum  {
  PROP_OLD_ADLIB = 2, PROP_CHANNEL_MASK = 3, PROP_SCUMM_OPL3 = 4, PROP_USER_VOLUME_SCALING = 5,
  PROP_MIDI_DATA_REVERSE_PANNING = 6, PROP_OPL_ACCURACY_MODE = 7, PROP_OPL_CHANNEL_ALLOCATION_MODE = 8, PROP_MILES_VERSION = 9,
  PROP_OPL_RHYTHM_MODE_IGNORE_NOTE_OFF = 10
}
 
typedef uint32 DeviceHandle
 

Public Member Functions

void midiDriverCommonSend (uint32 b)
 
void midiDriverCommonSysEx (const byte *msg, uint16 length)
 
virtual int open ()=0
 
virtual bool isOpen () const =0
 
virtual void close ()=0
 
virtual uint32 property (int prop, uint32 param)
 
virtual void setPitchBendRange (byte channel, uint range)
 
void sendMT32Reset ()
 
void sendGMReset ()
 
virtual void setTimerCallback (void *timer_param, Common::TimerManager::TimerProc timer_proc)=0
 
virtual uint32 getBaseTempo ()=0
 
virtual MidiChannelallocateChannel ()=0
 
virtual MidiChannelgetPercussionChannel ()=0
 
virtual void setEngineSoundFont (Common::SeekableReadStream *soundFontData)
 
virtual bool acceptsSoundFontData ()
 
- Public Member Functions inherited from MidiDriver_BASE
virtual void send (uint32 b)=0
 
virtual void send (int8 source, uint32 b)
 
void send (byte status, byte firstOp, byte secondOp)
 
void send (int8 source, byte status, byte firstOp, byte secondOp)
 
virtual void sysEx (const byte *msg, uint16 length)
 
virtual uint16 sysExNoDelay (const byte *msg, uint16 length)
 
virtual void metaEvent (byte type, byte *data, uint16 length)
 
virtual void metaEvent (int8 source, byte type, byte *data, uint16 length)
 
virtual void stopAllNotes (bool stopSustainedNotes=false)
 
virtual bool isReady (int8 source=-1)
 

Static Public Member Functions

static Common::String musicType2GUIO (uint32 musicType)
 
static MidiDrivercreateMidi (DeviceHandle handle)
 
static DeviceHandle detectDevice (int flags)
 
static DeviceHandle getDeviceHandle (const Common::String &identifier)
 
static bool checkDevice (DeviceHandle handle, int flags, bool quiet)
 
static MusicType getMusicType (DeviceHandle handle)
 
static Common::String getDeviceString (DeviceHandle handle, DeviceStringType type)
 
static const char * getErrorName (int error_code)
 

Static Public Attributes

static const byte _mt32ToGm [128]
 
static const byte _gmToMt32 [128]
 
- Static Public Attributes inherited from MidiDriver_BASE
static const uint8 MIDI_CHANNEL_COUNT = 16
 
static const uint8 MIDI_RHYTHM_CHANNEL = 9
 
static const byte MIDI_COMMAND_NOTE_OFF = 0x80
 
static const byte MIDI_COMMAND_NOTE_ON = 0x90
 
static const byte MIDI_COMMAND_POLYPHONIC_AFTERTOUCH = 0xA0
 
static const byte MIDI_COMMAND_CONTROL_CHANGE = 0xB0
 
static const byte MIDI_COMMAND_PROGRAM_CHANGE = 0xC0
 
static const byte MIDI_COMMAND_CHANNEL_AFTERTOUCH = 0xD0
 
static const byte MIDI_COMMAND_PITCH_BEND = 0xE0
 
static const byte MIDI_COMMAND_SYSTEM = 0xF0
 
static const byte MIDI_CONTROLLER_BANK_SELECT_MSB = 0x00
 
static const byte MIDI_CONTROLLER_MODULATION = 0x01
 
static const byte MIDI_CONTROLLER_DATA_ENTRY_MSB = 0x06
 
static const byte MIDI_CONTROLLER_VOLUME = 0x07
 
static const byte MIDI_CONTROLLER_BALANCE = 0x08
 
static const byte MIDI_CONTROLLER_PANNING = 0x0A
 
static const byte MIDI_CONTROLLER_EXPRESSION = 0x0B
 
static const byte MIDI_CONTROLLER_BANK_SELECT_LSB = 0x20
 
static const byte MIDI_CONTROLLER_DATA_ENTRY_LSB = 0x26
 
static const byte MIDI_CONTROLLER_SUSTAIN = 0x40
 
static const byte MIDI_CONTROLLER_PORTAMENTO = 0x41
 
static const byte MIDI_CONTROLLER_SOSTENUTO = 0x42
 
static const byte MIDI_CONTROLLER_SOFT = 0x43
 
static const byte MIDI_CONTROLLER_REVERB = 0x5B
 
static const byte MIDI_CONTROLLER_CHORUS = 0x5D
 
static const byte MIDI_CONTROLLER_RPN_LSB = 0x64
 
static const byte MIDI_CONTROLLER_RPN_MSB = 0x65
 
static const byte MIDI_CONTROLLER_ALL_SOUND_OFF = 0x78
 
static const byte MIDI_CONTROLLER_RESET_ALL_CONTROLLERS = 0x79
 
static const byte MIDI_CONTROLLER_ALL_NOTES_OFF = 0x7B
 
static const byte MIDI_CONTROLLER_OMNI_ON = 0x7C
 
static const byte MIDI_CONTROLLER_OMNI_OFF = 0x7D
 
static const byte MIDI_CONTROLLER_MONO_ON = 0x7E
 
static const byte MIDI_CONTROLLER_POLY_ON = 0x7F
 
static const uint16 MIDI_RPN_PITCH_BEND_SENSITIVITY = 0x0000
 
static const uint16 MIDI_RPN_MASTER_TUNING_FINE = 0x0001
 
static const uint16 MIDI_RPN_MASTER_TUNING_COARSE = 0x0002
 
static const uint16 MIDI_RPN_NULL = 0x7F7F
 
static const uint8 MIDI_META_END_OF_TRACK = 0x2F
 
static const uint8 MIDI_META_SEQUENCER = 0x7F
 
static const uint16 MIDI_PITCH_BEND_DEFAULT = 0x2000
 
static const uint8 MIDI_PANNING_DEFAULT = 0x40
 
static const uint8 MIDI_EXPRESSION_DEFAULT = 0x7F
 
static const uint16 MIDI_MASTER_TUNING_FINE_DEFAULT = 0x2000
 
static const uint8 MIDI_MASTER_TUNING_COARSE_DEFAULT = 0x40
 
static const uint8 MT32_PITCH_BEND_SENSITIVITY_DEFAULT = 0x0C
 
static const uint8 GM_PITCH_BEND_SENSITIVITY_DEFAULT = 0x02
 
static const uint8 GS_RHYTHM_FIRST_NOTE = 0x1B
 
static const uint8 GS_RHYTHM_LAST_NOTE = 0x58
 

Additional Inherited Members

- Protected Member Functions inherited from MidiDriver_BASE
void midiDumpInit ()
 
int midiDumpVarLength (const uint32 &delta)
 
void midiDumpDelta ()
 
void midiDumpDo (uint32 b)
 
void midiDumpSysEx (const byte *msg, uint16 length)
 
void midiDumpFinish ()
 
- Protected Attributes inherited from MidiDriver_BASE
bool _midiDumpEnable
 
uint32 _prevMillis
 
Common::Array< byte > _midiDumpCache
 

Detailed Description

Abstract MIDI Driver Class

Member Typedef Documentation

◆ DeviceHandle

typedef uint32 MidiDriver::DeviceHandle

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?

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Error codes returned by open. Can be converted to a string with getErrorName().

◆ anonymous enum

anonymous enum
Enumerator
PROP_USER_VOLUME_SCALING 

Set this to enable or disable scaling of the MIDI channel volume with the user volume settings (including setting it to 0 when Mute All is selected). This is currently implemented in the MT-32/GM drivers (regular and Miles AIL) and the regular AdLib driver.

Default is disabled.

PROP_MIDI_DATA_REVERSE_PANNING 

Set this property to indicate that the MIDI data used by the game has reversed stereo panning compared to its intended device. The MT-32 has reversed stereo panning compared to the MIDI specification and some game developers chose to stick to the MIDI specification.

Do not confuse this with the _midiDeviceReversePanning flag, which indicates that the output MIDI device has reversed stereo panning compared to the intended MIDI device targeted by the MIDI data. This is set by the MT-32/GM driver when MT-32 data is played on a GM device or the other way around. Both flags can be set, which results in no change to the panning.

Set this property before opening the driver, to make sure that the default panning is set correctly.

PROP_OPL_ACCURACY_MODE 

Set this property to specify the behavior of the AdLib driver for note frequency and volume calculation.

ACCURACY_MODE_SB16_WIN95: volume and frequency calculation is identical to the Windows 95 SB16 driver. This is the default. ACCURACY_MODE_GM: volume and frequency calculation is closer to the General MIDI and MIDI specifications. Volume is more dynamic and frequencies are closer to actual note frequencies. Calculations are more CPU intensive in this mode.

PROP_OPL_CHANNEL_ALLOCATION_MODE 

Set this property to specify the OPL channel allocation behavior of the AdLib driver.

ALLOCATION_MODE_DYNAMIC: behavior is identical to the Windows 95 SB16 driver. Whenever a note is played, an OPL channel is allocated to play this note if:

  1. the channel is not playing a note, or
  2. the channel is playing a note of the same instrument, or
  3. the channel is playing the least recently started note. This mode is the default. ALLOCATION_MODE_STATIC: when a note is played, an OPL channel is exclusively allocated to the MIDI channel and source playing the note. All notes on this MIDI channel are played using this OPL channel. If no OPL channels are unallocated, allocation will fail and the note will not play. This mode requires MIDI channels to be monophonic (i.e. only play one note at a time).
PROP_MILES_VERSION 

Set this property to specify the Miles AIL/MSS version that the Miles drivers should emulate.

MILES_VERSION_2: behavior matches Miles AIL versions 1 and 2. Specifically, GM devices are initialized like the MT-32 because these versions do not yet support GM. MILES_VERSION_3: behavior matches Miles Sound System version 3 and higher. GM devices are initialized according to the GM standard.

PROP_OPL_RHYTHM_MODE_IGNORE_NOTE_OFF 

Set this property to make the OPL driver ignore note off events for rhythm instruments when rhythm mode is activated. MIDI data should contain a note off for each note on. For rhythm instruments, a note off typically has no effect, because the note plays for a fixed amount of time. For the OPL rhythm instruments a note off will cut off the note. With this option, this behavior can be prevented. Currently only the AdLib multisource driver supports this option.

False: note offs for OPL rhythm mode instruments are processed. True: note offs for OPL rhythm mode instruments are ignored.

Member Function Documentation

◆ createMidi()

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

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

◆ detectDevice()

static DeviceHandle MidiDriver::detectDevice ( int  flags)
static

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

◆ getDeviceHandle()

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

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

◆ checkDevice()

static bool MidiDriver::checkDevice ( DeviceHandle  handle,
int  flags,
bool  quiet 
)
static

Check whether the device with the given handle is available.

Parameters
handleA device handle to check.
flagsA mask of flags from MidiDriverFlags to check with.
quietIf true, then failure produces no warnings. If false, then failure throws a warning.
Returns
True if the device is expected to be available, false if not.

◆ getMusicType()

static MusicType MidiDriver::getMusicType ( DeviceHandle  handle)
static

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

◆ getDeviceString()

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

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

◆ midiDriverCommonSend()

void MidiDriver::midiDriverCommonSend ( uint32  b)

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

◆ midiDriverCommonSysEx()

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

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

◆ open()

◆ isOpen()

◆ close()

◆ property()

virtual uint32 MidiDriver::property ( int  prop,
uint32  param 
)
inlinevirtual

◆ getErrorName()

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

Retrieve a string representation of an error code.

◆ sendMT32Reset()

void MidiDriver::sendMT32Reset ( )

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

◆ sendGMReset()

void MidiDriver::sendGMReset ( )

Send a General MIDI reset sysEx to the midi device.

◆ getBaseTempo()


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