![]() |
Maestro - Midi Player Tool Kit for Unity Version 2.18.2
|
Plays a local MIDI file or a MIDI file from a website. This class must be used with the MidiExternalPlayer prefab.
.
More...
Public Member Functions | |
| override void | MPTK_Play (bool alreadyLoaded=false) |
| Plays the MIDI file defined with MPTK_MidiName. | |
| void | MPTK_Stop () |
| Stops MIDI playback and cancels all sounds. This operation is performed in background, so MIDI may really stop after this method returns. | |
| void | MPTK_Stop (bool stopAllSound=true, float wait=-1f) |
| Stops MIDI playback and cancels all sounds. This operation is performed in background, so MIDI may really stop after this method returns. | |
| void | MPTK_RePlay () |
| Restart playing of the current midi file. | |
| void | MPTK_Pause (float timeToPauseMS=-1f) |
| Pause the current playing. Use MPTK_UnPause to continue playing. | |
| void | MPTK_UnPause () |
| UnPause the current playing when MidiPlayer is paused with MPTK_Pause. | |
| void | MPTK_Next () |
| Plays next MIDI from the list of midi defined in MPTK (see Unity menu Midi). | |
| void | MPTK_Previous () |
| Plays previous MIDI from the list of midi defined in MPTK (see Unity menu Midi). | |
| bool | MPTK_SearchMidiToPlay (string searchPartOfName) |
| Finds a MIDI in the Unity Resources folder MidiDB whose name contains searchPartOfName (case-sensitive). Sets MPTK_MidiIndex and MPTK_MidiName if the MIDI is found. | |
| void | MPTK_PlayNextOrPrevious (int offset) |
| Plays the next or previous MIDI from the MidiDB list. | |
| void | MPTK_SwitchMidiWithDelay (int index, string name, float volume, float delayToStopMillisecond, float delayToStartMillisecond) |
| Switches playback between two MIDIs with ramp-up. This method is useful for integration with Bolt: main MIDI parameters are defined in one call. | |
| virtual void | MPTK_Play (float delayRampUp, float startDelay=0) |
| Plays the MIDI file defined by MPTK_MidiName or MPTK_MidiIndex with ramp-up to the volume defined by MPTK_Volume. The time to get a MIDI playing at full MPTK_Volume is delayRampUp + startDelay. A delayed start can also be set. | |
| void | MPTK_Play (byte[] data) |
| Plays a MIDI file from a byte array. Check MPTK_StatusLastMidiLoaded to get the load status. | |
| void | MPTK_Play (MPTKWriter mfw2, float delayRampUp=0f, float fromPosition=0, float toPosition=0, long fromTick=0, long toTick=0, bool timePosition=true) |
| Plays a MIDI from a MidiFileWriter2 object. | |
| virtual void | MPTK_Stop (float delayRampDown, float stopDelay=0) |
| Stops playback after a delay. After the stop delay (0 by default), the volume decreases until playback stops. The time to get a real MIDI stop is delayRampDown + stopDelay. | |
| void | MPTK_ResetTranspose () |
| Force all notes to return to their original values before transposing. Useful when looping on a MIDI with a transpose value different than 0. When returning to 0 (no transpose) the note value can be reset to their original value. | |
| MPTKEvent.EnumLength | MPTK_NoteLength (MPTKEvent note) |
| Return note length as https://en.wikipedia.org/wiki/Note_value. | |
| MidiLoad | MPTK_Load () |
| Loads the midi file defined with MPTK_MidiName or MPTK_MidiIndex. It's an optional action before playing a midi file with MPTK_Play() Use this method to get all MIDI events before start playing. | |
| List< MPTKEvent > | MPTK_ReadMidiEvents (long fromTicks=0, long toTicks=long.MaxValue) |
| Read the list of midi events available in the MIDI from a ticks tick to an end tick. | |
| void | MPTK_SortEvents () |
| MIDI list events must be sorted by ticks before playing. It's mandatory if the list is modified. | |
| MidiLoad | MPTK_Load (string uri) |
| Loads a MIDI file from a local desktop file. Example paths: | |
| Public Member Functions inherited from MidiPlayerTK.MidiSynth | |
| IEnumerator | MPTK_WaitAllNotesOff (int _idSession=-1) |
| Waits until all notes are off. This may take a few seconds because samples must complete their release time. The method exits after a 3-second timeout. *** Use this method only as a coroutine. ***. | |
| void | MPTK_InitSynth (int channelCount=16, bool preserveChannelInfo=false, bool preserveActivVoice=true) |
| Initializes the synthesizer: | |
| void | MPTK_InitModulators () |
| Initializes the default MIDI modulators for the synthesizer, mapping standard MIDI inputs to corresponding sound synthesis parameters according to SoundFont 2.01 specifications. | |
| void | MPTK_StartSequencerMidi () |
| Starts the MIDI sequencer: each MIDI event is read and played on a dedicated thread. This thread is started automatically by the MidiFilePlayer, MidiListPlayer, and MidiExternalPlayer prefabs. | |
| void | MPTK_StartSynth () |
| Starts processing samples by the synth and the MIDI sequencer. Useful only after calling MPTK_StopSynth when using MidiStreamPlayer. | |
| void | MPTK_StopSynth () |
| Stops processing samples by the synth and the MIDI sequencer. See also MPTK_StartSynth. | |
| void | MPTK_ClearAllSound (bool destroyAudioSource=false, int _idSession=-1) |
| Clears all sound by sending NoteOff messages. This can take a few seconds because sample release times must play out. | |
| void | MPTK_DebugActiveVoice () |
| Log information about active voices. | |
| void | MPTK_DebugFreeVoice () |
| Log information about free voices. | |
| void | MPTK_ResetStat () |
| Reset voices statistics. | |
| delegate void | OnAudioFrameStartHandler (double synthTime) |
| Delegate for the OnAudioFrameStart event. | |
| void | MPTK_PlayDirectEvent (MPTKEvent midiEvent, bool playNoteOff=true) |
| Plays a single MIDI event immediately. Processing is synchronous: the method returns only after the MIDI event has been handled by the synth. | |
| void | MPTK_StopDirectEvent (MPTKEvent midiEvent) |
| Stops immediately the MIDI event played with @MPTK_PlayDirectEvent. Processing is synchronous: the method returns after all voices for the notes have been handled by the synth. | |
| void | MPTK_PauseVoices (float transitionDuration=30f) |
| Pauses all active voices using the specified transition duration. | |
| void | MPTK_ResumeVoices (float transitionDuration=30f) |
| Resumes all active voices using the specified transition duration. | |
MIDI Playback Control | |
Controls playback of MIDI events and sequences. These methods allow scripts to start, stop, pause, or control the flow of MIDI playback. They interact with the internal MIDI sequencer and control how events are scheduled and rendered by the synthesizer. This includes transport control and runtime playback management. | |
| new string | MPTK_MidiName [get, set] |
| Sets the full URI to a MIDI file: use file:// for a local file, or http:// / https:// for a web resource. The MIDI file is then loaded and played. . | |
Additional Inherited Members | |
| enum | ModeStopPlay { StopNoWaiting , StopWhenAllVoicesReleased , StopWhenAllVoicesEnded } |
| Defined the behavior of the MIDI player when playback is stopped with MPTK_Stop or restarted when the last MIDI events is reached and MPTK_MidiAutoRestart is set to true. See also MPTK_ModeStopVoice. More... | |
| enum | ModeSpatializer { Channel , Track } |
| Routing mode used by the MidiSpatializer prefab (MIDI Spatial Mapper). Selects how incoming Note On events are dispatched to spatial synth instances. More... | |
| bool | MPTK_StartPlayAtFirstNote |
| If the value is true, MIDI playing will begin at the first note found in the MIDI. | |
| bool | MPTK_StopPlayOnLastNote |
| By default, the end of a MIDI file is not the last note. It is the last MIDI event. If this value is true, MIDI playback will stop at the last note found in the MIDI file and the OnEventEndPlay will be triggered at the last note. | |
| ModeStopPlay | MPTK_ModeStopVoice |
| Defined the behavior of the MIDI player when playback is stopped with MPTK_Stop or restarted when the last MIDI events is reached and MPTK_MidiAutoRestart is set to true. Code example: | |
| bool | MPTK_PauseOnFocusLoss |
| Should the MIDI playing must be paused when the application lost the focus? | |
| bool | MPTK_LogLoadEvents |
| If true display in console all midi events when a MIDI file is loaded. . | |
| LoadingStatusMidiEnum | MPTK_StatusLastMidiLoaded |
| Status of the last midi loaded. The status is updated in a coroutine, so the status can change at each frame. | |
| string | MPTK_WebRequestError |
| Contains the error from the web request when loading MIDI from an URL. | |
| EventNotesMidiClass | OnEventNotesMidi |
| Method triggered for each MIDI event (or group of MIDI events) ready to be played by the MIDI synth. All these events are on same MIDI tick . The callback method is able to directly interacts with Unity gameObject (same thread). A List<MPTKEvent> is passed to the delegate. | |
| EventStartMidiClass | OnEventStartPlayMidi |
| Define the Unity event to be triggered at the start of Midi playback. At this moment, the MIDI file is loaded, the MIDI synth is initialised, but no MIDI event has been read yet. This is the right time to defined some specific behaviors. | |
| EventEndMidiClass | OnEventEndPlayMidi |
| Specify the Unity event that is triggered when the end of the MIDI list of events is reached. | |
| MPTKInnerLoop | MPTK_InnerLoop |
| ModeSpatializer | MPTK_ModeSpatializer |
| Current routing mode for MidiSpatializer (MIDI Spatial Mapper). | |
| int | MPTK_MaxSpatialSynth |
| Gets or sets the maximum number of spatial synth instances that can be created/used by MidiSpatializer. | |
| bool | MPTK_SpatialSynthEnabled |
| In MidiSpatializer mode, not all MidiSynth instances are active. True if this synth instance is currently enabled for spatial rendering. | |
| int | MPTK_InstrumentNum |
| In Track mode, contains the program number (preset) of the last instrument played. | |
| MPTKSoundFont | MPTK_SoundFont = null |
| At runtime, SoundFonts can be loaded dynamically from the local file system or directly from the web. This avoids embedding a SoundFont in your build, which is ideal for in-app purchases or downloadable content. Legacy mode still allows loading SoundFonts from the internal MPTK database. Maestro MPTK also lets you assign different SoundFonts to different MIDI players (MidiFilePlayer, MidiStreamPlayer, ...), enabling flexible, per-player audio rendering. | |
| float | MPTK_LeanSynthStarting = 0.05f |
| Gets or sets the initial volume level of the synthesizer at application startup. This property allows for a gradual increase in volume to prevent abrupt or unusual sounds when the application begins. | |
| bool | MPTK_EnablePresetDrum |
| Accept preset changes on Drum Channel 9 (percussion). Enabling this can produce unexpected results with MIDI files that are not standard-compliant. If disabled, preset changes on channel 9 are ignored (preset 0 remains in use). | |
| bool | MPTK_ReleaseSameNote = true |
| If the same note is hit twice on the same channel, the older voice is advanced to the release stage. This is the default MIDI processing behavior. | |
| bool | MPTK_KillByExclusiveClass = true |
| Finds the exclusive class of this voice. When enabled, stops all voices that share the exclusive class and were created after the first voice for this note-on event. | |
| float | MPTK_ReleaseTimeMod = 1f |
| When a note is stopped with a note-off or when its duration is over, it continues to play for a short time depending on the instrument. This parameter multiplies the default release time defined in the SoundFont for each instrument. Recommended values are between 0.1 and 10. Default is 1 (no change to the release time). Performance note: the longer the release, the more CPU is used after note-on, because many samples may play simultaneously. | |
| float | MPTK_CutOffVolume = 0.0001f |
| When the amplitude of a sample falls below this value, playback stops. Increasing the value can improve performance when many samples play concurrently, but may stop samples too early and reduce quality. Remember: amplitude ranges between 0 and 1. | |
| bool | MPTK_ApplyRealTimeModulator |
| Gradually ramps the synth volume at startup to avoid artifacts. Controls how quickly the audio source reaches full volume. Set to 1 for an immediate full level at start. | |
| bool | MPTK_ApplyModLfo |
| Apply LFO effect defined in the SoundFont. | |
| bool | MPTK_ApplyVibLfo |
| Apply vibrato effect defined in the SoundFont. | |
| bool | MPTK_DirectSendToPlayer |
| If true (default) then MIDI events are sent automatically to the MIDI player. Sets to false if you want to process events without playing sound. OnEventNotesMidi Unity Event can be used to process each note. | |
| bool | MPTK_EnableChangeTempo |
| Enable tempo changes from the MIDI file during playback. If disabled, only the first tempo change in the MIDI file is applied (or 120 BPM if none is found). Disable this when you want to control tempo from your script. | |
| bool | MPTK_EnablePanChange |
| Apply pan changes from MIDI events in the SoundFont. Pan is disabled when spatialization is activated. | |
| bool | MPTK_WeakDevice |
| Optimize playback for low-power devices (for example, budget smartphones). Applies only in AudioSource mode (MPTK_CorePlayer = false). Enabling this may cause imperfect MIDI interpretation and lower sound quality. | |
| uint | MPTK_ReleaseTimeMin = 500000 |
| [Only when CorePlayer = false] Defines a minimum release time at note-off in 100-nanosecond units. The 50 ms default is a good tradeoff; shorter values can produce unpleasant artifacts. No effect when MPTK_CorePlayer is true. | |
| int | MPTK_ThreadMidiWait = 10 |
| Delay (in milliseconds) that the MIDI sequencing thread waits between processing MIDI event batches. | |
| bool | MPTK_AutoBuffer = true |
| Enable voice buffering to improve runtime performance. | |
| int | MPTK_AutoCleanVoiceLimit |
| Removes free voices older than MPTK_AutoCleanVoiceTime once their count exceeds MPTK_AutoCleanVoiceLimit. | |
| float | MPTK_AutoCleanVoiceTime |
| Delay (in milliseconds) that the MIDI sequencing thread waits between processing MIDI event batches. | |
| MPTKEffectSoundFont | MPTK_EffectSoundFont |
| A SoundFont defines parameters for three kinds of effects: low-pass filter, reverb, and chorus. These parameters can be specific to each instrument and even each voice. Maestro MPTK effects are based on FluidSynth algorithmic effect modules. Maestro Pro can increase or decrease the impact of these effects (from the inspector or by script). To summarize: | |
| MPTKEffectUnity | MPTK_EffectUnity |
| Unlike SoundFont effects, Unity audio effects apply to the whole player. Their parameters are richer and rely on Unity's audio algorithms. https://docs.unity3d.com/Manual/class-AudioEffectMixer.html Maestro integrates the most important effects: Reverb and Chorus. Other effects could be added if needed. | |
| bool | MPTK_AudioSettingFromUnity |
| Use the audio settings provided by Unity instead of custom values. | |
| bool | MPTK_EnableFreeSynthRate = false |
| Allow direct setting of the Synth Rate. | |
| bool | MPTK_LogEvents |
| Log MIDI events (v2.9.0 moved from MidiFilePlayer). | |
| bool | MPTK_LogWave |
| Log for each sample to be played. | |
| int | MPTK_StatVoiceCountPlaying |
| Count of active voices (playing, excluding voices in release). Sound may still be audible from voices in release even when this count is 0. Read-only. | |
| int | MPTK_StatVoiceCountActive |
| Count of the active voices (playing and releasing) - Readonly. | |
| int | MPTK_StatVoiceCountReused |
| Count of the voices reused - Readonly. | |
| int | MPTK_StatVoiceCountFree |
| Count of free voices available for reuse. Voices older than AutoCleanVoiceTime are removed only when the count exceeds AutoCleanVoiceLimit. Read-only. | |
| int | MPTK_StatVoiceRatioReused |
| Percentage of voices reused during the synth lifetime. 0: no reuse, 100: all voices reused (unattainable in practice). | |
| int | MPTK_StatVoicePlayed |
| Count of voice played since the start of the synth. | |
| EventSynthClass | OnEventSynthAwake |
| Unity event fired during the synthesizer's Awake. The GameObject component name is passed as a parameter. Setting this callback via script (AddListener) is not recommended; prefer setting it from the inspector. | |
| EventSynthClass | OnEventSynthStarted |
| Unity event fired when the synthesizer starts. The GameObject component name is passed as a parameter. Setting this callback via script (AddListener) is not recommended; prefer setting it from the inspector. | |
| Func< MPTKEvent, bool > | OnMidiEvent |
| Called by the MIDI sequencer before sending a MIDI message to the synthesizer. From version 2.10.0 onward, the callback must return true to keep the event or false to skip it. | |
| Action< int, long, int, int > | OnBeatEvent |
| Invoked on each beat with the following parameters: | |
| float | MPTK_OrientationToListener |
| Returns the signed angle (in degrees) between the sound source and the AudioListener. | |
| bool | MPTK_PauseOnMaxDistance = true |
| If true, the MIDI player will be automatically paused when the distance from the listener exceeds MPTK_MaxDistance. | |
| static string[] | ModeStopPlayLabel = { "Stop No Waiting", "Stop When All Voices Are Released", "Stop When All Voices Are Ended" } |
| Defined the behavior of the MIDI player when playback is stopped with MPTK_Stop or restarted when the last MIDI events is reached and MPTK_MidiAutoRestart is set to true. See also MPTK_ModeStopVoice. | |
| static List< MidiFilePlayer > | SpatialSynths |
| Contains each Midi Synth for each channel or track when the prefab MidiSpatializer is used and IsMidiChannelSpace=true. Warning: only one MidiSpatializer can be used in a hierarchy. | |
| string | midiNameToPlay |
| Defined the behavior of the MIDI player when playback is stopped with MPTK_Stop or restarted when the last MIDI events is reached and MPTK_MidiAutoRestart is set to true. See also MPTK_ModeStopVoice. | |
| virtual string | MPTK_MidiName [get, set] |
| Select a MIDI from the MIDIDB to play by its name. Use the exact name as seen in the MIDI setup windows (Unity menu MPTK/ without any path or extension. Tips: Add MIDI files to your project with the Unity menu MPTK. | |
| int | MPTK_MidiIndex [get, set] |
| Select a MIDI file to play by its Index from the MIDIDB. The Index of a MIDI file is displayed in the popup from the MidiFilePlayer inspector and in the window "Midi File Setup" from the MPTK menu in the editor. . | |
| bool | MPTK_PlayOnStart [get, set] |
| Whether the MIDI playback starts when the application starts? | |
| bool | MPTK_MidiAutoRestart [get, set] |
| When the value is true, the current MIDI playing is restarted when it reaches the end of the MIDI file or #MPTK_MidiLoaded.MPTK_TickEnd. . | |
| bool | MPTK_IsPaused [get] |
| Is MIDI file playing is paused ? | |
| bool | MPTK_IsPlaying [get] |
| Is MIDI file is playing ? | |
| MPTKChannels | MPTK_Channels [get] |
| Description and list of MIDI Channels associated to the MIDI synth. Each MIDI synth has 16 channels that carry all the relevant MIDI information. | |
| double | MPTK_Position [get, set] |
| Gets or sets the current position in the MIDI in milliseconds. When a new position is set, the corresponding tick in the MIDI event list is searched for by comparing it with the MPTKEvent.RealTime value, and the current MIDI playback is moved to this new tick position. . | |
| TimeSpan | MPTK_Duration [get] |
| Real duration expressed in TimeSpan of the full midi from the first event (tick=0) to the last event. If MPTK_KeepEndTrack is false, the MIDI events End Track are not considered to calculate this time. The tempo changes are taken into account if MPTK_EnableChangeTempo is set to true before loading the MIDI. | |
| float | MPTK_DurationMS [get] |
| Real duration expressed in milliseconds of the full MIDI from the first event (tick=0) to the last event. If MPTK_KeepEndTrack is false, the MIDI events End Track are not considered to calculate this time. The tempo changes are taken into account if MPTK_EnableChangeTempo is set to true before loading the MIDI. | |
| long | MPTK_TickLast [get] |
| Last tick tick in Midi: it's the value of the tick for the last MIDI event in sequence expressed in number of "ticks". . | |
| long | MPTK_TickFirstNote [get] |
| Tick tick for the first note-on found. Most MIDI don't start playing a note immediately. There is often a delay. Use this attribute to known the tick tick where the will start to play a sound. See also MPTK_PositionFirstNote. | |
| long | MPTK_TickLastNote [get] |
| Tick tick for the last note-on found. There is often other MIDI events after the last note-on: for example event track-end. Use this attribute to known the tick tick time when all sound will be stop. See also the MPTK_PositionLastNote which provides the last time of the MIDI. | |
| double | MPTK_PositionFirstNote [get] |
| Real time tick in milliseconds for the first note-on found. Most MIDI don't start playing a note immediately. There is often a delay. Use this attribute to known the real time which it will start. See also MPTK_TickFirstNote. | |
| double | MPTK_PositionLastNote [get] |
| Real time tick in milliseconds for the last note-on found in the MIDI. There is often other MIDI events after the last note-on: for example event track-end. Use this attribute to known the real time when all sound will be stop. See also the MPTK_DurationMS which provides the full time of all MIDI events including track-end, control at the beginning and at the end, .... See also MPTK_TickLastNote. | |
| int | MPTK_TrackCount [get] |
| Count of track read in the MIDI file. | |
| long | MPTK_TickCurrent [get, set] |
| Gets the tick value of the last MIDI event played. Sets the tick value of the next MIDI event to played. . | |
| bool | MPTK_RawSeek [get, set] |
| This parameter controls how the playback position is adjusted within a MIDI file. By default (false), when the playback position is changed, all events except "note-on" are replayed from the start of the MIDI file up to the new position. This ensures the synthesizer is correctly updated with the appropriate context (tempo, selected instruments, controllers, etc.). If set to true, the playback position is updated directly; consequently, the current context is preserved. While this approach can lead to unintended (or amusing!) effects in some MIDI files, it allows for much faster position changes. | |
| MPTKEvent | MPTK_LastEventPlayed [get] |
| Last MIDI event played by the MIDI sequencer. | |
| double | MPTK_Pulse [get] |
| Length in milliseconds of a MIDI tick. The pulse length is the minimum time in milliseconds between two MIDI events. It's like a definition of graphical resolution but for MIDI: the MIDI sequencer will not be able to play two separate MIDI events in a time below this value. . | |
| double | MPTK_PulseLenght [get] |
| Gets or sets the current position in the MIDI in milliseconds. When a new position is set, the corresponding tick in the MIDI event list is searched for by comparing it with the MPTKEvent.RealTime value, and the current MIDI playback is moved to this new tick position. . | |
| TimeSpan | MPTK_PlayTime [get] |
| Real time in TimeSpan format from the beginning of play. It's an access to the MIDI timer used by the MIDI sequencer. | |
| double | MPTK_RealTime [get] |
| Real time in milliseconds from the beginning of play. It's an access to the MIDI timer used by the MIDI sequencer. | |
| float | MPTK_Speed [get, set] |
| Percentage of the default playback speed. Range 0.1 (10% of the current BPM) to 10 (1000%). Default is 1 for normal speed. Speed also applied to the duration of the sample played at voice level (often multiple voices are played for one note). | |
| bool | MPTK_Loop [get, set] |
| double | MPTK_Tempo [get, set] |
| Gets or sets the current tempo played by the internal MIDI sequencer (independent from MPTK_Speed). Return QuarterPerMinuteValue similar to BPM (Beat Per Measure). . | |
| string | MPTK_SequenceTrackName [get] |
| Gets sequence track name if defined in the MIDI file with MIDI MetaEventType = SequenceTrackName See detail here https://ccrma.stanford.edu/~craig/14q/midifile/MidiFileFormat.html Can be used only when the MIDI is playing. | |
| string | MPTK_ProgramName [get] |
| Gets Program track name if defined in the MIDI file with MIDI MetaEventType = ProgramName See detail here https://ccrma.stanford.edu/~craig/14q/midifile/MidiFileFormat.html Can be used only when the MIDI is playing. | |
| string | MPTK_TrackInstrumentName [get] |
| Gets Instrument track name if defined in the MIDI file with MIDI MetaEventType = TrackInstrumentName See detail here https://ccrma.stanford.edu/~craig/14q/midifile/MidiFileFormat.html Can be used only when the MIDI is playing. | |
| string | MPTK_TextEvent [get] |
| Gets Text if defined in the MIDI file with MIDI MetaEventType = TextEvent See detail here https://ccrma.stanford.edu/~craig/14q/midifile/MidiFileFormat.html Can be used only when the MIDI is playing. | |
| string | MPTK_Copyright [get] |
| Gets Copyright if defined in the MIDI file with MIDI MetaEventType = Copyright See detail here https://ccrma.stanford.edu/~craig/14q/midifile/MidiFileFormat.html Can be used only when the MIDI is playing. | |
| List< MPTKEvent > | MPTK_MidiEvents [get] |
| Gets a list of all the MPTK MIDI events that are available in the MIDI. . | |
| int | MPTK_Quantization [get, set] |
| Level of quantization : | |
| int | MPTK_DeltaTicksPerQuarterNote [get] |
| Delta Ticks Per Beat Note. Indicate 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. More info here https://paxstellar.fr/2020/09/11/midi-timing/ . | |
| MidiLoad | MPTK_MidiLoaded [get] |
| Gets detailed information about MIDI playback. This readonly property is available only when a MIDI has been loaded. | |
| bool | MPTK_KeepNoteOff [get, set] |
| A MIDI file is a kind of keyboard simulation: in general, a key pressed generates a 'note-on' and a key release generates a 'note-off'. But there is an other possibility in a MIDI file: create a 'note-on' with a velocity=0 which must act as a 'midi-off' By default, MPTK create only one MPTK event with the command NoteOn and a duration. But in some cases, you could want to keep the note-off events if they exist in the MIDI file. Sets to false if there is no need (could greatly increases the MIDI list events). Sets to true to keep 'note-off' events. | |
| bool | MPTK_KeepEndTrack [get, set] |
| When set to true, meta MIDI event End Track are keep. Default is false. If set to true, the End Track Event are taken into account for calculate the full duration of the MIDI. See MPTK_DurationMS. | |
| bool | MPTK_ExtendedText [get, set] |
| If the value is true, text read from Text META (e.g. lyrics) will be read with UTF8 encoding. The default is false. The MIDI standard only allows ASCII characters for this META, but with this extension you will be able to read and display characters like Korean, Chinese, Japanese and even French accented letters ;-). | |
| int | MPTK_SpatialSynthIndex [get] |
| Index of the MidiSynth for the dedicated Channel or Track when the prefab MidiSpatializer is used. If MPTK_ModeSpatializer = Channel then represent the playing channel. If MPTK_ModeSpatializer = Track then represent the playing track. The value is -1 for the Midi reader because no voice is played. | |
| bool | MPTK_IsSpatialSynthMaster [get] |
| True if this MidiSynth is the master spatial synth used by MidiSpatializer. The master synth reads MIDI events and dispatches them to the other spatial synth instances. | |
| string | MPTK_InstrumentPlayed [get] |
| In Track mode, returns the name of the last instrument played on this track. Empty string if unknown. | |
| string | MPTK_TrackName [get] |
| In Track mode, returns the last known track name. Empty string if the MIDI file does not provide SequenceTrackName. | |
| bool | MPTK_KeepPlayingNonLooped [get, set] |
| When the value is true, NoteOff and Duration for non-looped samples are ignored and the samples play through to the end. | |
| float | MPTK_VelocityAttenuation [get, set] |
| Experimental feature: modify the Fluidsynth constant FLUID_PEAK_ATTENUATION to change how velocity affects the voice attenuation. The default value is 960 (96 Db) Other values may produce unwanted results, use with care! | |
| float | MPTK_Volume [get, set] |
| Sets the global volume between 0 and 1 for the current MPTK Synth. | |
| int | MPTK_Transpose [get, set] |
| Transposes notes from -24 to +24 semitones. | |
| int | MPTK_TransExcludedChannel [get, set] |
| Transposition applies to all channels except this one. Set to -1 to apply to every channel. V2.89.0 Default is 9 because drums are generally on channel 9. | |
| bool | MPTK_Dsp64 [get, set] |
| Accept preset changes on Drum Channel 9 (percussion). Enabling this can produce unexpected results with MIDI files that are not standard-compliant. If disabled, preset changes on channel 9 are ignored (preset 0 remains in use). | |
| int | MPTK_ThreadMidiPriority [get, set] |
| The MIDI thread priority controls how often the thread is scheduled by the CPU. The default value is 0 (normal); you can increase it to 1 or 2 (higher) on weaker hardware for more stable MIDI reading. | |
| bool | MPTK_CorePlayer [get, set] |
| If true, the synth rate and buffer size are set automatically by Unity according to the hardware capability. - V2.89.0 - See Unity menu "Edit / Project Settings..." to choose between best latency and best performance. If false, you can set rate and buffer size manually, at the risk of degraded audio quality (experimental). | |
| int | MPTK_SynthRate [get, set] |
| Gets or sets the current synth rate (only if MPTK_EnableFreeSynthRate is true). | |
| int | MPTK_IndexSynthRate [get, set] |
| Gets or sets the synth output sample rate. -1: default, 0: 24000, 1: 36000, 2: 48000, 3: 60000, 4: 72000, 5: 84000, 6: 96000. It's better to stop playback before changing on the fly to avoid noise. | |
| int | MPTK_IndexSynthBuffSize [get, set] |
| Gets or sets synth buffer size: -1: default, 0: 64, 1: 128, 2: 256, 3: 512, 4: 1024, 5: 2048. The change is global for all prefabs. Stop playback on all prefabs before changing on the fly to avoid noise or crashes. | |
| int | MPTK_StatVoiceCountSustained [get] |
| Gets the number of active voices currently in the sustained state. | |
| bool | MPTK_Orientation [get, set] |
| Enables orientation-based audio behavior (Pro). | |
| bool | MPTK_DistanceAttenuation [get, set] |
| Enables Unity distance-based attenuation (min/max distance and custom rolloff curve). When enabled, MPTK configures the underlying AudioSource with: | |
| float | MPTK_MinDistance [get, set] |
| When MPTK_DistanceAttenuation is enabled, the volume of the audio source depends on the distance between the audio source and the listener. Distance at which attenuation begins. When the listener is closer than this value, the audio plays at full volume(1.0). | |
| float | MPTK_MaxDistance [get, set] |
| When MPTK_DistanceAttenuation is enabled, the volume of the audio source depends on the distance between the audio source and the listener. Distance at which attenuation reaches its minimum level. Beyond this distance, the volume remains constant and does not decrease further. | |
| float | MPTK_MinSoundAttenuation [get, set] |
| If MPTK_DistanceAttenuation is enabled, the volume of the audio source depends on the distance between the audio source and the listener. Minimum volume applied at Max Distance. | |
| OnAudioFrameStartHandler | OnAudioFrameStart |
| Raised at the start of each audio frame by the audio engine. . | |
Plays a local MIDI file or a MIDI file from a website. This class must be used with the MidiExternalPlayer prefab.
.
You do not need to write a script for simple usage; everything can be configured in the prefab inspector.
A set of methods is also available to control playback from scripts.
This class inherits from MidiFilePlayer and MidiSynth, so all properties, events, and methods from both classes are available.
More information here: https://paxstellar.fr/midi-external-player-v2/
Example for loading and playing a MIDI file from a website.
|
virtual |
Plays the MIDI file defined with MPTK_MidiName.
| alreadyLoaded | True if the MIDI has already been loaded (see MPTK_Load(), v2.9.0). |
Reimplemented from MidiPlayerTK.MidiFilePlayer.
|
getset |
Sets the full URI to a MIDI file: use file:// for a local file, or http:// / https:// for a web resource. The MIDI file is then loaded and played.
.
See https://en.wikipedia.org/wiki/File_URI_scheme for URI examples.