MidiPlayerTK Namespace Reference

Classes

class  HelperNoteLabel
 Some useful methods to get the label of a note. More...
 
class  MidiExternalPlayer
 [MPTK PRO] Play a Local MIDI file or from a Web site. This class must be used with the prefab MidiExternalPlayer
More...
 
class  MidiFileLoader
 Load all or a part of the MIDI events from a MIDI file to a list of MPTKEvent. This class must be used with the prefab MidiFileLoader.
More...
 
class  MidiFilePlayer
 Play a MIDI file from the MidiDB. This class must be used with the prefab MidiFilePlayer.
More...
 
class  MidiFileWriter2
 [MPTK PRO] Build and Write a MIDI file from different sources.
More...
 
class  MidiInReader
 [MPTK PRO] Read MIDI events from a MIDI keyboard connected to your Windows or Mac desktop. This class must be used with the prefab MidiInReader
More...
 
class  MidiKeyboard
 [MPTK PRO] Base class to send and receive Midi Message from a Midi keyboard connected to the desktop
More...
 
class  MidiListPlayer
 [MPTK PRO] Play a list of pre-selected MIDI files from the MidiDB. This class must be used with the prefab MidiListPlayer.
More...
 
class  MidiLoad
 Base class for loading a Midi file. It is not recommended to instanciate directly this class.
This class is used by MidiFilePlayer, MidiListPlayer, MidiFileWrite2, MidiFileLoader (see members MPTK_MidiLoaded of these classes).
It is better to use the prefab and class MidiFileLoader if you only want to load a Midi file. More...
 
class  MidiPlayerGlobal
 Singleton class to manage all globales MPTK features. More information here: https://paxstellar.fr/midiplayerglobal/ More...
 
class  MidiSpatializer
 [MPTK PRO] For playing Spatialized MIDI by channels or by tracks from the MidiDB. This class must be used with the prefab MidiSpatializer
More...
 
class  MidiStreamPlayer
 Build and Play Real Time Music in relation with user actions or algorithms. This class must be used with the prefab MidiStreamPlayer.
More...
 
class  MidiSynth
 Base class wich contains all the stuff to build a Wave Table Synth. Not for use directly.
More...
 
class  MPTKChordBuilder
 [MPTK PRO] Build Chord and Play with MidiStreamPlayer.
More...
 
class  MPTKChordLib
 [MPTK PRO] Build Chord from a library and Play with MidiStreamPlayer.
More...
 
class  MPTKEvent
 Description of a MIDI Event. It's the heart of MPTK! Essential to handling MIDI by script from all others classes as MidiStreamPlayer, MidiFilePlayer, MidiFileLoader, ...
More...
 
class  MPTKFootPrint
 [MPTK PRO] Experimental - Search a MIDI from a sequence of notes and calculate a score tempo.
More...
 
class  MPTKListItem
 This class is useful when a list of paired value string+id is needed.
More...
 
class  MPTKRangeLib
 [MPTK PRO] Build Scale and Play with MidiStreamPlayer.
More...
 

Enumerations

enum  LoadingStatusMidiEnum {
  NotYetDefined = -1 , Success = 0 , NotFound = 1 , TooShortSize = 2 ,
  NoMThdSignature = 3 , NetworkError = 4 , MidiFileInvalid = 5 , SoundFontNotLoaded = 6 ,
  AlreadyPlaying = 7 , MidiNameInvalid = 8 , MidiNameNotDefined = 9
}
 
enum  midi_rpn_event { RPN_PITCH_BEND_RANGE = 0x00 , RPN_CHANNEL_FINE_TUNE = 0x01 , RPN_CHANNEL_COARSE_TUNE = 0x02 , RPN_TUNING_PROGRAM_CHANGE = 0x03 , RPN_TUNING_BANK_SELECT = 0x04 , RPN_MODULATION_DEPTH_RANGE = 0x05 }
 
enum  MPTKChordName
 [MPTK PRO] List of chords available More...
 
enum  MPTKCommand : byte {
  NoteOff = 0x80 , NoteOn = 0x90 , KeyAfterTouch = 0xA0 , ControlChange = 0xB0 ,
  PatchChange = 0xC0 , ChannelAfterTouch = 0xD0 , PitchWheelChange = 0xE0 , Sysex = 0xF0 ,
  Eox = 0xF7 , TimingClock = 0xF8 , StartSequence = 0xFA , ContinueSequence = 0xFB ,
  StopSequence = 0xFC , AutoSensing = 0xFE , MetaEvent = 0xFF
}
 
