Midi.Input.Message Class

 

About Midi.Input.Message Class

 

Midi.Input.Message class is mainly used for receiving MIDI Messages from MIDI Input devices.

 

Midi.Input.Message Class Methods

 

Midi.Input.Message.ManualChecking( bool ManualChecking ) specifies if Giavapps MIDI should store data about detected MIDI Messages in order that you can then check that data through Midi.Input.Message.* functions. By default this feature is disabled. When this feature is enabled you must always loop through all received data by calling Midi.Input.Message.Count() (usually inside Update() or Coroutine methods). If a MIDI device continues sending MIDI Messages and you are not processing them you may cause a memory leak. (See Code Examples below for more info about how to manual check MIDI Messages correctly). When this feature is disabled, Giavapps MIDI will stop storing data for MIDI Messages. You can leave disabled this feature if you are not going to use any of the Midi.Input.Message.* functions.

bool ManualChecking: enable (true) or disable (false) manual check.

 

Midi.Input.Message.Count( uint DeviceIndex ) returns the amount of messages from the specified MIDI Input device. Use the other Midi.Input.Message.* functions to get info about the messages. When you call this function Giavapps MIDI will free data stored for MIDI Messages (see Midi.Input.Message.ManualChecking() function for more info).

uint DeviceIndex: zero-based index of the device.

 

Midi.Input.Message.Size( uint DeviceIndex, ulong MessageIndex ) returns the amout of bytes of the specified MIDI Message.

uint DeviceIndex: zero-based index of the device.
ulong
MessageIndex: zero-based index of the MIDI Message.

 

Midi.Input.Message.Byte( uint DeviceIndex, ulong MessageIndex, ulong ByteIndex) Returns the specified byte (0-255) from the given MIDI Message.

uint DeviceIndex: zero-based index of the device.
ulong
MessageIndex: zero-based index of the MIDI Message.
ulong ByteIndex: zero-based index of the byte.

 

Midi.Input.Message.Time( uint DeviceIndex, ulong MessageIndex ) returns the amount of time (milliseconds) passed since the MIDI Input device was open.

uint DeviceIndex: zero-based index of the device.
ulong
MessageIndex: zero-based index of the MIDI Message.

 

Code Example

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Giavapps.MIDI;

public class CodeExample : MonoBehaviour
{

void Awake()
{
Midi.Input.Device.Open(2);//Opens the third MIDI Input Device ("Oxygen 49" MIDI Keyboard in my case)
Midi.Output.Device.Open(0);//Opens the first MIDI Output Device ("Microsoft GS Wavetable Synth" by default on Windows)
Midi.Input.Device.Connect(2, 0);//Sends all received MIDI Input Messages to the MIDI Output Device ("Oxygen 49" >>> "Microsoft GS Wavetable Synth" in my case)
Midi.Input.Message.ManualChecking(true);//Enables manual checking of MIDI Messages
}

void Update()
{

//Prints all received MIDI Messages
for
(uint d=0; d < Midi.Input.Device.Count(); d++)
{

ulong messages = Midi.Input.Message.Count(d);

for(ulong m = 0; m < messages; m++)
{
ulong time = Midi.Input.Message.Time(d, m);
ulong size = Midi.Input.Message.Size(d, m);
string bytes = “”;

for(ulong b = 0; b < size; b++)
{
bytes += Midi.Input.Message.Byte(d, m, b).ToString()+” “;
}


Debug
.Log(“MIDI MESSAGE – TIME: “+time.ToString()+” – “+size.ToString()+” bytes – “+bytes);
}

}

}

void OnApplicationQuit()
{
Midi.Deinitialize();//Deinitializes Midi
}

}

 

I am Luigi Piscopo, also known as DJ GiDeejay / Producer / Remixer in the music world. I am a Producer with a lot of experience in photo editing, video editing, audio editing, graphic design, web design, programming and promotion.

Comments are closed.