RtMidi.Error Class


About RtMidi.Error Class


RtMidi.Error class is mainly used for retrieving error messages from RtMidi functions.


RtMidi.Error Class Methods


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

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


RtMidi.Error.Count() returns the amount of detected errors. Use the other RtMidi.Error.* functions to get info about the messages. When you call this function Giavapps MIDI will free data stored for errors (see RtMidi.Error.ManualChecking() function for more info).


RtMidi.Error.String( ulong ErrorIndex ) returns the specified error string.

ulong ErrorIndex: zero-based index of the error.


Code Example

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

public class CodeExample : MonoBehaviour

void Awake()
RtMidi.Initialize();//Initializes RtMidi
RtMidi.Error.ManualChecking(true);//Enables manual checking of error messages
RtMidi.Input.Device.Open(2);//Opens the third MIDI Input Device ("Oxygen 49" MIDI Keyboard in my case)

void Update()

//Check for error messages
errors = RtMidi.Error.Count();
for(ulong e = 0; e < errors; e++)
Debug.Log(RtMidi.Error.String(e));//Prints an error message

//Checks if space key is pressed
RtMidi.Input.Device.Open(2);//Ops! This causes an error!


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.