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...
Inherits MonoBehaviour, and MonoBehaviour.
Public Member Functions | |
bool | MPTK_Load (byte[] midiBytesToLoad=null) |
bool | MPTK_Load (string filePath) |
void | MPTK_Next () |
MPTKEvent.EnumLength | MPTK_NoteLength (MPTKEvent note) |
void | MPTK_Previous () |
List< MPTKEvent > | MPTK_ReadMidiEvents (long fromTicks=0, long toTicks=long.MaxValue) |
bool | MPTK_SearchMidiToPlay (string name) |
Public Attributes | |
int | MPTK_DeltaTicksPerQuarterNote |
TimeSpan | MPTK_Duration |
double | MPTK_InitialTempo |
bool | MPTK_KeepEndTrack |
bool | MPTK_KeepNoteOff |
int | MPTK_KeySigMajorMinor |
int | MPTK_KeySigSharpsFlats |
bool | MPTK_LogEvents |
int | MPTK_MicrosecondsPerQuarterNote |
int | MPTK_No32ndNotesInQuarterNote |
int | MPTK_NumberBeatsMeasure |
int | MPTK_NumberQuarterBeat |
long | MPTK_TickLast |
int | MPTK_TicksInMetronomeClick |
int | MPTK_TimeSigDenominator |
int | MPTK_TimeSigNumerator |
int | MPTK_TrackCount |
Properties | |
float | MPTK_DurationMS [get] |
int | MPTK_MidiIndex [get, set] |
MidiLoad | MPTK_MidiLoaded [get] |
string | MPTK_MidiName [get, set] |
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.
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).
For more information see here https://paxstellar.fr/prefab-midifileloader/
bool MidiPlayerTK.MidiFileLoader.MPTK_Load | ( | byte[] | midiBytesToLoad = null | ) |
Load the midi file defined with MPTK_MidiName or MPTK_MidiIndex or from a array of bytes. Look at MPTK_MidiLoaded for detailed information about the MIDI loaded.
midiBytesToLoad | byte arry from a midi stream |
bool MidiPlayerTK.MidiFileLoader.MPTK_Load | ( | string | filePath | ) |
[MPTK PRO] Load a MIDI file from a local desktop file. Look at MPTK_MidiLoaded for detailed information about the MIDI loaded.
Example of path for Mac "/Users/xxx/Desktop/WellTempered.mid"
Example of path for Windows "C:\Users\xxx\Desktop\BIM\Sound\Midi\DreamOn.mid"
filePath | Example for Windows: filePath= "C:\Users\xxx\Desktop\BIM\Sound\Midi\DreamOn.mid" |
void MidiPlayerTK.MidiFileLoader.MPTK_Next | ( | ) |
Read next Midi from the list of midi defined in MPTK (see Unity menu Midi)
MPTKEvent.EnumLength MidiPlayerTK.MidiFileLoader.MPTK_NoteLength | ( | MPTKEvent | note | ) |
Return note length as https://en.wikipedia.org/wiki/Note_value
note |
void MidiPlayerTK.MidiFileLoader.MPTK_Previous | ( | ) |
Read previous Midi from the list of midi defined in MPTK (see Unity menu Midi)
List< MPTKEvent > MidiPlayerTK.MidiFileLoader.MPTK_ReadMidiEvents | ( | long | fromTicks = 0 , |
long | toTicks = long.MaxValue |
||
) |
Read the list of midi events available in the Midi file from a ticks position to an end position into a List of MPTKEvent
See full example in TestMidiFileLoad.cs
fromTicks | ticks start, default from start |
toTicks | ticks end, default to the end |
bool MidiPlayerTK.MidiFileLoader.MPTK_SearchMidiToPlay | ( | string | name | ) |
[MPTK PRO] Find a Midi in the Unity resources folder MidiDB which contains the name (case sensitive)
Beware: name of this method is not appropriate because class MidiFileLoader is not able to play MIDI. Rather use MidiFilePlayer class.
We keep it only for compatibility, could be removed with a major version.
Tips: Add MIDI files to your project with the Unity menu MPTK or add it directly in the ressource folder and open MIDI File Setup to automatically integrate MIDI in MPTK.
name | case sensitive part of a MIDI file name |
int MidiPlayerTK.MidiFileLoader.MPTK_DeltaTicksPerQuarterNote |
From Midi Header: Delta Ticks Per Quarter Note.
Represent the duration time in "ticks" which make up a quarter-note.
For instance, if 96, then a duration of an eighth-note in the file would be 48.
TimeSpan MidiPlayerTK.MidiFileLoader.MPTK_Duration |
Duration of the midi.
double MidiPlayerTK.MidiFileLoader.MPTK_InitialTempo |
Initial tempo read in the Midi.
bool MidiPlayerTK.MidiFileLoader.MPTK_KeepEndTrack |
When set to true, meta MIDI event End Track are keep. Default is false.
If set to true, the duration of the MIDI taken into account the End Track Event.
bool MidiPlayerTK.MidiFileLoader.MPTK_KeepNoteOff |
Should keep note off event Events ?
int MidiPlayerTK.MidiFileLoader.MPTK_KeySigMajorMinor |
From KeySignature event: Specifies the scale of the MIDI file.
int MidiPlayerTK.MidiFileLoader.MPTK_KeySigSharpsFlats |
From KeySignature event: Values between -7 and 7 and specifies the key signature in terms of number of flats (if negative) or sharps (if positive) https://www.recordingblogs.com/wiki/midi-key-signature-meta-message
bool MidiPlayerTK.MidiFileLoader.MPTK_LogEvents |
Log midi events
int MidiPlayerTK.MidiFileLoader.MPTK_MicrosecondsPerQuarterNote |
From the SetTempo event: The tempo is given in micro seconds per quarter beat.
To convert this to BPM we needs to use the following equation:BPM = 60,000,000/[tt tt tt]
Warning: this value can change during the playing when a change tempo event is find.
https://paxstellar.fr/2020/09/11/midi-timing/
int MidiPlayerTK.MidiFileLoader.MPTK_No32ndNotesInQuarterNote |
From TimeSignature event: This value specifies the number of 1/32nds of a note happen every MIDI quarter note.
It is usually 8 which means that a quarter note happens every quarter note.
https://paxstellar.fr/2020/09/11/midi-timing/
int MidiPlayerTK.MidiFileLoader.MPTK_NumberBeatsMeasure |
From TimeSignature event: The numerator counts the number of beats in a measure.
For example a numerator of 4 means that each bar contains four beats.
This is important to know because usually the first beat of each bar has extra emphasis.
https://paxstellar.fr/2020/09/11/midi-timing/
int MidiPlayerTK.MidiFileLoader.MPTK_NumberQuarterBeat |
From TimeSignature event: number of quarter notes in a beat.
Equal 2 Power TimeSigDenominator.
https://paxstellar.fr/2020/09/11/midi-timing/
long MidiPlayerTK.MidiFileLoader.MPTK_TickLast |
Last tick position in Midi: Time of the last midi event in sequence expressed in number of "ticks".
MPTK_TickLast / MPTK_DeltaTicksPerQuarterNote equal the duration time of a quarter-note regardless the defined tempo.
int MidiPlayerTK.MidiFileLoader.MPTK_TicksInMetronomeClick |
From TimeSignature event: The standard MIDI clock ticks every 24 times every quarter note (crotchet)
So a MPTK_TicksInMetronomeClick value of 24 would mean that the metronome clicks once every quarter note.
A MPTK_TicksInMetronomeClick value of 6 would mean that the metronome clicks once every 1/8th of a note (quaver).
https://paxstellar.fr/2020/09/11/midi-timing/
int MidiPlayerTK.MidiFileLoader.MPTK_TimeSigDenominator |
From TimeSignature event: The denominator specifies the number of quarter notes in a beat.
2 represents a quarter-note,
3 represents an eighth-note, etc.
https://paxstellar.fr/2020/09/11/midi-timing/
int MidiPlayerTK.MidiFileLoader.MPTK_TimeSigNumerator |
From TimeSignature event: The numerator counts the number of beats in a measure.
For example a numerator of 4 means that each bar contains four beats.
This is important to know because usually the first beat of each bar has extra emphasis.
In MIDI the denominator value is stored in a special format. i.e. the real denominator = 2 ^ MPTK_TimeSigNumerator
https://paxstellar.fr/2020/09/11/midi-timing/
int MidiPlayerTK.MidiFileLoader.MPTK_TrackCount |
Count of track read in the Midi file.
Not to be confused with channel. A track can contains midi events for different channel.
|
get |
Duration (milliseconds) of the midi.
|
getset |
Index Midi. Find the Index of Midi file from the popup in MidiFileLoader inspector.
Tips: Add Midi files to your project with the Unity menu MPTK or add it directly in the ressource folder and open Midi File Setup to automatically integrate Midi in MPTK.
return -1 if not found
index |
|
get |
Get detailed information about the midi loaded.
|
getset |
Midi name to load. Use the exact name defined in Unity resources folder MidiDB without any path or extension. Tips: Add Midi files to your project with the Unity menu MPTK or add it directly in the ressource folder and open Midi File Setup to automatically integrate Midi in MPTK.