Midi.Input.Device Class

 

About Midi.Input.Device Class

 

Midi.Input.Device class is mainly used for retrieving information about MIDI Input devices and for opening and closing MIDI Input devices.

 

Midi.Input.Device Class Methods

 

Midi.Input.Device.Count() returns the amount of connected MIDI Input devices. This function detects connected MIDI Input devices.

 

Midi.Input.Device.Name( uint DeviceIndex ) returns a string identifier for the specified MIDI Input device.

uint DeviceIndex: zero-based index of the device.

 

Midi.Input.Device.Open( uint DeviceIndex ) opens the specified MIDI Input device. Only open devices can receive messages.

uint DeviceIndex: zero-based index of the device.

 

Midi.Input.Device.OpenAll( ) opens all MIDI Input devices. Only open devices can receive messages.

 

Midi.Input.Device.IsOpen( uint DeviceIndex ) returns true if a MIDI Input device is open and false if not.

uint DeviceIndex: zero-based index of the device.

 

Midi.Input.Device.OpenCount( ) returns the amount of open MIDI Input devices.

 

Midi.Input.Device.Close( uint DeviceIndex ) closes the specified MIDI Input device. Note that when you call Midi.Deinitialize() function or when you unplug the device it will be closed automatically by Giavapps MIDI extension.

uint DeviceIndex: zero-based index of the device.

 

Midi.Input.Device.CloseAll() closes all open MIDI Input devices. Note that when you call Midi.Deinitialize() function or when you unplug the device it will be closed automatically by Giavapps MIDI extension.

 

Midi.Input.Device.Connect( uint InputDeviceIndex, uint OutputDeviceIndex ) connects the given MIDI Input device with the specified MIDI Output device. The MIDI Input device will send all received MIDI Messages to MIDI Output device automatically.

uint InputDeviceIndex: zero-based index of the device.
uint OutputDeviceIndex: zero-based index of the device.

 

Midi.Input.Device.Disconnect( uint InputDeviceIndex, uint OutputDeviceIndex ) disconnects the given MIDI Input device from the specified MIDI Output device. Note that when you call Midi.Deinitialize() function or when you unplug the device or when you close the device it will be disconnected automatically by Giavapps MIDI extension.

uint InputDeviceIndex: zero-based index of the device.
uint OutputDeviceIndex: zero-based index of the device.

 

Midi.Input.Device.ConnectionCount( uint DeviceIndex ) returns the amount of connections set for the specified MIDI Input device.

uint DeviceIndex: zero-based index of the device.

 

Midi.Input.Device.ConnectionExists( uint InputDeviceIndex, uint OutputDeviceIndex ) returns true if the given MIDI Input device is connected with the specified MIDI Output device or false otherwise.

uint InputDeviceIndex: zero-based index of the device.
uint OutputDeviceIndex: zero-based index of the device.

 

Code Example

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

public class CodeExample : MonoBehaviour
{

void Awake()
{

//Prints all available MIDI Input devices
Debug.Log("MIDI INPUT DEVICES:");
uint i;
for(i=0; i < Midi.Input.Device.Count(); i++)
{
Debug.Log(Midi.Input.Device.Name(i));
}

//Prints all available MIDI Output devices
Debug.Log("MIDI OUTPUT DEVICES:");
for(i=0; i < Midi.Output.Device.Count(); i++)
{
Debug.Log(Midi.Output.Device.Name(i));
}

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)

}

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.