content top

Mci Class

Mci Class

  About Mci Functions   Mci functions use native Windows API and MCI (Media Control Interface) commands for playing external MIDI (*.mid) files through the default MCI MIDI Sequencer. Note that Giavapps MIDI also includes an extra feature for executing custom MCI commands: you can do a lot more with it! You can check the following link for more info about: https://msdn.microsoft.com/it-it/library/windows/desktop/dd798439(v=vs.85).aspx   About Mci Class   Mci class is mainly used for initializing and deinitializing Mci library but also for sending custom MCI commands.   Mci Class Methods   Mci.Initialize() method initializes Mci library. This function should be called before any other function (usually inside Awake() or Start() methods).   Mci.Deinitialize() method deinitializes Mci library. This function should be called for freeing memory used (usually inside OnApplicationQuit() method).   Mci.Command( string Command ) sends a command string to an MCI device. You can check the following link for a full list of available commands: https://msdn.microsoft.com/en-us/library/windows/desktop/dd743373(v=vs.85).aspx string Command: string that specifies an MCI command string.   Code Example using System.Collections; using System.Collections.Generic; using UnityEngine; using Giavapps.MIDI; public class CodeExample : MonoBehaviour { void Awake() { Mci.Initialize();//Initializes Mci } void Update() { //Other function calls could be here or you can start a Coroutine for best performance! } void OnApplicationQuit() { Mci.Deinitialize();//Deinitializes Mci } }   Mci Class Members   Mci.Alias member contains a string which determines the current alias prefix name used for internal MCI commands. The full alias name used internally is equal to Mci.Alias+DeviceIndex ("midi1" for example). You can leave this value as it is or you can edit it (manually) for using your own custom alias name. Note that if this value is set to an empty string Giavapps MIDI will use the default alias prefix name (which is "midi").   Code Example Debug.Log(“MCI ALIAS: “+Mci.Alias);   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.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
content top