MidiPlayerTK Namespace Reference

Classes

class  HelperNoteLabel
 Class contains some static methods about notes helper. More...
 
class  MidiBuildFootprint
 Experimental More...
 
class  MidiExternalPlayer
 [MPTK PRO] - Script associated to the prefab MidiExternalPlayer.
Play a midi file from a path on the local deskop or from a web site.
There is no need to writing a script. For a simple usage, all the job can be done in the prefab inspector.

But a set of API is also available to drive the music from your script.
On top of that, this class inherits from MidiFilePlayer and MidiSynth
All properties, event, methods from MidiFilePlayer and MidiSynth are available in this class.

More...
 
class  MidiFileLoader
 This class, associated with the prefab MidiFileLoader is useful for loading all or a part of the Midi events from a Midi file.
No sequencer, no synthetizer, no music playing capabilities, just loading and decoding a Midi file to the more easy class MPTKEvent.
Midi can be loaded from the MidiDB list (see Unity menu MPTK / Midi Player Setup) or from a folder on the desktop (Pro). More...
 
class  MidiFilePlayer
 This class, associated to the prefab MidiFilePlayer, is able to play music from MIDI file.
MIDI files must be added from the Unity menu MPTK in the Unity editor.
There is no need to writing a script. For a simple usage, all the job can be done in the prefab inspector.
For more information see here https://paxstellar.fr/midi-file-player-detailed-view-2/
But to more specific interaction, this class can be useful. See example below wich select randomly a MIDI to play.

On top of that, this class inherits from MidiSynth
All properties, event, methods from MidiSynth are available in the class MidiFilePlayer.

More...
 
class  MidiFileWriter2
 [MPTK PRO] - Write a midi file from differents sources based on NAudio frawemork.
See full example TestMidiWriter.cs with a light sequencer.
This class replaced MidiFileWriter with these changes: channel start at 0, new specfic event, better control.
More information here: https://paxstellar.fr/class-midifilewriter2/ More...
 
class  MidiInReader
 [MPTK PRO] - Script associated to the prefab MidiInReader.
Read Midi events from a Midi keyboard connected your device (Windows 10 or MacOS). See example of use in TestMidiInputScripting.cs
There is no need to writing a script. For a simple usage, all the job can be done in the prefab inspector.
More...
 
class  MidiKeyboard
 [MPTK PRO] - BAse class to send and receive Midi Message from a Midi keyboard connected to the device
More information here https://paxstellar.fr/class-midikeyboard/ More...
 
class  MidiListPlayer
 [MPTK PRO] - Script for the prefab MidiListPlayer.
Play a list of pre-selected midi files from the dedicated inspector or from an API.
List of Midi files must exists in MidiDB. See Midi Player Setup (Unity menu MPTK).
Two Midi Players are defined in the MidiListPlayer. Only one is played at a given time.
They are switched at the end of a midi. There is an overlap time between.
More...
 
class  MidiLoad
 Base class for loading a Midi file.
Internal used by MidiFilePlayer, MidiListPlayer, MidiFileWrite2, MidiFileLoader.
It is better to use the prefab and class MidiFileLoader if you want to only load a Midi file. More...
 
class  MidiPlayerGlobal
 Singleton class to manage all global features of MPTK. More information here: https://paxstellar.fr/midiplayerglobal/ More...
 
class  MidiSpatializer
 [MPTK PRO] - Script associated to the prefab MidiSpatializer.
It's quite light because the major job is done with MidiSynth
There is no specific API for this prefab.
Scripting is necessary to defined position of channel or instrument in your 3D env. See below.

On top of that, this class inherits from MidiFilePlayer and MidiSynth
All properties, event, methods from MidiFilePlayer and MidiSynth are available in this class.

///! More...
 
class  MidiStreamPlayer
 The prefab MidiStreamPlayer is useful for playing real time music in relation with user actions or an algo.
