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
 
int MPTK_InstrumentNum
 
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_SpatialSynthEnabled
 
int MPTK_StatVoiceCountActive
 
int MPTK_StatVoiceCountFree
 
int MPTK_StatVoiceCountPlaying
 
int MPTK_StatVoiceCountReused
 
int MPTK_StatVoicePlayed
 
int 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
void MPTK_ClearAllSound (bool destroyAudioSource=false, int _idSession=-1)
 
void MPTK_InitSynth (int channelCount=16, bool preserveChannelInfo=false)
 
void MPTK_ResetStat ()
 
void MPTK_StartSequencerMidi ()
 
void MPTK_StartSynth ()
 
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
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]
 
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:45
override string ToString()
Extract value 2 from a double int build with BuildIntFromBytes
Definition: MPTKEvent.cs:437
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:114

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:154