content top

Midi.Error Class

Midi.Error Class

  About Midi.Error Class   Midi.Error class is mainly used for retrieving error messages from Midi functions.   Midi.Error Class Methods   Midi.Error.ManualChecking( bool ManualChecking ) specifies if Giavapps MIDI should store data about detected errors in order that you can then check that data through Midi.Error.* functions. By default this feature is disabled. When this feature is enabled you must always loop through all received data by calling Midi.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 Midi.Error.* functions. bool ManualChecking: enable (true) or disable (false) manual check.   Midi.Error.Count() returns the amount of detected errors. Use the other Midi.Error.* functions to get info about the messages. When you call this function Giavapps MIDI will free data stored for errors (see Midi.Error.ManualChecking() function for more info).   Midi.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() { Midi.Error.ManualChecking(true);//Enables manual checking of error messages Midi.Input.Device.Open(2);//Opens the third MIDI Input Device ("Oxygen 49" MIDI Keyboard in my case) } void Update() { //Check for error messages ulong errors = Midi.Error.Count(); for(ulong e = 0; e < errors; e++) { Debug.Log(Midi.Error.String(e));//Prints an error message } //Checks if space key is pressed if(Input.GetKeyDown(KeyCode.Space)) { Midi.Input.Device.Open(2);//Ops! This causes an error! } } 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...

Read More

Midi.Output.Message Class

Midi.Output.Message Class

  About Midi.Output.Message Class   Midi.Output.Message class is mainly used for sending MIDI Messages to MIDI Output devices.   Midi.Output.Message Class Methods   Midi.Output.Message.Clear() clears the MIDI Message Buffer. This function removes all bytes previously stored in the MIDI Message Buffer.   Midi.Output.Message.Size() returns the amount of bytes stored in the MIDI Message Buffer.   Midi.Output.Message.Byte( byte Byte ) Adds one byte to the MIDI Message Buffer. byte Byte: value from 0 to 255.   Midi.Output.Message.Send( uint DeviceIndex ) sends the MIDI Message Buffer previously created with Midi.Output.Message.* functions to the specified MIDI Output device. uint DeviceIndex: zero-based index of the device.   Midi.Output.Message.SendShort( uint DeviceIndex, byte Byte1, byte Byte2, byte Byte3 ) sends a Short MIDI Message Buffer (up to 3 bytes) to the specified MIDI Output device. This function has lower latency. Most MIDI Messages require up to 3 bytes (except for System Exclusive MIDI Messages). If the MIDI Message requires only 2 bytes, set the Byte3 argument to 0. uint DeviceIndex: zero-based index of the device. byte Byte1: first byte. byte Byte2: second byte. byte Byte3: third byte.   Code Example using System.Collections; using System.Collections.Generic; using UnityEngine; using Giavapps.MIDI; public class CodeExample : MonoBehaviour { void Awake() { Midi.Output.Device.Open(0);//Opens the first MIDI Output Device ("Microsoft GS Wavetable Synth" by default on Windows) } void Update() { //Checks if space key is pressed if(Input.GetKeyDown(KeyCode.Space)) { //NOTE C5 ON – CHANNEL 1 – VELOCITY 100 Midi.Output.Message.Clear();//Clears the MIDI Message buffer Midi.Output.Message.Byte(144);//Adds one byte to the MIDI Message buffer Midi.Output.Message.Byte(60);//Adds one byte to the MIDI Message buffer Midi.Output.Message.Byte(100);//Adds one byte to the MIDI Message buffer Midi.Output.Message.Send(0);//Sends the MIDI Message to the MIDI Output Device } //Checks if space key is released else if(Input.GetKeyUp(KeyCode.Space)) { //NOTE C5 OFF – CHANNEL 1 – VELOCITY 0 Midi.Output.Message.Clear();//Clears the MIDI Message buffer Midi.Output.Message.Byte(128);//Adds one byte to the MIDI Message buffer Midi.Output.Message.Byte(60);//Adds one byte to the MIDI Message buffer Midi.Output.Message.Byte(0);//Adds one byte to the MIDI Message buffer Midi.Output.Message.Send(0);//Sends the MIDI Message to the MIDI Output Device } //Checks if return key is pressed if(Input.GetKeyDown(KeyCode.Return)) { //NOTE C5 ON – CHANNEL 1 – VELOCITY 100 Midi.Output.Message.SendShort(0, 144, 60, 100);//Sends the Short MIDI Message to the MIDI Output Device } //Checks if return key is released else if(Input.GetKeyUp(KeyCode.Return)) { //NOTE C5 OFF – CHANNEL 1 – VELOCITY 0 Midi.Output.Message.SendShort(0, 128, 60, 0);//Sends the Short MIDI Message to the MIDI Output Device } } 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...

Read More

Midi.Output.Device Class

Midi.Output.Device Class

  About Midi.Output.Device Class   Midi.Output.Device class is mainly used for retrieving information about MIDI Output devices and for opening and closing MIDI Output devices.   Midi.Output.Device Class Methods   Midi.Output.Device.Count() returns the amount of connected MIDI Output devices. This function detects connected MIDI Output devices.   Midi.Output.Device.Name( uint DeviceIndex ) returns a string identifier for the specified MIDI Output device. uint DeviceIndex: zero-based index of the device.   Midi.Output.Device.Open( uint DeviceIndex ) opens the specified MIDI Output device. Only open devices can receive messages. uint DeviceIndex: zero-based index of the device.   Midi.Output.Device.OpenAll() opens all MIDI Output devices. Only open devices can receive messages.   Midi.Output.Device.IsOpen( uint DeviceIndex ) returns true if a MIDI Output device is open and false if not. uint DeviceIndex: zero-based index of the device.   Midi.Output.Device.OpenCount() returns the amount of open MIDI Output devices.   Midi.Output.Device.Close( uint DeviceIndex ) closes the specified MIDI Output 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.Output.Device.CloseAll() closes all open MIDI Output devices. Note that when you call Midi.Deinitialize() function or when you unplug the device it will be closed automatically by Giavapps MIDI extension.   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...

Read More

Midi.Input.Message Class

Midi.Input.Message Class

  About Midi.Input.Message Class   Midi.Input.Message class is mainly used for receiving MIDI Messages from MIDI Input devices.   Midi.Input.Message Class Methods   Midi.Input.Message.ManualChecking( bool ManualChecking ) specifies if Giavapps MIDI should store data about detected MIDI Messages in order that you can then check that data through Midi.Input.Message.* functions. By default this feature is disabled. When this feature is enabled you must always loop through all received data by calling Midi.Input.Message.Count() (usually inside Update() or Coroutine methods). If a MIDI device continues sending MIDI Messages and you are not processing them you may cause a memory leak. (See Code Examples below for more info about how to manual check MIDI Messages correctly). When this feature is disabled, Giavapps MIDI will stop storing data for MIDI Messages. You can leave disabled this feature if you are not going to use any of the Midi.Input.Message.* functions. bool ManualChecking: enable (true) or disable (false) manual check.   Midi.Input.Message.Count( uint DeviceIndex ) returns the amount of messages from the specified MIDI Input device. Use the other Midi.Input.Message.* functions to get info about the messages. When you call this function Giavapps MIDI will free data stored for MIDI Messages (see Midi.Input.Message.ManualChecking() function for more info). uint DeviceIndex: zero-based index of the device.   Midi.Input.Message.Size( uint DeviceIndex, ulong MessageIndex ) returns the amout of bytes of the specified MIDI Message. uint DeviceIndex: zero-based index of the device. ulong MessageIndex: zero-based index of the MIDI Message.   Midi.Input.Message.Byte( uint DeviceIndex, ulong MessageIndex, ulong ByteIndex) Returns the specified byte (0-255) from the given MIDI Message. uint DeviceIndex: zero-based index of the device. ulong MessageIndex: zero-based index of the MIDI Message. ulong ByteIndex: zero-based index of the byte.   Midi.Input.Message.Time( uint DeviceIndex, ulong MessageIndex ) returns the amount of time (milliseconds) passed since the MIDI Input device was open. uint DeviceIndex: zero-based index of the device. ulong MessageIndex: zero-based index of the MIDI Message.   Code Example using System.Collections; using System.Collections.Generic; using UnityEngine; using Giavapps.MIDI; public class CodeExample : MonoBehaviour { void Awake() { 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) Midi.Input.Message.ManualChecking(true);//Enables manual checking of MIDI Messages } void Update() { //Prints all received MIDI Messages for(uint d=0; d < Midi.Input.Device.Count(); d++) { ulong messages = Midi.Input.Message.Count(d); for(ulong m = 0; m < messages; m++) { ulong time = Midi.Input.Message.Time(d, m); ulong size = Midi.Input.Message.Size(d, m); string bytes = “”; for(ulong b = 0; b < size; b++) { bytes...

Read More

Midi.Input.Device Class

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

Read More

Midi Class

Midi Class

  About Midi Functions   Midi functions use native Windows API. Midi functions can handle multiple MIDI Input and multiple MIDI Output devices at a time. The MIDI Input Buffers for receiving MIDI Messages have a limit of 1024 bytes. The MIDI Output Buffer for sending MIDI Messages has no limits.   About Midi Class   Midi class is mainly used for deinitializing Midi library.   Midi Class Methods   Midi.Deinitialize() method deinitializes Midi library. This function should be called for freeing memory used (usually inside OnApplicationQuit() method).   Code Example using System.Collections; using System.Collections.Generic; using UnityEngine; using Giavapps.MIDI; public class CodeExample : MonoBehaviour { void Awake() { //Other function calls could be here… } void Update() { //Other function calls could be here or you can start a Coroutine for best performance! } 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...

Read More
content top