Midi Player Tool Kit for Unity  Version 2.872
Add Midi Music to your Unity App, Build Rhytm Game, Create Music Generator ... see how here.
Public Types | Public Member Functions | Public Attributes | Properties | List of all members
MidiPlayerTK.MPTKEvent

Midi Event class for MPTK. Use this class to generate Midi Music with MidiStreamPlayer or to read midi events from a Midi file with MidiLoad or to receive midi events from MidiFilePlayer OnEventNotesMidi. With this class, you can: play and stop a note, change instrument (preset, patch, ...), change some control as modulation See here https://paxstellar.fr/class-mptkevent More...

Inherits ICloneable, and ICloneable.

Public Types

enum class  EnumLength
 Note length as https://en.wikipedia.org/wiki/Note_value More...
 

Public Member Functions

 MPTKEvent (ulong data)
 Create a MPTK Midi event from a midi input message More...
 
bool MTPK_ModifySynthParameter (fluid_gen_type genType, float value, MPTKModeGeneratorChange mode)
 [Pro] Apply modification on default SoundFont generator value. Can be applied independently for each notes, can be applied in real time when the note is played. More...
 
ulong ToData ()
 Build a packet midi message from a MPTKEvent. Example: 0x00403C90 for a noton (90h, 3Ch note, 40h volume) More...
 
override string ToString ()
 Build a string description of the Midi event. V2.83 removes
on each returns string More...
 

Public Attributes

int Channel
 Midi channel fom 0 to 15 (9 for drum) More...
 
MPTKCommand Command
 Midi Command code. Defined the type of message (Note On, Control Change, Patch Change...) More...
 
MPTKController Controller
 Controller code. When the Command is ControlChange, contains the code fo the controller to change (Modulation, Pan, Bank Select ...). Value will contains the value of the controller. More...
 
long Delay
 Delay before playing the note in millisecond. New with V2.82, works only in Core mode. More...
 
long Duration
 Duration of the note in millisecond. Set -1 to play undefinitely. More...
 
int IdSession
 V2.84 Define an Id associated with this event. Can be used with MPTK_ClearAllSound to clear only a subset of sound associated with this session. More...
 
string Info
 Information hold by textual meta event when Command=MetaEvent More...
 
int Length
 Duration of the note in Midi Tick. MidiFilePlayer.MPTK_NoteLength can be used to convert this duration. Not used for MidiStreamPlayer, length is set only when reading a Midi file. https://en.wikipedia.org/wiki/Note_value More...
 
MPTKMeta Meta
 MetaEvent Code. When the Command is MetaEvent, contains the code of the meta event (Lyric, TimeSignature, ...). . Info will contains the value of the meta. More...
 
uint Source
 Origine of the message. Midi ID if from Midi Input else zero. V2.83: rename source to Source et set public. More...
 
object Tag
 V2.87 Tag information More...
 
long Tick
 Time in Midi Tick (part of a Beat) of the Event since the start of playing the midi file. This time is independent of the Tempo or Speed. Not used for MidiStreamPlayer. More...
 
long TickTime
 V2.86 Time in System.DateTime when the Event is created or read from the Midi file. Can be read from a system thread. More...
 
long Track
 Index of track. More...
 
int Value
 Contains a value between 0 and 127 in relation with the Command. For: More...
 
int Velocity
 Velocity between 0 and 127 More...
 
List< fluid_voice > Voices
 List of voices associated to this Event for playing a NoteOn event. More...
 

Properties

bool IsOver [get]
 CHeck if playing of this midi event is over (all voices are OFF) More...
 
long MPTK_DeltaTimeMillis [get]
 V2.86 Delta time in milliseconds since the creation of this event More...
 
long MPTK_DeltaTimeTick [get]
 V2.86 Delta time in system ticks since the creation of this event More...
 

Detailed Description

Midi Event class for MPTK. Use this class to generate Midi Music with MidiStreamPlayer or to read midi events from a Midi file with MidiLoad or to receive midi events from MidiFilePlayer OnEventNotesMidi. With this class, you can: play and stop a note, change instrument (preset, patch, ...), change some control as modulation See here https://paxstellar.fr/class-mptkevent

