Play a list of pre-selected MIDI files from the MidiDB. This class must be used with the prefab MidiListPlayer.
More...
Inherits MonoBehaviour.
class inhiriting | |
class | MidiListPlayerStatus |
Midi Player status for the two MIDI Players defined in the MidiListPlayer. More... | |
class | MPTK_MidiPlayItem |
Define a MIDI file from DBMidi to be added in the list More... | |
Public Types | |
enum | enStatusPlayer { Starting , Playing , Ending , Stopped } |
Public Member Functions | |
void | MPTK_AddMidi (string name, float start=0, float end=0) |
void | MPTK_ChangeMidi (string name, int indexList) |
MPTK_MidiPlayItem | MPTK_GetAt (int index) |
void | MPTK_NewList () |
void | MPTK_Next () |
void | MPTK_Pause () |
void | MPTK_Play () |
void | MPTK_Previous () |
void | MPTK_ReIndexMidi () |
void | MPTK_RemoveMidi (string name) |
void | MPTK_RemoveMidiAt (int index) |
void | MPTK_RePlay () |
void | MPTK_Stop () |
void | MPTK_UnPause () |
Public Attributes | |
MidiListPlayerStatus | MPTK_MidiFilePlayer_1 |
MidiListPlayerStatus | MPTK_MidiFilePlayer_2 |
float | MPTK_OverlayTimeMS |
List< MPTK_MidiPlayItem > | MPTK_PlayList |
EventEndMidiClass | OnEventEndPlayMidi |
EventStartMidiClass | OnEventStartPlayMidi |
Properties | |
TimeSpan | MPTK_Duration [get] |
bool | MPTK_IsPaused [get] |
bool | MPTK_IsPlaying [get] |
bool | MPTK_MidiLoop [get, set] |
int | MPTK_PlayIndex [get, set] |
bool | MPTK_PlayOnStart [get, set] |
double | MPTK_Position [get, set] |
long | MPTK_TickCurrent [get, set] |
long | MPTK_TickLast [get] |
float | MPTK_Volume [get, set] |
Play a list of pre-selected MIDI files from the MidiDB. This class must be used with the prefab MidiListPlayer.
See "Midi File Setup" in the Unity menu MPTK for adding MIDI in MidiDB.
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 with an overlap time between.
See Midi Player Setup (Unity menu MPTK) for adding MIDI in MidiDB.
More information here https://paxstellar.fr/midi-list-player-v2/
void MidiPlayerTK.MidiListPlayer.MPTK_AddMidi | ( | string | name, |
float | start = 0 , |
||
float | end = 0 |
||
) |
Add a Midi name to the list. 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.
name | midi filename as defined in resources |
start | starting time of playing (ms). Default: start of the midi |
end | endding time of playing (ms). Default: end of midi |
void MidiPlayerTK.MidiListPlayer.MPTK_ChangeMidi | ( | string | name, |
int | indexList | ||
) |
Change a Midi in the list
name | |
indexList |
MPTK_MidiPlayItem MidiPlayerTK.MidiListPlayer.MPTK_GetAt | ( | int | index | ) |
Get description of a play item at position.
void MidiPlayerTK.MidiListPlayer.MPTK_NewList | ( | ) |
Create an empty list
void MidiPlayerTK.MidiListPlayer.MPTK_Next | ( | ) |
Play next Midi in list
void MidiPlayerTK.MidiListPlayer.MPTK_Pause | ( | ) |
Pause the current playing
void MidiPlayerTK.MidiListPlayer.MPTK_Play | ( | ) |
Play the midi in list at MPTK_PlayIndex position
void MidiPlayerTK.MidiListPlayer.MPTK_Previous | ( | ) |
Play previous Midi in list
void MidiPlayerTK.MidiListPlayer.MPTK_ReIndexMidi | ( | ) |
Recalculate the index of the midi from the list.
void MidiPlayerTK.MidiListPlayer.MPTK_RemoveMidi | ( | string | name | ) |
Remove a Midi name from the list. Use the exact name defined in Unity resources folder MidiDB without any path or extension.
void MidiPlayerTK.MidiListPlayer.MPTK_RemoveMidiAt | ( | int | index | ) |
Remove a Midi at position from the list..
void MidiPlayerTK.MidiListPlayer.MPTK_RePlay | ( | ) |
Restart playing the current midi file
void MidiPlayerTK.MidiListPlayer.MPTK_Stop | ( | ) |
Stop playing
void MidiPlayerTK.MidiListPlayer.MPTK_UnPause | ( | ) |
Pause the current playing
MidiListPlayerStatus MidiPlayerTK.MidiListPlayer.MPTK_MidiFilePlayer_1 |
First MidiFilePlayer to play the Midi
MidiListPlayerStatus MidiPlayerTK.MidiListPlayer.MPTK_MidiFilePlayer_2 |
Second MidiFilePlayer to play the Midi
float MidiPlayerTK.MidiListPlayer.MPTK_OverlayTimeMS |
Duration of overlay between playing two midi in milliseconds
List<MPTK_MidiPlayItem> MidiPlayerTK.MidiListPlayer.MPTK_PlayList |
Play list
EventEndMidiClass MidiPlayerTK.MidiListPlayer.OnEventEndPlayMidi |
Define unity event to trigger at the end playing of each Midi in the list
EventStartMidiClass MidiPlayerTK.MidiListPlayer.OnEventStartPlayMidi |
Define unity event to trigger at the start playing of each Midi in the list
|
get |
Duration of the currrent midi playing. This duration can change during the playing when Change Tempo Event are processed.
|
get |
Is Midi is paused ?
|
get |
Is Midi is playing ?
|
getset |
Should the playing be restarted at the beginning of the list when the playlist is finished?
|
getset |
Play a specific Midi in the list.
|
getset |
Should the Midi much restart at first of the list when playing list is over?
|
getset |
Set or Get midi position of the currrent midi playing. Position is a time in millisecond. Be carefull when modifying position on fly from GUI, weird behavior can happen If the Midi contains tempo change, the position could not reflect the real time from the beginning. Use MPTK_TickCurrent to change the position in tick which is independent of the tempo and the speed. There is no effect if the Midi is not playing.
|
getset |
Set or get the current tick position in the Midi when playing. Midi tick is an easy way to identify a position in a song independently of the time which could vary with tempo change. The count of ticks for a quarter is constant all along a Midi: see properties MPTK_DeltaTicksPerQuarterNote. Example: with a time signature of 4/4 the ticks length of a bar is 4 * MPTK_DeltaTicksPerQuarterNote. Warning: if you want to set the start position, set MPTK_TickCurrent inside the processing of the event OnEventStartPlayMidi because MPTK_Play() reset the start position to 0. Other possibility to change the position in the Midi is to use the property MPTK_Position: set or get the position in milliseconds but tempo change event will impact also this time. More info here https://paxstellar.fr/2020/09/11/midi-timing/
|
get |
Last tick position of the currrent midi playing: Value of the tick for 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.
|
getset |
Volume of midi playing. Must be >=0 and <= 1