Maestro - Midi Player Tool Kit for Unity Version 2.22.0
Loading...
Searching...
No Matches
Runtime Control and Performance

Runtime tuning, threading, buffering, and audio-side controls. More...

Classes

class  MidiPlayerTK.MidiSynth
 Core sample-based SoundFont synthesizer (base class). More...

Synthesizer Initialization And Life Cycle

Initialization and lifecycle of the MIDI synthesizer.

This section contains methods and parameters related to the creation and initialization of the MIDI synthesizer. These functions configure the audio engine, load SoundFonts, and prepare the synth for playback.

In most cases initialization is handled automatically by the prefab, but advanced users may control it directly from scripts.

float MidiPlayerTK.MidiSynth.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.
void MidiPlayerTK.MidiSynth.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 MidiPlayerTK.MidiSynth.MPTK_StartSynth ()
 Starts the audio synthesis engine and resumes sample processing.
void MidiPlayerTK.MidiSynth.MPTK_ClearAllSound (bool destroyAudioSource=false, int _idSession=-1)
 Clears all sound by sending NoteOff messages.
void MidiPlayerTK.MidiSynth.MPTK_InitSynth (int channelCount=16, bool preserveChannelInfo=false, bool preserveActivVoice=true)
 Initializes the synthesizer:
void MidiPlayerTK.MidiSynth.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 MidiPlayerTK.MidiSynth.MPTK_StopSynth ()
 Stops the audio synthesis engine.

Detailed Description

Runtime tuning, threading, buffering, and audio-side controls.

Function Documentation

◆ MPTK_InitModulators()

void MidiPlayerTK.MidiSynth.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.

This method configures modulation sources and destinations so that MIDI events such as velocity, controller changes, channel pressure, and pitch wheel movements influence sound characteristics including attenuation, filter cutoff, vibrato depth, pan position, reverb, chorus, and pitch. It ensures that the synthesizer responds to MIDI input in a manner consistent with SoundFont standards, enabling expressive and dynamic sound generation. Call this method before processing MIDI events to guarantee correct modulator setup.

◆ MPTK_StartSynth()

void MidiPlayerTK.MidiSynth.MPTK_StartSynth ( )

Starts the audio synthesis engine and resumes sample processing.

This method is intended for synth lifecycle management. It is normally required only after MPTK_StopSynth has been called, especially when using MidiStreamPlayer.

Do not call this method to start or resume MIDI playback. Playback control is handled by the corresponding player API.

Version
2.11.2

◆ MPTK_ClearAllSound()

void MidiPlayerTK.MidiSynth.MPTK_ClearAllSound ( bool destroyAudioSource = false,
int _idSession = -1 )

Clears all sound by sending NoteOff messages.

Deprecated
with 2.22.0 MPTK_ClearAllSound is deprecated. Please investigate MPTK_StopAllNotes
Parameters
destroyAudioSourceIgnored by this deprecated method. See remarks.
_idSessionIgnored by this deprecated method. See remarks.

Both parameters are ignored: this method always requests voice destruction for all sessions. This historical behavior is preserved for backward compatibility. Use MPTK_StopAllNotes instead; version 2.22.0 fixes the parameter forwarding in that method by passing both arguments to ThreadClearAllSound.

◆ MPTK_InitSynth()

void MidiPlayerTK.MidiSynth.MPTK_InitSynth ( int channelCount = 16,
bool preserveChannelInfo = false,
bool preserveActivVoice = true )

Initializes the synthesizer:

  • channel information (instrument and bank selection, pitch, volume, ...)
  • voice cache
  • synth modulators. This method is called by MidiFilePlayer during MPTK_Play(). In some cases you may need to call MPTK_InitSynth to restore the synth's initial state (mainly with MidiStreamPlayer).
Parameters
channelCountNumber of channels to create. Default is 16. Other values are experimental.
preserveChannelInfoIf true, channel information is not reset. Default is false, which reinitializes channel information.

◆ MPTK_StartSequencerMidi()

void MidiPlayerTK.MidiSynth.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.

Note
Available only when MPTK_CorePlayer is true. No effect in Legacy mode.

◆ MPTK_StopSynth()

void MidiPlayerTK.MidiSynth.MPTK_StopSynth ( )

Stops the audio synthesis engine.

This method is intended for synth lifecycle management. Do not use it to stop currently playing MIDI notes, pause playback, or reset a MidiStreamPlayer.

To immediately silence active notes while keeping the synthesizer available for subsequent events, use MPTK_ClearAllSound().

Variable Documentation

◆ MPTK_LeanSynthStarting

float MidiPlayerTK.MidiSynth.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.

Set this property to 1 for immediate full volume at startup. Valid values range from 0.001 to 1. Using a lower value can help avoid unexpected audio artifacts during initialization.