enum  MPTKController : byte {
  BankSelectMsb = 0 , Modulation = 1 , BreathController = 2 , FootController = 4 ,
  PORTAMENTO_TIME_MSB = 0x05 , DATA_ENTRY_MSB = 6 , VOLUME_MSB = 7 , BALANCE_MSB = 8 ,
  Pan = 10 , Expression = 11 , EFFECTS1_MSB = 12 , EFFECTS2_MSB = 13 ,
  GPC1_MSB = 16 , GPC2_MSB = 17 , GPC3_MSB = 18 , GPC4_MSB = 19 ,
  BankSelectLsb = 32 , MODULATION_WHEEL_LSB = 33 , BREATH_LSB = 34 , FOOT_LSB = 36 ,
  PORTAMENTO_TIME_LSB = 37 , DATA_ENTRY_LSB = 38 , VOLUME_LSB = 39 , BALANCE_LSB = 40 ,
  PAN_LSB = 42 , EXPRESSION_LSB = 43 , EFFECTS1_LSB = 44 , EFFECTS2_LSB = 45 ,
  GPC1_LSB = 48 , GPC2_LSB = 49 , GPC3_LSB = 50 , GPC4_LSB = 51 ,
  Sustain = 64 , Portamento = 65 , Sostenuto = 66 , SoftPedal = 67 ,
  LegatoFootswitch = 68 , HOLD2_SWITCH = 69 , SOUND_CTRL1 = 70 , SOUND_CTRL2 = 71 ,
  SOUND_CTRL3 = 72 , SOUND_CTRL4 = 73 , SOUND_CTRL5 = 74 , SOUND_CTRL6 = 75 ,
  SOUND_CTRL7 = 76 , SOUND_CTRL8 = 77 , SOUND_CTRL9 = 78 , SOUND_CTRL10 = 79 ,
  GPC5 = 80 , GPC6 = 81 , GPC7 = 82 , GPC8 = 83 ,
  PORTAMENTO_CTRL = 84 , EFFECTS_DEPTH1 = 91 , EFFECTS_DEPTH2 = 92 , EFFECTS_DEPTH3 = 93 ,
  EFFECTS_DEPTH4 = 94 , EFFECTS_DEPTH5 = 95 , DATA_ENTRY_INCR = 96 , DATA_ENTRY_DECR = 97 ,
  NRPN_LSB = 98 , NRPN_MSB = 99 , RPN_LSB = 100 , RPN_MSB = 101 ,
  AllSoundOff = 120 , ResetAllControllers = 121 , LOCAL_CONTROL = 122 , AllNotesOff = 123 ,
  OMNI_OFF = 124 , OMNI_ON = 125 , POLY_OFF = 126 , POLY_ON = 127
}
 
enum  MPTKMeta : byte {
  TrackSequenceNumber = 0x00 , TextEvent = 0x01 , Copyright = 0x02 , SequenceTrackName = 0x03 ,
  TrackInstrumentName = 0x04 , Lyric = 0x05 , Marker = 0x06 , CuePoint = 0x07 ,
  ProgramName = 0x08 , DeviceName = 0x09 , MidiChannel = 0x20 , MidiPort = 0x21 ,
  EndTrack = 0x2F , SetTempo = 0x51 , SmpteOffset = 0x54 , TimeSignmature = 0x58 ,
  TimeSignature = 0x58 , KeySignature = 0x59 , SequencerSpecific = 0x7F
}
 
enum  MPTKRangeName
 [MPTK PRO] List of ranges available More...
 

Enumeration Type Documentation

◆ LoadingStatusMidiEnum

Status of the last midi file loaded

  • -1: midi file is loading
  • 0: succes, midi file loaded
  • 1: error, no Midi found
  • 2: error, not a midi file, too short size
  • 3: error, not a midi file, signature MThd not found.
  • 4: error, network error or site not found.
Enumerator
NotYetDefined 

-1: midi file is loading.

Success 

0: succes, midi file loaded.

NotFound 

1: error, no Midi file found.

TooShortSize 

2: error, not a midi file, too short size.

NoMThdSignature 

3: error, not a midi file, signature MThd not found.

NetworkError 

4: error, network error or site not found (MidiExternalPlayer only).

MidiFileInvalid 

5: error, midi file corrupted, error detected when loading the midi events.

SoundFontNotLoaded 

6: SoundFont not loaded.

AlreadyPlaying 

7: error, Already playing.

MidiNameInvalid 

8: error, MPTK_MidiName must start with file:// or http:// or https:// (only for MidiExternalPlayer).

MidiNameNotDefined 

9: error, Set MPTK_MidiName by script or in the inspector with Midi Url/path before playing.

◆ midi_rpn_event

General MIDI RPN event numbers (LSB, MSB = 0) The only confusing part of using parameter numbers, initially, is that there are two parts to using them.
First you need to tell the synthesizer what parameter you want to change, then you need to tell it how to change the parameter.
For example, if you want to change the "pitch bend sensitivity" to 12 semitones, you would send the following controler midi message:

Enumerator
RPN_PITCH_BEND_RANGE 

Change pitch bend sensitivity

◆ MPTKChordName

[MPTK PRO] List of chords available

◆ MPTKCommand

MIDI command codes. Defined the action to be done with the message: note on/off, change instrument, ...
Depending of the command selected, others properties must be set; Value, Channel, ...

Enumerator
NoteOff 

Note Off
Stop the note defined with the Value and the Channel
MPTKEvent::Value contains the note to stop 60=C5.
MPTKEvent::Channel the midi channel between 0 and 15

NoteOn 

