Maestro - Midi Player Tool Kit for Unity Version 2.18.2
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 processing samples by the synth and the MIDI sequencer. Useful only after calling MPTK_StopSynth when using MidiStreamPlayer.
void MidiPlayerTK.MidiSynth.MPTK_ClearAllSound (bool destroyAudioSource=false, int _idSession=-1)
 Clears all sound by sending NoteOff messages. This can take a few seconds because sample release times must play out.
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 processing samples by the synth and the MIDI sequencer. See also MPTK_StartSynth.

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 processing samples by the synth and the MIDI sequencer. Useful only after calling MPTK_StopSynth when using MidiStreamPlayer.

Version
2.11.2

◆ MPTK_ClearAllSound()

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

Clears all sound by sending NoteOff messages. This can take a few seconds because sample release times must play out.

Parameters
destroyAudioSourceUseful only in non-core mode.
_idSessionClear only samples playing in this session; -1 clears all (default).

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

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.