MidiPlayerTK.MidiPlayerGlobal

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

Inherits MonoBehaviour, and MonoBehaviour.

Static Public Member Functions

static float MPTK_DistanceToListener (Transform trf)
 Calculate distance with the AudioListener. More...
 
static int MPTK_FindMidi (string name)
 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. More...
 
static bool MPTK_IsReady (float delay=0.5f)
 Check if SoudFont is loaded. Add a default wait time because Unity AudioSource need a delay to be really ready to play. More...
 
static bool MPTK_LoadLiveSF (string pPathSF=null, int defaultBank=-1, int drumBank=-1, bool restartPlayer=true)
 [MPTK PRO] - 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 More...
 
static void MPTK_Quit ()
 Stop all Midi Synthesizer dans Midi Sequencer and exit application More...
 
static void MPTK_SelectBankDrum (int nbank)
 Change current bank on fly More...
 
static void MPTK_SelectBankInstrument (int nbank)
 Change default current bank on fly More...
 
static void MPTK_SelectSoundFont (string name, bool restartPlayer=true)
 [MPTK PRO] - Changing the current Soundfont on fly. If some Midis are playing they are restarted. More...
 
static void MPTK_Stop ()
 Stop all Midi Synthesizer dans Midi Sequencer More...
 

Public Attributes

string MPTK_LiveSoundFont
 [MPTK PRO] - Full path to SoundFont file (.sf2) or URL to load. Defined in the MidiPlayerGlobal editor inspector. Must start with file:// or http:// or https://. More...
 

Static Public Attributes

static int MPTK_CountWaveLoaded
 Count of wave loaded More...
 
static List< MPTKListItemMPTK_ListBank
 Get the list of banks available More...
 
static List< MPTKListItemMPTK_ListDrum
 Get the list of presets available More...
 
static List< MPTKListItemMPTK_ListMidi
 List of midi(s) available More...
 
static List< MPTKListItemMPTK_ListPreset
 List of presets (instrument) for the default or selected bank. The default bank can be changed with MPTK_SelectBankInstrument More...
 
static List< MPTKListItemMPTK_ListPresetDrum
 List of drum set for the default or selected bank. The default bank can be changed with MPTK_SelectBankDrum More...
 
static bool MPTK_SoundFontLoaded = false
 True if soundfont is loaded More...
 

Properties

static int MPTK_CountPresetLoaded [get]
 Count of preset loaded More...
 
static List< string > MPTK_ListSoundFont [get]
 List of Soundfont(s) available More...
 
static bool? MPTK_LoadSoundFontAtStartup [get, set]
 If true load soundfont when startup More...
 
static bool? MPTK_LoadWaveAtStartup [get, set]
 If true load all waves when application is started else load when need when playing (default) More...
 
static string MPTK_PathToResources [get]
 This path could change depending your project. Change the path before any actions in MPTK. DEPRECATED, WILL BE REMOVED. More...
 
static TimeSpan MPTK_TimeToLoadSoundFont [get]
 Load time for the current SoundFont More...
 
static TimeSpan MPTK_TimeToLoadWave [get]
 Load time for the wave More...
 
static UnityEvent? OnEventPresetLoaded [get, set]
 Event triggered at end of loading a soundfont. Warning: when defined by script, this event is not triggered at first load of MPTK because MidiPlayerGlobal is loaded before any other gamecomponent. Set this event in the Inspector of MidiPlayerGlobal to get at first load this information. More...
 

Detailed Description

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

Singleton class to manage all global features of MPTK.

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_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 really 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

[MPTK PRO] - 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

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 Synthesizer dans Midi Sequencer and exit application

◆ MPTK_SelectBankDrum()

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

Change current bank on fly

Parameters
nbankNumber of the SoundFont Bank to load for drum.

◆ MPTK_SelectBankInstrument()

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

Change default current bank on fly

Parameters
nbankNumber of the SoundFont Bank to load for instrument.

◆ MPTK_SelectSoundFont()

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

[MPTK PRO] - Changing the current Soundfont on fly. If some Midis are playing they are restarted.

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 Synthesizer dans Midi Sequencer

Member Data Documentation

◆ MPTK_CountWaveLoaded

int MidiPlayerTK.MidiPlayerGlobal.MPTK_CountWaveLoaded
static

Count of wave loaded

◆ MPTK_ListBank

List<MPTKListItem> MidiPlayerTK.MidiPlayerGlobal.MPTK_ListBank
static

Get the list of banks available

◆ MPTK_ListDrum

List<MPTKListItem> MidiPlayerTK.MidiPlayerGlobal.MPTK_ListDrum
static

Get the list of presets available

◆ MPTK_ListMidi

List<MPTKListItem> MidiPlayerTK.MidiPlayerGlobal.MPTK_ListMidi
static

List of midi(s) available

◆ 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

◆ 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

◆ MPTK_LiveSoundFont

string MidiPlayerTK.MidiPlayerGlobal.MPTK_LiveSoundFont

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

◆ 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

◆ 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)

◆ MPTK_PathToResources

string MidiPlayerTK.MidiPlayerGlobal.MPTK_PathToResources
staticget

This path could change depending your project. Change the path before any actions in MPTK. DEPRECATED, WILL BE REMOVED.

◆ MPTK_TimeToLoadSoundFont

TimeSpan MidiPlayerTK.MidiPlayerGlobal.MPTK_TimeToLoadSoundFont
staticget

Load time for the current SoundFont

◆ MPTK_TimeToLoadWave

TimeSpan MidiPlayerTK.MidiPlayerGlobal.MPTK_TimeToLoadWave
staticget

Load time for the wave

◆ OnEventPresetLoaded

UnityEvent? MidiPlayerTK.MidiPlayerGlobal.OnEventPresetLoaded
staticgetset

Event triggered at end of loading a soundfont. Warning: when defined by script, this event is not triggered at first load of MPTK because MidiPlayerGlobal is loaded before any other gamecomponent. Set this event in the Inspector of MidiPlayerGlobal to get at first load this information.