MidiPlayerTK.MidiPlayerGlobal

Singleton class to manage all globales MPTK features. More information here: https://paxstellar.fr/midiplayerglobal/ More...

Inherits MonoBehaviour, and MonoBehaviour.

Static Public Member Functions

static float MPTK_DistanceToListener (Transform trf)
 
static int MPTK_FindMidi (string name)
 
static string MPTK_GetPatchName (int bank, int patch)
 
static bool MPTK_IsReady (float delay=0.5f)
 
static bool MPTK_LoadLiveSF (string pPathSF=null, int defaultBank=-1, int drumBank=-1, bool restartPlayer=true)
 
static void MPTK_Quit ()
 
static bool MPTK_SelectBankDrum (int nbank)
 
static bool MPTK_SelectBankInstrument (int nbank)
 
static void MPTK_SelectSoundFont (string name, bool restartPlayer=true)
 
static void MPTK_Stop ()
 

Public Attributes

string MPTK_LiveSoundFont
 

Static Public Attributes

static int MPTK_CountWaveLoaded
 
static List< MPTKListItemMPTK_ListBank
 
static List< MPTKListItemMPTK_ListMidi
 
static List< MPTKListItemMPTK_ListPreset
 
static List< MPTKListItemMPTK_ListPresetDrum
 
static bool MPTK_SoundFontLoaded = false
 

Properties

static int MPTK_CountPresetLoaded [get]
 
static List< string > MPTK_ListSoundFont [get]
 
static bool MPTK_LoadSoundFontAtStartup [get, set]
 
static bool MPTK_LoadWaveAtStartup [get, set]
 
static string MPTK_PathToResources [get]
 
static bool MPTK_SoundFontIsReady [get]
 Is a SoundFont is selected and contains sound preset
 
static TimeSpan MPTK_TimeToLoadSoundFont [get]
 
static TimeSpan MPTK_TimeToLoadWave [get]
 
static UnityEvent OnEventPresetLoaded [get, set]
 

Detailed Description

Singleton class to manage all globales MPTK features. More information here: https://paxstellar.fr/midiplayerglobal/

Member Function Documentation

◆ MPTK_DistanceToListener()

static float MidiPlayerTK.MidiPlayerGlobal.MPTK_DistanceToListener ( Transform  trf)
static

Calculate distance with the AudioListener.

Parameters
trfTransform of the object to calculate the distance.
Returns

◆ MPTK_FindMidi()

static int MidiPlayerTK.MidiPlayerGlobal.MPTK_FindMidi ( string  name)
static

Find index of a Midi by name. 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.

Parameters
namename of the midi without path nor extension
Returns
-1 if not found else return the index of the midi.

◆ MPTK_GetPatchName()

static string MidiPlayerTK.MidiPlayerGlobal.MPTK_GetPatchName ( int  bank,
int  patch 
)
static

Return the nape of the preset (patch) from a bank and patch number.

Parameters
bank
patch
Returns
Name of the preset or empty if not found.

◆ MPTK_IsReady()

static bool MidiPlayerTK.MidiPlayerGlobal.MPTK_IsReady ( float  delay = 0.5f)
static

Check if SoudFont is loaded. Add a default wait time because Unity AudioSource need a delay to be ready to play.

Parameters
delayAdditional waiting time (second), default is 0.5 second. Could be equal to 0.
Returns

◆ MPTK_LoadLiveSF()

static bool MidiPlayerTK.MidiPlayerGlobal.MPTK_LoadLiveSF ( string  pPathSF = null,
int  defaultBank = -1,
int  drumBank = -1,
bool  restartPlayer = true 
)
static

Load a SoundFont on the fly when application is running. SoundFont is loaded from a local file or from the web. If some Midis are playing they are restarted. Loading is done in background (coroutine), so method return immediately

Version
Maestro Pro
Parameters
pPathSFFull path to SoudFont file. Must start with file:// for local desktop loading or with or http:// or https:// for loading from web resource. if null, use MPTK_LiveSoundFont
defaultBankdefault bank to use for instrument, default or -1 to select the first bank
drumBankbank to use for drum kit, default or -1 to select the last bank
restartPlayerRestart midi player if need, default is true
Returns
true if loading is in progress, false if an error is detected in parameters

◆ MPTK_Quit()

static void MidiPlayerTK.MidiPlayerGlobal.MPTK_Quit ( )
static

Stop all MIDI Synthesizers and exit application

◆ MPTK_SelectBankDrum()

static bool MidiPlayerTK.MidiPlayerGlobal.MPTK_SelectBankDrum ( int  nbank)
static

The default instrument and drum banks are defined with the popup "SoundFont Setup Alt-F" in the Unity editor.
This method change the default instrument drum bank and build presets available for it. See MPTK_ListPreset.
Note 1: this call doesn't change the current MIDI bank used to play an instrument, only the content of MPTK_ListPreset.
Note 2: to apply the bank to all channels, the synth must be restarted: call MidiFilePlayer.MPTK_InitSynth.
Note 3: to change the current bank, rather use MidiFilePlayer.MPTK_ChannelPresetChange

Parameters
nbankNumber of the SoundFont Bank to load for drum.
Returns
true if bank has been found else false.

◆ MPTK_SelectBankInstrument()

