Updated Unity MIDI control

More information and the project code can be found on Github or BitBucket.

UPDATED: This plugin now uses keijiro’s MIDI Jack as a backend, removing the need to run the third-party software MIDI Bridge required by the previous version.

This Unity interface allows you to map MIDI inputs to keyboard buttons - play the mapped input on your instrument to trigger the corresponding key press. The interface currently supports GetKey, GetKeyDown and GetKeyUp events for all keyboard buttons. Direct button presses (i.e., using the keyboard rather than a mapped instrument) will still be detected.

Example Use

The following note mappings trigger:

Example key mappings

These keypresses may be detected programmatically using the following code:

if (UnityMidiControl.Input.InputManager.GetKeyDown("x")) {
	Debug.Log("'x' down");
}
if (UnityMidiControl.Input.InputManager.GetKeyDown("d")) {
	Debug.Log("'d' down");
}
if (UnityMidiControl.Input.InputManager.GetKeyDown("a")) {
	Debug.Log("'a' down");
}
if (UnityMidiControl.Input.InputManager.GetKeyDown("b")) {
	Debug.Log("'b' down");
}

Using key codes rather than string arguments will also work:

if (UnityMidiControl.Input.InputManager.GetKeyUp(KeyCode.X)) {
	Debug.Log("'x' up");
}
if (UnityMidiControl.Input.InputManager.GetKeyUp(KeyCode.D)) {
	Debug.Log("'d' up");
}
if (UnityMidiControl.Input.InputManager.GetKeyUp(KeyCode.A)) {
	Debug.Log("'a' up");
}
if (UnityMidiControl.Input.InputManager.GetKeyDown(Keycode.B)) {
	Debug.Log("'b' down");
}