RTMIDI – Giavapps MIDI

 

About RTMIDI Functions

 

Giavapps MIDI includes support for RtMidiRtMidi is a set of C++ classes that provides a common API for realtime MIDI input/output. library functions. These functions have better performace, different features and different limitations but they could be ported on more operative systems in the future. Thanks to this addition you can send and receive any kind of MIDI Message (so you are not limited to 3 bytes only). These functions are for advanced users only.

 

RTMIDI Utility

 

rtmidi_version() Returns a string which determines the current RtMidi version.

 

RTMIDI Input

 

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

 

rtmidi_input_device_name(DeviceIndex) Returns a string identifier for the specified MIDI Input device and number.

DeviceIndex: zero-based index of the device.

 

rtmidi_input_auto_message(AutoMessage) Specifies if the open MIDI Input device should automatically send all received MIDI Messages to the open MIDI Output device.

AutoMessage: enable (true) or disable (false) the auto message feature for the specified MIDI Input device.

 

rtmidi_input_open(DeviceIndex) Opens the specified MIDI Input device. Only open devices can receive messages.

DeviceIndex: zero-based index of the device.

 

rtmidi_input_is_open() Returns true if a MIDI Input device is open and false if not.

 

rtmidi_input_close() Closes an open MIDI Input device (if exists).

 

rtmidi_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 rtmidi_input_message_* functions. By default this feature is disabled. When this feature is enabled you must always loop through all received data by calling rtmidi_input_message_count() (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 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 rtmidi_input_message_* functions.

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

 

rtmidi_input_message_type(Sysex, Time, Sense) Specify whether certain MIDI Message Types should be queued or ignored during input.

Sysex: enable (true) or disable (false) System Exclusive messages.
Time: enable (true) or disable (false) Timing messages.
Sense: enable (true) or disable (false) Active Sensing messages.

 

rtmidi_input_message_count() Returns the amount of messages from an open MIDI Input device since this function was last called. Use the other rtmidi_input_message_* functions to get info about the messages. When you call this function Giavapps MIDI will free data stored for MIDI Messages (see rtmidi_input_message_manual_checking() function for more info).

 

rtmidi_input_message_size(MessageIndex) Returns the amout of bytes of the specified MIDI Message.

MessageIndex: zero-based index of the MIDI Message.

 

rtmidi_input_message_byte(MessageIndex,ByteIndex) Returns the specified byte (0-255) from the given MIDI Message.

MessageIndex: zero-based index of the MIDI Message.
ByteIndex: zero-based index of the byte.

 

rtmidi_input_message_time(MessageIndex) Returns the amount of time passed since the previous MIDI Message was received.

MessageIndex: zero-based index of the MIDI Message.

 

RTMIDI Output

 

rtmidi_output_device_count() Returns the amount of connected MIDI Output devices. This function detects connected MIDI Output devices.

 

rtmidi_output_device_name(DeviceIndex) Returns a string identifier for the specified MIDI Output device and number.

DeviceIndex: zero-based index of the device.

 

rtmidi_output_open(DeviceIndex) Opens the specified MIDI Output device. Only open devices can receive messages.

DeviceIndex: zero-based index of the device.

 

rtmidi_output_is_open() Returns true if a MIDI Output device is open and false if not.

 

rtmidi_output_close() Closes an open MIDI Output device (if exists).

 

rtmidi_output_message_clear() Clears the MIDI Message Buffer. This function removes all bytes previously stored in the MIDI Message Buffer.

 

rtmidi_output_message_size() Returns the amount of bytes stored in the MIDI Message Buffer.

 

rtmidi_output_message_byte(Byte) Adds one byte to the MIDI Message Buffer.

Byte: value from 0 to 255.

 

rtmidi_output_message() Sends the MIDI Message Buffer previously created with rtmidi_output_message_* functions to the open MIDI Output device.

 

Code Examples

 

Checking Connected MIDI Input And MIDI Output Devices

 

GMS 2

var str, i;
str = "MIDI INPUT DEVICES\n\n";
for(i=0; i<rtmidi_input_device_count(); i++)
{
str += rtmidi_input_device_name(i)+"\n";
}
show_message(str);

str = "MIDI OUTPUT DEVICES\n\n";

for(i=0; i<rtmidi_output_device_count(); i++)
{
str += rtmidi_output_device_name(i)+"\n";
}
show_message(str);

GMS 1.4

var str, i;
str = "MIDI INPUT DEVICES##";
for(i=0; i<rtmidi_input_device_count(); i++)
{
str += rtmidi_input_device_name(i)+"#";
}
show_message(str);

str = "MIDI OUTPUT DEVICES##";

for(i=0; i<rtmidi_output_device_count(); i++)
{
str += rtmidi_output_device_name(i)+"#";
}
show_message(str);

 

Sending Input Messages To An Output Device Automatically

 

rtmidi_input_open(2);//Opens the third MIDI Input Device ("Oxygen 49" MIDI Keyboard in my case)
rtmidi_output_open(0);//Opens the first MIDI Output Device ("Microsoft GS Wavetable Synth" by default)
rtmidi_input_auto_message(1);//Sends all received MIDI Input Messages to the MIDI Output Device ("Oxygen 49" >>> "Microsoft GS Wavetable Synth" in my case)

 

Manual Checking MIDI Input Messages

 

Create Event

 

rtmidi_input_message_type(1,1,1);//Enables all MIDI Messages Types
rtmidi_input_message_manual_checking(1);//Enables manual checking of MIDI Messages
rtmidi_input_open(2);//Opens the third MIDI Input Device ("Oxygen 49" MIDI Keyboard in my case)

 

Step Event

 

var messages,m,bytes,b;
messages = rtmidi_input_message_count();
for(m=0; m<messages; m++)
{

bytes = "";

for(b=0; b<rtmidi_input_message_size(m); b++)
{
bytes += string(rtmidi_input_message_byte(m,b))+" ";
}

show_debug_message(string(m)+" – TIME: "+string(rtmidi_input_message_time(m))+" – "+string(rtmidi_input_message_size(m))+" bytes – "+bytes);
}

 

Sending Custom MIDI Messages To An Open Output Device

 

//NOTE C5 ON – CHANNEL 1 – VELOCITY 100
rtmidi_output_message_clear
();//Clears the MIDI Message buffer
rtmidi_output_message_byte(144);//Adds one byte to the MIDI Message buffer
rtmidi_output_message_byte(60);//Adds one byte to the MIDI Message buffer
rtmidi_output_message_byte(100);//Adds one byte to the MIDI Message buffer
rtmidi_output_message();//Sends the MIDI Message to the MIDI Output Device

 

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 *

*