ScummVM API documentation
MidiDriver_BASE Class Referenceabstract

#include <mididrv.h>

Inheritance diagram for MidiDriver_BASE:
Audio::MidiPlayer Groovie::MusicPlayerMidi Lure::MidiMusic MidiDriver Queen::MidiMusic Sci::MidiPlayer Scumm::Player Access::MusicManager Agi::SoundGenMIDI AGS::Music Bagel::MusicPlayer CGE2::MusicPlayer CGE::MusicPlayer Draci::MusicPlayer Dragons::MidiMusicPlayer Gnap::MusicPlayer Hugo::MidiPlayer Illusions::MidiPlayer Lilliput::LilliputSound Prince::MusicPlayer Tinsel::MidiMusicPlayer Toltecs::MusicPlayer Touche::MidiPlayer TwinE::TwinEMidiPlayer Ultima::Ultima4::Music Groovie::MusicPlayerMac_t7g Groovie::MusicPlayerMac_v2 Groovie::MusicPlayerXMI 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 Member Functions

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 Attributes

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
 

Protected Member Functions

void midiDumpInit ()
 
int midiDumpVarLength (const uint32 &delta)
 
void midiDumpDelta ()
 
void midiDumpDo (uint32 b)
 
void midiDumpSysEx (const byte *msg, uint16 length)
 
void midiDumpFinish ()
 

Protected Attributes

bool _midiDumpEnable
 
uint32 _prevMillis
 
Common::Array< byte > _midiDumpCache
 

Detailed Description

TODO: Document this, give it a better name.

Member Function Documentation

◆ send() [1/4]

◆ send() [2/4]

virtual void MidiDriver_BASE::send ( int8  source,
uint32  b 
)
inlinevirtual

◆ send() [3/4]

void MidiDriver_BASE::send ( byte  status,
byte  firstOp,
byte  secondOp 
)

Output a midi command to the midi stream. Convenience wrapper around the usual 'packed' send method.

Do NOT use this for sysEx transmission; instead, use the sysEx() method below.

◆ send() [4/4]

void MidiDriver_BASE::send ( int8  source,
byte  status,
byte  firstOp,
byte  secondOp 
)

Send a MIDI command from a specific source. If the MIDI driver does not support multiple sources, the source parameter is ignored.

◆ sysEx()

virtual void MidiDriver_BASE::sysEx ( const byte *  msg,
uint16  length 
)
inlinevirtual

Transmit a SysEx to the MIDI device.

The given msg MUST NOT contain the usual SysEx frame, i.e. do NOT include the leading 0xF0 and the trailing 0xF7.

Furthermore, the maximal supported length of a SysEx is 268 bytes. Passing longer buffers can lead to undefined behavior (most likely, a crash).

Reimplemented in MidiDriver_ADLIB_Multisource, Scumm::Player, MidiDriver_MT32GM, Groovie::MusicPlayerMidi, and Scumm::IMuseDriver_GMidi.

◆ sysExNoDelay()

virtual uint16 MidiDriver_BASE::sysExNoDelay ( const byte *  msg,
uint16  length 
)
inlinevirtual

Transmit a SysEx to the MIDI device and return the necessary delay until the next SysEx event in milliseconds.

This can be used to implement an alternate delay method than the OSystem::delayMillis function used by most sysEx implementations. Note that not every driver needs a delay, or supports this method. In this case, 0 is returned and the driver itself will do a delay if necessary.

For information on the SysEx data requirements, see the sysEx method.

Reimplemented in Scumm::Player, MidiDriver_MT32GM, and Groovie::MusicPlayerMidi.

◆ metaEvent()

virtual void MidiDriver_BASE::metaEvent ( int8  source,
byte  type,
byte *  data,
uint16  length 
)
inlinevirtual

Send a meta event from a specific source. If the MIDI driver does not support multiple sources, the source parameter is ignored.

Reimplemented in MidiDriver_ADLIB_Multisource, MidiDriver_MT32GM, Lure::MidiDriver_ADLIB_Lure, Groovie::MusicPlayerXMI, MidiDriver_Casio, Lure::MidiMusic, Ultima::Nuvie::MidiDriver_M_MT32, and Ultima::Nuvie::MidiDriver_M_AdLib.

◆ stopAllNotes()

virtual void MidiDriver_BASE::stopAllNotes ( bool  stopSustainedNotes = false)
virtual

Stops all currently active notes. Specify stopSustainedNotes if the MIDI data makes use of the sustain controller to make sure sustained notes are also stopped.

Usually, the MIDI parser tracks active notes and terminates them when playback is stopped. This method should be used as a backup to silence the MIDI output in case the MIDI parser makes a mistake when tracking acive notes. It can also be used when quitting or pausing a game.

By default, this method sends an All Notes Off message and, if stopSustainedNotes is true, a Sustain off message on all MIDI channels. Driver implementations can override this if they want to implement this functionality in a different way.

Reimplemented in MidiDriver_ADLIB_Multisource, MidiDriver_MT32GM, Groovie::MusicPlayerXMI, Audio::MidiDriver_Miles_Midi, MidiDriver_Casio, and Ultima::Nuvie::MidiDriver_M_MT32.

◆ isReady()

virtual bool MidiDriver_BASE::isReady ( int8  source = -1)
inlinevirtual

A driver implementation might need time to prepare playback of a track. Use this function to check if the driver is ready to receive MIDI events.

Parameters
sourceCheck if the driver is ready to receive events from this specific source. Specify -1 to check readiness regardless of source.

Reimplemented in MidiDriver_MT32GM, and Groovie::MusicPlayerXMI.

◆ midiDumpInit()

void MidiDriver_BASE::midiDumpInit ( )
protected

Initialize midi dumping mechanism, called only if enabled

◆ midiDumpVarLength()

int MidiDriver_BASE::midiDumpVarLength ( const uint32 &  delta)
protected

Handles MIDI file variable length dumping

◆ midiDumpDelta()

void MidiDriver_BASE::midiDumpDelta ( )
protected

Handles MIDI file time delta dumping

◆ midiDumpDo()

void MidiDriver_BASE::midiDumpDo ( uint32  b)
protected

Performs dumping of MIDI commands, called only if enabled

◆ midiDumpSysEx()

void MidiDriver_BASE::midiDumpSysEx ( const byte *  msg,
uint16  length 
)
protected

Performs dumping of MIDI SysEx commands, called only if enabled

◆ midiDumpFinish()

void MidiDriver_BASE::midiDumpFinish ( )
protected

Writes the captured MIDI events to disk, called only if enabled

Member Data Documentation

◆ _midiDumpEnable

bool MidiDriver_BASE::_midiDumpEnable
protected

Enables midi dumping to a 'dump.mid' file and to debug messages on screen It's set by '–dump-midi' command line parameter

◆ _prevMillis

uint32 MidiDriver_BASE::_prevMillis
protected

Used for MIDI dumping delta calculation

◆ _midiDumpCache

Common::Array<byte> MidiDriver_BASE::_midiDumpCache
protected

Stores all MIDI events, will be written to disk after an engine quits


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