static bool MidiPlayerTK.MidiPlayerGlobal.MPTK_SelectBankInstrument ( int  nbank)
static

The default instrument and drum banks are defined with the popup "SoundFont Setup Alt-F" in the Unity editor.
This method change the default instrument drum bank and build presets available for it. See MPTK_ListPreset.
Note 1: this call doesn't change the current MIDI bank used to play an instrument, only the content of MPTK_ListPreset.
Note 2: to apply the bank to all channels, the synth must be restarted: call MidiFilePlayer.MPTK_InitSynth.
Note 3: to change the current bank, rather use MidiFilePlayer.MPTK_ChannelPresetChange

Parameters
nbankNumber of the SoundFont Bank to load for instrument.
Returns
true if bank has been found else false.

◆ MPTK_SelectSoundFont()

static void MidiPlayerTK.MidiPlayerGlobal.MPTK_SelectSoundFont ( string  name,
bool  restartPlayer = true 
)
static

Change the current Soundfont on fly. If MidiFilePlayer are running, they are stopped and optionally restarted.

Version
Maestro Pro
Parameters
nameSoundFont name
restartPlayerif a MIDI is playing, restart the current playing midi

◆ MPTK_Stop()

static void MidiPlayerTK.MidiPlayerGlobal.MPTK_Stop ( )
static

Stop all MIDI Synthesizers.

Member Data Documentation

◆ MPTK_CountWaveLoaded

int MidiPlayerTK.MidiPlayerGlobal.MPTK_CountWaveLoaded
static

Number of samples loaded

◆ MPTK_ListBank

List<MPTKListItem> MidiPlayerTK.MidiPlayerGlobal.MPTK_ListBank
static

Get the list of banks available.
The default bank can be changed with MPTK_SelectBankInstrument or MPTK_SelectBankDrum or with the menu "MPTK / SoundFont" or Alt-F in the Unity editor.

◆ MPTK_ListMidi

List<MPTKListItem> MidiPlayerTK.MidiPlayerGlobal.MPTK_ListMidi
static

List of MIDI files available. Add or remove MIDI from the Unity editor menu "MPTK / Midi File Setup" or Alt-M

◆ MPTK_ListPreset

List<MPTKListItem> MidiPlayerTK.MidiPlayerGlobal.MPTK_ListPreset
static

List of presets (instrument) for the default or selected bank.
The default bank can be changed with MPTK_SelectBankInstrument or with the popup "SoundFont Setup Alt-F" in the Unity editor.

◆ MPTK_ListPresetDrum

List<MPTKListItem> MidiPlayerTK.MidiPlayerGlobal.MPTK_ListPresetDrum
static

List of drum set for the default or selected bank.
The default bank can be changed with MPTK_SelectBankDrum or with the menu "MPTK / SoundFont" or Alt-F in the Unity editor.

◆ MPTK_LiveSoundFont

string MidiPlayerTK.MidiPlayerGlobal.MPTK_LiveSoundFont

Full path to SoundFont file (.sf2) or URL to load. Defined in the MidiPlayerGlobal editor inspector. Must start with file:// or http:// or https://.

Version
Maestro Pro

◆ MPTK_SoundFontLoaded

bool MidiPlayerTK.MidiPlayerGlobal.MPTK_SoundFontLoaded = false
static

True if soundfont is loaded

Property Documentation

◆ MPTK_CountPresetLoaded

int MidiPlayerTK.MidiPlayerGlobal.MPTK_CountPresetLoaded
staticget

Count of preset loaded

◆ MPTK_ListSoundFont

List<string> MidiPlayerTK.MidiPlayerGlobal.MPTK_ListSoundFont
staticget

List of Soundfont(s) available. With the MPTK PRO, add or remove SoundFonts from the Unity editor menu "MPTK / SoundFont Setup" or Alt-F

◆ MPTK_LoadSoundFontAtStartup

bool MidiPlayerTK.MidiPlayerGlobal.MPTK_LoadSoundFontAtStartup
staticgetset

If true load soundfont when startup

◆ MPTK_LoadWaveAtStartup

bool MidiPlayerTK.MidiPlayerGlobal.MPTK_LoadWaveAtStartup
staticgetset

If true load all waves when application is started else load when need when playing (default) Useless?

◆ MPTK_PathToResources

string MidiPlayerTK.MidiPlayerGlobal.MPTK_PathToResources
staticget

This path could change depending your project. Change the path before any actions in MPTK.

◆ MPTK_TimeToLoadSoundFont

TimeSpan MidiPlayerTK.MidiPlayerGlobal.MPTK_TimeToLoadSoundFont
staticget

Loading time for the current SoundFont

◆ MPTK_TimeToLoadWave

TimeSpan MidiPlayerTK.MidiPlayerGlobal.MPTK_TimeToLoadWave
staticget

Loading time for the samples

◆ OnEventPresetLoaded

UnityEvent MidiPlayerTK.MidiPlayerGlobal.OnEventPresetLoaded
staticgetset

Event triggered at the end of the loading of the soundfont.
Setting this callback function by script (AddListener) is not recommended. It's better to set callback function from the inspector. See here:https://mptkapi.paxstellar.com/d7/dc4/class_midi_player_t_k_1_1_midi_player_global.html::a64995b20027b35286c143f9f25a1cb6d