MIDI Input – Giavapps MIDI

midi_input_device_count() Returns the amount of connected MIDI Input devices. This function detects new connected MIDI Input devices.

 

midi_input_device_name(DeviceIndex) Returns the name of a connected MIDI Input device.

DeviceIndex: zero-based index of the device.

 

midi_input_auto_open(AutoOpen) Specifies if Giavapps MIDI should automatically open all connected MIDI Input devices. By default this feature is disabled.

AutoOpen: enable (true) or disable (false) the auto open feature.

 

midi_input_auto_message(InputDeviceIndex, OutputDeviceIndex, AutoMessage) Specifies if the given MIDI Input device should automatically send all detected MIDI Messages to the specified MIDI Output device.

InputDeviceIndex: zero-based index of the MIDI Input device.
OutputDeviceIndex: zero-based index of the MIDI Output device.
AutoMessage: enable (true) or disable (false) the auto message feature for the specified MIDI Input device.

 

midi_input_open(DeviceIndex) Opens the specified MIDI Input device. Only opened devices can receive messages.

DeviceIndex: zero-based index of the device.

 

midi_input_open_all() Opens all connected MIDI Input devices.

 

midi_input_close(DeviceIndex) Closes the specified MIDI Input device.

DeviceIndex: zero-based index of the device.

 

midi_input_close_all() Closes all connected MIDI Input devices.

 

midi_input_key_manual_checking(ManualChecking) Specifies if Giavapps MIDI should store data about detected Key Presses and Key Releases in order that you can then check that data through midi_input_key_press_* and midi_input_key_release_* functions. By default this feature is disabled. When this feature is enabled you must always loop through all received data by calling midi_input_key_press_count() and midi_input_key_release_count() for all connected MIDI Input devices (usually inside a Step Event or Alarm Event). 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 key events correctly). When this feature is disabled, Giavapps MIDI will stop storing data for Key Presses and Key Releases. You can leave disabled this feature if you are not going to use any of the midi_input_key_press_* and midi_input_key_release_* functions.

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

 

midi_input_key_press_count(DeviceIndex) Returns the amount of key presses from a connected MIDI Input device since this function was last called. Use the other midi_input_key_press_* functions to get info about the key presses. When you call this function Giavapps MIDI will free data stored for Key Presses (see midi_input_key_manual_checking() for more info).

DeviceIndex: zero-based index of the device.

 

midi_input_key_press_note(DeviceIndex, KeyIndex) Returns the note (0127) of a key press from a connected MIDI Input device.

DeviceIndex: zero-based index of the device.
KeyIndex: zero-based index of the key.

 

midi_input_key_press_velocity(DeviceIndex, KeyIndex) Returns the velocity (1100) of a key press from a connected MIDI Input device. Values are affected by how hard the key was hit (if the device supports it).

DeviceIndex: zero-based index of the device.
KeyIndex: zero-based index of the key.

 

midi_input_key_press_time(DeviceIndex, KeyIndex) Returns the amount of milliseconds between the application starting to read input from the device and the key press from a connected MIDI Input device.

DeviceIndex: zero-based index of the device.
KeyIndex: zero-based index of the key.

 

midi_input_key_release_count(DeviceIndex) Returns the amount of key releases from a connected MIDI Input device since this function was last called. Use the other midi_input_key_release_* functions to get info about the key releases. When you call this function Giavapps MIDI will free data stored for Key Releases (see midi_input_key_manual_checking for more info).

DeviceIndex: zero-based index of the device.

 

midi_input_key_release_note(DeviceIndex, KeyIndex) Returns the note (0127) of a key release from a connected MIDI Input device.

DeviceIndex: zero-based index of the device.
KeyIndex: zero-based index of the key.

 

midi_input_key_release_time(DeviceIndex, KeyIndex) Returns the amount of milliseconds between the application starting to read input from the device and the key release from a connected MIDI Input device.

DeviceIndex: zero-based index of the device.
KeyIndex: zero-based index of the key.

 

midi_input_instrument(DeviceIndex) Returns the selected instrument (0127) of a connected MIDI Input device.

DeviceIndex: zero-based index of the device.

 

midi_input_pitch_wheel(DeviceIndex) Returns the pitch wheel offset (0127) of a connected MIDI Input device. 64 is no change.

DeviceIndex: zero-based index of the device.

 

