RtMidi.Input.Device Class

 

About RtMidi.Input.Device Class

 

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

 

RtMidi.Input.Device Class Methods

 

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

 

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

uint DeviceIndex: zero-based index of the device.

 

RtMidi.Input.Device.AutoMessage( bool AutoMessage ) specifies if the open MIDI Input device should automatically send all received MIDI Messages to the open MIDI Output device.

bool AutoMessage: enable (true) or disable (false) the auto message feature for the open MIDI Input device.

 

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

 

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

 

RtMidi.Input.Device.Close() closes an open MIDI Input device (if exists).

 

Code Example

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

public class CodeExample : MonoBehaviour
{

void Awake()
{
RtMidi.Initialize();//Initializes RtMidi

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

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

RtMidi.Input.Device.Open(2);//Opens the third MIDI Input Device ("Oxygen 49" MIDI Keyboard in my case)
RtMidi.Output.Device.Open(0);//Opens the first MIDI Output Device ("Microsoft GS Wavetable Synth" by default on Windows)
RtMidi.Input.Device.AutoMessage(true);//Sends all received MIDI Input Messages to the MIDI Output Device ("Oxygen 49" >>> "Microsoft GS Wavetable Synth" in my case)

}

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

}

 

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.