Note On.
MPTKEvent::Value contains the note to play 60=C5.
MPTKEvent::Duration the duration of the note in millisecond, -1 for infinite
MPTKEvent::Channel the midi channel between 0 and 15
MPTKEvent::Velocity between 0 and 127

KeyAfterTouch 

Key After-touch


ControlChange 

Control change.
MPTKEvent::Controller contains the controller to change. See MPTKController (Modulation, Pan, Bank Select ...).
MPTKEvent::Value contains the value of the controller between 0 and 127.

PatchChange 

Patch change.
MPTKEvent::Value contains patch/preset/instrument to select between 0 and 127.

ChannelAfterTouch 

Channel after-touch

PitchWheelChange 

Pitch wheel change
MPTKEvent::Value contains the Pitch Wheel Value between 0 and 16383.
Higher values transpose pitch up, and lower values transpose pitch down.
The default sensitivity value is 2. That means that the maximum pitch bend will result in a pitch change of two semitones
above and below the sounding note, meaning a total of four semitones from lowest to highest pitch bend positions.

  • 0 is the lowest bend positions (default is 2 semitones),
  • 8192 (0x2000) centered value, the sounding notes aren't being transposed up or down,
  • 16383 (0x3FFF) is the highest pitch bend position (default is 2 semitones)
Sysex 

Sysex message

Eox 

Eox (comes at end of a sysex message)

TimingClock 

Timing clock
(used when synchronization is required)

StartSequence 

Start sequence

ContinueSequence 

Continue sequence

StopSequence 

Stop sequence

AutoSensing 

Auto-Sensing

MetaEvent 

Meta events are optionnals information that could be defined in a MIDI. None are mandatory
In MPTKEvent the attibute MPTKEvent::Meta defined the type of meta event. See MPTKMeta (TextEvent, Lyric, TimeSignature, ...).
Examples:

◆ MPTKController

Midi Controller list.
Each MIDI CC operates at 7-bit resolution, meaning it has 128 possible values. The values start at 0 and go to 127.
Some instruments can receive higher resolution data for their MIDI control assignments. These high res assignments are defined by combining two separate CCs,
one being the Most Significant Byte (MSB), and one being the Least Significant Byte (LSB).
Most instruments just receive the MSB with default 7-bit resolution. See more information here https://www.presetpatch.com/midi-cc-list.aspx

Enumerator
BankSelectMsb 

Bank Select (MSB)

Modulation 

Modulation (MSB)

BreathController 

Breath Controller

FootController 

Foot controller (MSB)

VOLUME_MSB 

Channel volume (was MainVolume before v2.88.2

Pan 

Pan MSB

Expression 

Expression (EXPRESSION_MSB)

BankSelectLsb 

Bank Select LSB *** not implemented ***
MPTK bank style is FLUID_BANK_STYLE_GS (see fluidsynth), bank = CC0/MSB (CC32/LSB ignored)

Sustain 

Sustain (SUSTAIN_SWITCH)

Portamento 

Portamento On/Off (PORTAMENTO_SWITCH)

Sostenuto 

Sostenuto On/Off (SOSTENUTO_SWITCH)

SoftPedal 

Soft Pedal On/Off (SOFT_PEDAL_SWITCH)

LegatoFootswitch 

Legato Footswitch (LEGATO_SWITCH)

NRPN_LSB 

Non Registered Parameter Number LSB
http://www.philrees.co.uk/nrpnq.htm

NRPN_MSB 

Non Registered Parameter Number MSB
http://www.philrees.co.uk/nrpnq.htm

RPN_LSB 

Registered Parameter Number LSB
http://www.philrees.co.uk/nrpnq.htm

RPN_MSB 

Registered Parameter Number MSB
http://www.philrees.co.uk/nrpnq.htm

AllSoundOff 

<summary

>All sound off (ALL_SOUND_OFF)

ResetAllControllers 

Reset all controllers (ALL_CTRL_OFF)

AllNotesOff 

All notes off (ALL_NOTES_OFF)

◆ MPTKMeta

enum MidiPlayerTK.MPTKMeta : byte

MIDI MetaEvent Type. Meta events are optionnals information that could be defined in a MIDI. None are mandatory
In MPTKEvent the attibute MPTKEvent::Meta defined the type of meta event.

Enumerator
TrackSequenceNumber 

Track sequence number

TextEvent 

Text event

Copyright 

Copyright

SequenceTrackName 

Sequence track name

TrackInstrumentName 

Track instrument name

Lyric 

Lyric

Marker 

Marker

CuePoint 

Cue point

ProgramName 

Program (patch) name

DeviceName 

Device (port) name

MidiChannel 

MIDI Channel (not official?)

MidiPort 

MIDI Port (not official?)

EndTrack 

End track

SetTempo 

Set tempo

SmpteOffset 

MPTE offset

TimeSignmature 

Time signature (typo error, deprecated!)

TimeSignature 

Time signature

KeySignature 

Key signature

SequencerSpecific 

Sequencer specific

◆ MPTKRangeName

[MPTK PRO] List of ranges available