MusIT

Set MIDI Player properties


When Maestro MPTK load a MIDI from the MIDI db or from an external file (web or local), all the setting of the MIDI player (prefab MidiFilePlayer or MidiExternalPlay) are set to the default values found in the MIDI.

This code will not works:

It’s the same for properties like MPTK_InnerLoop. This code will works but with MIDI from your DB because the Load and Start MIDI are split.

Another solution will works with MIDI from the DB (MidiFilePlayer prefab) and MIDI from a web site (MidiExternalPlay prefab). Here an example with an external MIDI:

private void Start()
{
midiExternalPlayer = FindFirstObjectByType<MidiExternalPlayer>();
// Event triggered when MIDI starts playing
midiExternalPlayer.OnEventStartPlayMidi.AddListener(StartPlay);
midiExternalPlayer.MPTK_Play();
}
public void StartPlay(string midiName)
{
// Disable MIDI channel 9

midiExternalPlayer .MPTK_ChannelEnableSet(9, false);
}

Obviously, changing these properties dynamically when the MIDI is playing is always possible.

Have any Question or Comment?

Leave a Reply

Your email address will not be published. Required fields are marked *

I accept that my given data and my IP address is sent to a server in the USA only for the purpose of spam prevention through the Akismet program.More information on Akismet and GDPR.