!
! // Change instrument to Marimba for channel 0
! NotePlaying = new MPTKEvent() {
! Command = MPTKCommand.NoteOn,
! Value = 12, // generally Marimba but depend on the SoundFont selected
! Channel = 0 }; // Instrument are defined by channel. So at any time, only 16 différents instruments can be used simultaneously.
! midiStreamPlayer.MPTK_PlayEvent(NotePlaying);
!
! // Play a C5 during one second with the Marimba instrument
! NotePlaying = new MPTKEvent() {
! Command = MPTKCommand.NoteOn,
! Value = 60, // play a C5 note
! Channel = 0,
! Duration = 1000, // one second
! Velocity = 100 };
! midiStreamPlayer.MPTK_PlayEvent(NotePlaying);
!
long Duration
Duration of the note in millisecond. Set -1 to play undefinitely.
Definition: MPTKEvent.cs:220
MPTKCommand Command
Midi Command code. Defined the type of message (Note On, Control Change, Patch Change....
Definition: MPTKEvent.cs:182
int Velocity
Velocity between 0 and 127
Definition: MPTKEvent.cs:215
int Value
Contains a value between 0 and 127 in relation with the Command. For:
Definition: MPTKEvent.cs:205
int Channel
Midi channel fom 0 to 15 (9 for drum)
Definition: MPTKEvent.cs:210
MPTKCommand
MIDI command codes. Defined the action to be done with the message: note on/off, change instrument,...
Definition: MPTKEvent.cs:15

Member Enumeration Documentation

◆ EnumLength

Constructor & Destructor Documentation

◆ MPTKEvent()

MidiPlayerTK.MPTKEvent.MPTKEvent ( ulong  data)

Create a MPTK Midi event from a midi input message

Parameters
data

Member Function Documentation

◆ MTPK_ModifySynthParameter()

bool MidiPlayerTK.MPTKEvent.MTPK_ModifySynthParameter ( fluid_gen_type  genType,
float  value,
MPTKModeGeneratorChange  mode 
)

[Pro] Apply modification on default SoundFont generator value. Can be applied independently for each notes, can be applied in real time when the note is played.

// Create a midi event for a C5 note (60)
mptkEvent = new MPTKEvent() { Value = 60 };
// Fine tuning (pitch)
mptkEvent.MTPK_ModifySynthParameter(fluid_gen_type.GEN_FINETUNE, 0.52f, MPTKModeGeneratorChange.Override);
// Change low pass filter frequency
mptkEvent.MTPK_ModifySynthParameter(fluid_gen_type.GEN_FILTERFC, 0.6f, MPTKModeGeneratorChange.Override);
midiStream.MPTK_PlayDirectEvent(mptkEvent);
!
Parameters
genTypeType of generator to modify. Not all generators are authorized to real time modification. See here https://paxstellar.fr/class-mptkevent#Generator-List
valueValue for the generator between 0 (min value for the generator) and 1 (max value for the generator).
modeOverride: the SoundFont value is overridden, Reinforce: the value is added to the default value.
Returns
true if change has been done

◆ ToData()

ulong MidiPlayerTK.MPTKEvent.ToData ( )

Build a packet midi message from a MPTKEvent. Example: 0x00403C90 for a noton (90h, 3Ch note, 40h volume)

Returns

◆ ToString()

override string MidiPlayerTK.MPTKEvent.ToString ( )

Build a string description of the Midi event. V2.83 removes
on each returns string

Returns

Member Data Documentation

◆ Channel

int MidiPlayerTK.MPTKEvent.Channel

Midi channel fom 0 to 15 (9 for drum)

◆ Command

MPTKCommand MidiPlayerTK.MPTKEvent.Command

Midi Command code. Defined the type of message (Note On, Control Change, Patch Change...)

◆ Controller

MPTKController MidiPlayerTK.MPTKEvent.Controller

Controller code. When the Command is ControlChange, contains the code fo the controller to change (Modulation, Pan, Bank Select ...). Value will contains the value of the controller.

◆ Delay

long MidiPlayerTK.MPTKEvent.Delay

Delay before playing the note in millisecond. New with V2.82, works only in Core mode.

◆ Duration

long MidiPlayerTK.MPTKEvent.Duration

Duration of the note in millisecond. Set -1 to play undefinitely.

◆ IdSession

int MidiPlayerTK.MPTKEvent.IdSession

V2.84 Define an Id associated with this event. Can be used with MPTK_ClearAllSound to clear only a subset of sound associated with this session.

◆ Info

string MidiPlayerTK.MPTKEvent.Info

Information hold by textual meta event when Command=MetaEvent

◆ Length

int MidiPlayerTK.MPTKEvent.Length

Duration of the note in Midi Tick. MidiFilePlayer.MPTK_NoteLength can be used to convert this duration. Not used for MidiStreamPlayer, length is set only when reading a Midi file. https://en.wikipedia.org/wiki/Note_value

◆ Meta

MPTKMeta MidiPlayerTK.MPTKEvent.Meta

MetaEvent Code. When the Command is MetaEvent, contains the code of the meta event (Lyric, TimeSignature, ...). . Info will contains the value of the meta.

◆ Source

uint MidiPlayerTK.MPTKEvent.Source

Origine of the message. Midi ID if from Midi Input else zero. V2.83: rename source to Source et set public.

◆ Tag

object MidiPlayerTK.MPTKEvent.Tag

V2.87 Tag information

◆ Tick

long MidiPlayerTK.MPTKEvent.Tick

Time in Midi Tick (part of a Beat) of the Event since the start of playing the midi file. This time is independent of the Tempo or Speed. Not used for MidiStreamPlayer.

◆ TickTime

long MidiPlayerTK.MPTKEvent.TickTime

V2.86 Time in System.DateTime when the Event is created or read from the Midi file. Can be read from a system thread.

◆ Track

long MidiPlayerTK.MPTKEvent.Track

Index of track.

◆ Value

int MidiPlayerTK.MPTKEvent.Value

Contains a value between 0 and 127 in relation with the Command. For:

  • If Command = NoteOn then Value contains midi note. 60=C5, 61=C5#, ..., 72=C6, ....
  • If Command = ControlChange then Value contains controller value, see MPTKController
  • If Command = PatchChange then Value contains patch/preset/instrument value. See the current SoundFont to find value associated to each instrument.

◆ Velocity

int MidiPlayerTK.MPTKEvent.Velocity

Velocity between 0 and 127

◆ Voices

List<fluid_voice> MidiPlayerTK.MPTKEvent.Voices

List of voices associated to this Event for playing a NoteOn event.

Property Documentation

◆ IsOver

bool MidiPlayerTK.MPTKEvent.IsOver
get

CHeck if playing of this midi event is over (all voices are OFF)

◆ MPTK_DeltaTimeMillis

long MidiPlayerTK.MPTKEvent.MPTK_DeltaTimeMillis
get

V2.86 Delta time in milliseconds since the creation of this event

◆ MPTK_DeltaTimeTick

long MidiPlayerTK.MPTKEvent.MPTK_DeltaTimeTick
get

V2.86 Delta time in system ticks since the creation of this event