Play a list of pre-selected MIDI files from the MidiDB. This class must be used with the prefab MidiListPlayer.
.
More...
|
|
void | MPTK_NewList () |
| | Create an empty list.
|
| void | 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.
|
| void | MPTK_ChangeMidi (string name, int indexList) |
| | Change a Midi in the list.
|
| void | 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 | MPTK_RemoveMidiAt (int index) |
| | Remove a Midi at position from the list..
|
| MPTK_MidiPlayItem | MPTK_GetAt (int index) |
| | Get description of a play item at position.
|
|
void | MPTK_ReIndexMidi () |
| | Recalculate the index of the midi from the list.
|
|
void | MPTK_Play () |
| | Play the midi in list at MPTK_PlayIndex position.
|
|
void | MPTK_Stop () |
| | Stop playing.
|
|
void | MPTK_RePlay () |
| | Restart playing the current midi file.
|
|
void | MPTK_Pause () |
| | Pause the current playing.
|
|
void | MPTK_UnPause () |
| | Pause the current playing.
|
|
void | MPTK_Next () |
| | Play next Midi in list.
|
|
void | MPTK_Previous () |
| | Play previous Midi in list.
|
|
|
float | MPTK_Volume [get, set] |
| | Volume of midi playing. Must be >=0 and <= 1.
|
|
int | MPTK_PlayIndex [get, set] |
| | Play a specific Midi in the list.
|
|
bool | MPTK_PlayOnStart [get, set] |
| | Should the Midi much restart at first of the list when playing list is over?
|
|
bool | MPTK_MidiLoop [get, set] |
| | Should the playing be restarted at the beginning of the list when the playlist is finished?
|
| double | MPTK_Position [get, set] |
| | 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.
|
|
long | MPTK_TickLast [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.
|
|
long | MPTK_TickCurrent [get, set] |
| | 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/.
|
|
TimeSpan | MPTK_Duration [get] |
| | Duration of the currrent midi playing. This duration can change during the playing when Change Tempo Event are processed.
|
|
bool | MPTK_IsPaused [get] |
| | Is Midi is paused ?
|
|
bool | MPTK_IsPlaying [get] |
| | Is Midi is playing ?
|
Play a list of pre-selected MIDI files from the MidiDB. This class must be used with the prefab MidiListPlayer.
.
- Version
- Maestro Pro
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/
private void Update()
{
if (IsDisplayFulllLog != null && IsDisplayFulllLog.isOn)
{
MidiListPlayer.MidiListPlayerStatus current;
current = midiListPlayer.MPTK_GetPlaying;
if (current != null) DisplayLog("Playing", current);
current = midiListPlayer.MPTK_GetStarting;
if (current != null) DisplayLog("Starting", current);
current = midiListPlayer.MPTK_GetEnding;
if (current != null) DisplayLog("Ending ", current);
}
}
private void DisplayLog(string from, MidiListPlayer.MidiListPlayerStatus current)
{
Debug.Log(
$"{from} - Name:{current.MPTK_MidiFilePlayer.name} " +
$"Status:{current.StatusPlayer} " +
$"EndAt:{current.EndAt} " +
$"PlayTime:{current.MPTK_MidiFilePlayer.MPTK_PlayTime} " +
$"MIDI:{current.MPTK_MidiFilePlayer.MPTK_MidiName} " +
$"PctVolume:{current.PctVolume:F2} " +
$"Active Voice:{current.MPTK_MidiFilePlayer.MPTK_StatVoiceCountActive} " +
$"Audio Read MS:{current.MPTK_MidiFilePlayer.StatAudioFilterReadMS:F2} " +
$"Dsp Load Pct:{current.MPTK_MidiFilePlayer.StatDspLoadPCT:F2} "
);
}