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.

Get MPTK from the Unity store

If you like Midi Player Tool Kit, please leave a review on the Asset Store. It’s very appreciated!!!

Maestro MPTK on ChatGPT!

From different MPTK documentation sources DarkSky42 has created a custom LLM based on ChatGPT. You are now able to ask all the questions you want and get a good level of response, request code example, verify your source code …

Contact

If you have questions, please don’t hesitate to contact us via the dedicated Unity forum or our Discord  channel.

Reach the Discord archive by topic.

We are always happy to discuss your projects!