MidiPlayerTK.MidiInReader

Read MIDI events from a MIDI keyboard connected to your Windows or Mac desktop. This class must be used with the prefab MidiInReader.
There is no need to writing a script. For a simple usage, all the job can be done in the prefab inspector. More information here https://paxstellar.fr/prefab-midiinreader/
More...

Inheritance diagram for MidiPlayerTK.MidiInReader:
MidiPlayerTK.MidiSynth

Public Attributes

bool MPTK_ReadMidiInput
 
EventMidiClass OnEventInputMidi
 
- Public Attributes inherited from MidiPlayerTK.MidiSynth
bool MPTK_ApplyModLfo
 
bool MPTK_ApplyRealTimeModulator
 
bool MPTK_ApplyVibLfo
 
bool MPTK_AudioSettingFromUnity
 
bool MPTK_AutoBuffer = true
 
int MPTK_AutoCleanVoiceLimit
 
bool MPTK_CorePlayer
 
float MPTK_CutOffVolume = 0.0001f
 
bool MPTK_DirectSendToPlayer
 
bool MPTK_EnableChangeTempo
 
bool MPTK_EnableFreeSynthRate = false
 
bool MPTK_EnablePanChange
 
bool MPTK_EnablePresetDrum
 
bool MPTK_KillByExclusiveClass = true
 
float MPTK_LeanSynthStarting = 0.05f
 
bool MPTK_LogEvents
 
bool MPTK_LogWave
 
bool MPTK_ReleaseSameNote = true
 
uint MPTK_ReleaseTimeMin = 500000
 
float MPTK_ReleaseTimeMod = 1f
 
bool MPTK_ResetChannel = true
 
float MPTK_SFChorusAmplify
 
float MPTK_SFFilterFreqOffset = 0f
 
float MPTK_SFReverbAmplify
 
bool MPTK_SpatialSynthEnabled
 
int MPTK_StatVoiceCountActive
 
int MPTK_StatVoiceCountFree
 
int MPTK_StatVoiceCountPlaying
 
int MPTK_StatVoicePlayed
 
float MPTK_StatVoiceRatioReused
 
bool MPTK_WeakDevice
 
Action< int, long, int, int > OnBeatEvent
 Action executed at each quarter with: More...
 
EventSynthClass OnEventSynthAwake
 
EventSynthClass OnEventSynthStarted
 
Func< MPTKEvent, bool > OnMidiEvent
 
bool playOnlyFirstWave
 

Additional Inherited Members

- Public Types inherited from MidiPlayerTK.MidiSynth
enum  ModeSpatializer { Channel , Track }
 
- Public Member Functions inherited from MidiPlayerTK.MidiSynth
int MPTK_ChannelBankGetIndex (int channel)
 
int MPTK_ChannelControllerGet (int channel, int controller)
 
int MPTK_ChannelCount ()
 
bool MPTK_ChannelEnableGet (int channel)
 
void MPTK_ChannelEnableSet (int channel, bool enable)
 
int MPTK_ChannelForcedPresetGet (int channel)
 
bool MPTK_ChannelForcedPresetSet (int channel, int preset, int bank=-1)
 
string MPTK_ChannelInfo (int channel)
 
int MPTK_ChannelNoteCount (int channel)
 
bool MPTK_ChannelPresetChange (int channel, int preset, int bank=-1)
 
int MPTK_ChannelPresetGetIndex (int channel)
 
string MPTK_ChannelPresetGetName (int channel)
 
float MPTK_ChannelVolumeGet (int channel)
 
void MPTK_ChannelVolumeSet (int channel, float volume)
 
void MPTK_ChorusSetDefault ()
 
void MPTK_ClearAllSound (bool destroyAudioSource=false, int _idSession=-1)
 
void MPTK_InitSynth (int channelCount=16, bool resetActiveVoices=false)
 
void MPTK_ResetStat ()
 
void MPTK_ReverbSetDefault ()
 
void MPTK_SFChorusSetDefault ()
 
void MPTK_SFFilterSetDefault ()
 
void MPTK_SFReverbSetDefault ()
 
void MPTK_StartSequencerMidi ()
 
void MPTK_StopSynth ()
 
IEnumerator MPTK_WaitAllNotesOff (int _idSession=-1)
 
delegate void OnAudioFrameStartHandler (double synthTime)
 
- Static Public Attributes inherited from MidiPlayerTK.MidiSynth
static List< MidiFilePlayerSpatialSynths
 
- Properties inherited from MidiPlayerTK.MidiSynth
bool MPTK_ApplySFChorus [get, set]
 Apply chorus effect as defined in the SoundFont.
This effect is processed with the fluidsynth algo independently on each voices but with a small decrease of performace(10%). More...
 
bool MPTK_ApplySFFilter [get, set]
 
bool MPTK_ApplySFReverb [get, set]
 Apply reverberation effect as defined in the SoundFont.
This effect is processed with the fluidsynth algo independently on each voices but with a small decrease of performace(40%). More...
 
bool MPTK_ApplyUnityChorus [get, set]
 
bool MPTK_ApplyUnityReverb [get, set]
 
