Mci.Error Class

 

About Mci.Error Class

 

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

 

Mci.Error Class Methods

 

Mci.Error.ManualChecking( bool ManualChecking ) specifies if Giavapps MIDI should store data about detected errors in order that you can then check that data through Mci.Error.* functions. By default this feature is disabled. When this feature is enabled you must always loop through all received data by calling Mci.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 Mci.Error.* functions.

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

 

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

 

Mci.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
{

private string FileName = "mymidi.mid";

void Awake()
{
Mci.Initialize();//Initializes Mci
Mci.Error.ManualChecking(true);//Enables manual checking of error messages
Mci.Sequencer.Open(FileName);//Opens the specified MIDI file into the MCI MIDI Sequencer for playback
}

void Update()
{

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

//Checks if space key is pressed
if(Input.GetKeyDown(KeyCode.Space))
{
Mci.Command("open \""+FileName+"\" type sequencer alias "+Mci.Alias+"1");//Ops! This causes an error!
}

}

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

}

 

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.