Any Midi file is necessary, the notes are generated by your scripts from your own algorithm. Thank to the API of this class.
The main function MPTK_PlayEvent() and the class MPTKEvent are able to create all kind of midi events as note-on.
All the values must be set in MPTKEvent, command, note value, duration ... for more details look at the class MPTKEvent.
A note-on must also be stopped, : if duration = -1 the note is infinite, it's the goal of MPTK_StopEvent() to stop the note with a note-off.
On top of that, the Pro version adds playing chords with MPTK_PlayChordFromRange() and MPTK_PlayChordFromLib().
For playing scales, have a look to the class MPTKRangeLib
For more information see here https://paxstellar.fr/midi-file-player-detailed-view-2-2/
and look at the demo TestMidiStream with the source code TestMidiStream.cs.

On top of that, this class inherits from MidiSynth
All properties, event, methods from MidiSynth are available in the class MidiStreamPlayer.

More...
 
class  MidiSynth
 Contains all the functions to build a wave table synth: load SoundFont and samples, process midi event, play voices, controllers, generators ...
This class is inherited by others class to build these prefabs: MidiStreamPlayer, MidiFilePlayer, MidiInReader.
It is not recommended to instanciate directly this class, rather add prefabs to the hierarchy of your scene. More...
 
class  MPTKChordBuilder
 [MPTK PRO] Chord builder class for MPTK. Usefull to generate Midi Music with MidiStreamPlayer - V2.82 See example in TestMidiStream.cs and ExtStreamPlayerPro.cs More...
 
class  MPTKChordLib
 [MPTK PRO] - Load library of chord from ChordLib.csv in folder Resources/GeneratorTemplate.csv - V2.82 new More...
 
class  MPTKEvent
 Midi Event class for MPTK. This class is more simple to use that the standard Midi structure.
The main property is Command, the content and role of other properties (as Value) depend on the value of Command. Look at the Value property.
With this class, you can: play and stop a note, change instrument (preset, patch, ...), change some control as modulation (Pro) ...
Use this class in relation with these classes: More...
 
class  MPTKListItem
 This class is useful when a list of paired value string+id is needed.
This is also the entry point to display a popup for selecting a value by user: midi, preset, bank, drum, generator, ... More...
 
class  MPTKRangeLib
 [MPTK PRO] - Load library of scale from GammeDefinition.csv in folder Resources/GeneratorTemplate.csv
For more information see here https://paxstellar.fr/midi-file-player-detailed-view-2-2/
More...
 

Enumerations

enum class  LoadingStatusMidiEnum {
  NotYetDefined = -1 , Success = 0 , NotFound = 1 , TooShortSize = 2 ,
  NoMThdSignature = 3 , NetworkError = 4 , MidiFileInvalid = 5 , SoundFontNotLoaded = 6 ,
  AlreadyPlaying = 7 , MidiNameInvalid = 8 , MidiNameNotDefined = 9
}
 Status of the last midi file loaded More...
 
enum class  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 }
 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:
More...
 
enum class  MPTKChordName
 [MPTK PRO] - List of chord available More...
 
enum class  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
}
 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, ...
More...
 
enum class  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
}
 MidiController enumeration http://www.midi.org/techspecs/midimessages.php#3 More...
 
enum class  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
}
 MIDI MetaEvent Type More...
 
enum class  MPTKRangeName
 [MPTK PRO] - List of range 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 chord available

◆ MPTKCommand

enum MidiPlayerTK.MPTKCommand : byte
strong

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 16

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 16
MPTKEvent::Velocity between 0 and 127

KeyAfterTouch 

Key After-touch


ControlChange 

Control change.
MPTKEvent::Controller contains identify 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-event
MPTKEvent::Meta defined the type of meta event. See MPTKMeta (TextEvent, Lyric, TimeSignature, ...).

◆ MPTKController

enum MidiPlayerTK.MPTKController : byte
strong

MidiController enumeration http://www.midi.org/techspecs/midimessages.php#3

Enumerator
BankSelectMsb 

Bank Select (MSB)

Modulation 

Modulation (MSB)

BreathController 

Breath Controller

FootController 

Foot controller (MSB)

VOLUME_MSB 

Main 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 

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
strong

MIDI MetaEvent Type

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 

SMPTE offset

TimeSignmature 

Time signature (typo error, deprecated!)

TimeSignature 

Time signature

KeySignature 

Key signature

SequencerSpecific 

Sequencer specific

◆ MPTKRangeName

[MPTK PRO] - List of range available