float MPTK_ChorusDelay [get, set]
 
float MPTK_ChorusDepth [get, set]
 
float MPTK_ChorusDryMix [get, set]
 
float MPTK_ChorusRate [get, set]
 
float MPTK_ChorusWetMix1 [get, set]
 
float MPTK_ChorusWetMix2 [get, set]
 
float MPTK_ChorusWetMix3 [get, set]
 
int MPTK_IndexSynthBuffSize [get, set]
 
int MPTK_IndexSynthRate [get, set]
 
string MPTK_InstrumentPlayed [get]
 
bool MPTK_IsSpatialSynthMaster [get]
 
bool MPTK_KeepPlayingNonLooped [get, set]
 
float MPTK_MaxDistance [get, set]
 
bool MPTK_PauseOnDistance [get, set]
 
float MPTK_ReverbDecayHFRatio [get, set]
 
float MPTK_ReverbDecayTime [get, set]
 
float MPTK_ReverbDelay [get, set]
 
float MPTK_ReverbDensity [get, set]
 
float MPTK_ReverbDiffusion [get, set]
 
float MPTK_ReverbDryLevel [get, set]
 
float MPTK_ReverbHFReference [get, set]
 
float MPTK_ReverbLevel [get, set]
 
float MPTK_ReverbLFReference [get, set]
 
float MPTK_ReverbReflectionDelay [get, set]
 
float MPTK_ReverbReflectionLevel [get, set]
 
float MPTK_ReverbRoom [get, set]
 
float MPTK_ReverbRoomHF [get, set]
 
float MPTK_ReverbRoomLF [get, set]
 
float MPTK_SFChorusDepth [get, set]
 
float MPTK_SFChorusLevel [get, set]
 
float MPTK_SFChorusSpeed [get, set]
 
float MPTK_SFChorusWidth [get, set]
 
float MPTK_SFFilterQModOffset [get, set]
 
float MPTK_SFReverbDamp [get, set]
 
float MPTK_SFReverbLevel [get, set]
 
float MPTK_SFReverbRoomSize [get, set]
 
float MPTK_SFReverbWidth [get, set]
 
bool MPTK_Spatialize [get, set]
 
int MPTK_SpatialSynthIndex [get]
 
int MPTK_SynthRate [get, set]
 
string MPTK_TrackName [get]
 
int MPTK_TransExcludedChannel [get, set]
 
int MPTK_Transpose [get, set]
 
float MPTK_Volume [get, set]
 
- Events inherited from MidiPlayerTK.MidiSynth
OnAudioFrameStartHandler OnAudioFrameStart
 

Detailed Description

Read MIDI events from a MIDI keyboard connected to your Windows or Mac desktop. This class must be used with the prefab MidiInReader.
There is no need to writing a script. For a simple usage, all the job can be done in the prefab inspector. More information here https://paxstellar.fr/prefab-midiinreader/

Attention
MidiInReader inherits of class MidiSynth. For clarity, only MidiInReader attibutes are provided here. Look at the class MidiSynth to discover all attributes available.
Version
Maestro Pro

Example of script. See TestMidiInputScripting.cs for a more detailed usage.
Display each MIDI events from a MIDI device connected Need for a reference to the Prefab (can also be set from the hierarchy)

MidiInReader midiIn = FindObjectOfType<MidiInReader>();
if (midiIn == null)
Debug.LogWarning("Can't find a MidiInReader Prefab in the current Scene Hierarchy. Add it with the MPTK menu.");
// There is two methods to trigger event: in inpector from the Unity editor or by script
midiIn.OnEventInputMidi.AddListener((MPTKEvent evt) =>
{
// your processing here
Debug.Log(evt.ToString());
});
Description of a MIDI Event. It's the heart of MPTK! Essential to handling MIDI by script from all ot...
Definition: MPTKEvent.cs:418
override string ToString()
Extract value 2 from a double int build with BuildIntFromBytes
Definition: MPTKEvent.cs:819
Read MIDI events from a MIDI keyboard connected to your Windows or Mac desktop. This class must be us...
Definition: MidiInReader.cs:35
EventMidiClass OnEventInputMidi
Definition: MidiInReader.cs:109

Member Data Documentation

◆ MPTK_ReadMidiInput

bool MidiPlayerTK.MidiInReader.MPTK_ReadMidiInput

Read Midi input

◆ OnEventInputMidi

EventMidiClass MidiPlayerTK.MidiInReader.OnEventInputMidi

Define unity event to trigger when note available from the Midi file.

MidiInReader midiFilePlayer = FindObjectOfType<MidiInReader>();
...
if (!midiFilePlayer.OnEventInputMidi.HasEvent())
{
// No listener defined, set now by script. NotesToPlay will be called for each new notes read from Midi file
midiFilePlayer.OnEventInputMidi.AddListener(NotesToPlay);
}
...
public void NotesToPlay(MPTKEvent notes)
{
Debug.Log(notes.Value);
foreach (MPTKEvent midievent in notes)
{
...
}
}
int Value
Definition: MPTKEvent.cs:530