midi_input_control(DeviceIndex, ControlNumber) Returns the value (0127) of the given control of a connected MIDI Input device. This function is for advanced users only. For more info about MIDI Control Change Messages click here.

DeviceIndex: zero-based index of the device.
ControlNumber: MIDI Control Number (0127).

 

midi_input_message_manual_checking(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() for all connected MIDI Input devices (usually inside a Step Event or Alarm Event). If a MIDI device continues sending MIDI Messages and you are not processing them you may cause a memory leak. When this feature is disabled, Giavapps MIDI stops 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.

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

 

midi_input_message_count(DeviceIndex) Returns the amount of messages from a connected MIDI Input device since this function was last called. 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_manual_checking() function for more info).

DeviceIndex: zero-based index of the device.

 

midi_input_message_byte(DeviceIndex, MessageIndex, ByteNumber) Returns the specified byte from the detected MIDI Message of a connected MIDI Input device. This function is for advanced users only. For more info about MIDI Messages click here.

DeviceIndex: zero-based index of the device.
MessageIndex: zero-based index of the detected MIDI Message.
ByteNumber: number of the byte to retrieve (02).

 

midi_input_message_time(DeviceIndex, MessageIndex) Returns the amount of milliseconds between the application starting to read input from the device and the time that the message was detected from a connected MIDI Input device.

DeviceIndex: zero-based index of the device.
MessageIndex: zero-based index of the detected MIDI Message.

 

Code Examples

 

Checking MIDI Input Devices

 

show_message(‘You have ‘+string(midi_input_device_count())+‘ usable MIDI Input devices on this computer!’);

for
(i = 0; i < midi_input_device_count(); i++)
{
show_message(‘ID: ‘+string(i)+‘#NAME: "’+midi_input_device_name(i)+‘"’);
}

 

Sending Input Messages To An Output Device Automatically

 

midi_input_auto_open(1);//Automatically opens all connected MIDI Input devices
midi_output_auto_open(1);//Automatically opens all connected MIDI Output devices
midi_input_auto_message(1,0,1);//The second MIDI Input Device ("Oxygen 49" in my case) will send any input message to the first Output Device ("Microsoft GS Wavetable Synth")

//With only 3 lines of code you can start playing with your MIDI Keyboard and have fun!

 

Manual Checking Key Presses And Key Releases

 

Create Event:

 

midi_input_auto_open(1);//Automatically opens all connected MIDI Input devices
midi_output_auto_open(1);//Automatically opens all connected MIDI Output devices
midi_input_key_manual_checking(1);//Enables Key Presses and Key Releases features

 

Step Event:

 

var devices, keypresses, keyreleases, d, k;
devices = midi_input_device_count();

if (devices > 0)
{

//Loops through each MIDI Input Device…
for(d = 0; d < devices; d++)
{

//Loops through each MIDI Input Key Pressed…
keypresses = midi_input_key_press_count(d);
for (k = 0; k < keypresses; k++)
{
midi_output_note_on_ext(0, 0, midi_input_instrument(d), 64, midi_input_key_press_note(d, k), midi_input_key_press_velocity(d, k));//Plays the key pressed!
}

//Loops through each MIDI Input Key Released…
keyreleases = midi_input_key_release_count(d);
for (k = 0; k < keyreleases; k++)
{
midi_output_note_off(0, 0, midi_input_key_release_note(d, k));//Stops the key released!
}

}

}

 

Manual Checking MIDI Messages

 

Create Event:

 

midi_input_auto_open(1);//Automatically opens all connected MIDI Input devices
midi_input_message_manual_checking(1);//Enables manual checking of MIDI Messages

 

Step Event:

 

var devices, messages, d, m, byte1, byte2, byte3, time, str;
devices = midi_input_device_count();

if (devices > 0)
{

//Loops through each MIDI Input Device…
for(d = 0; d < devices; d++)
{

//Loops through each MIDI Message…
messages = midi_input_message_count(d);
for (m = 0; m < messages; m++)
{
byte1 = midi_input_message_byte(d, m, 0);
byte2 = midi_input_message_byte(d, m, 1);
byte3 = midi_input_message_byte(d, m, 2);
time = midi_input_message_time(d, m);

str = "BYTE 1: "+string(byte1)
+" – BYTE 2: "+string(byte2)
+" – BYTE 3: "+string(byte3)
+" – TIME: "+string(time);

show_debug_message(str);//shows a debug message with the MIDI Message
}

}

}

 

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.

Leave a Reply

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *

*