ssCore.MIDI.setNotify

Tell SWF Studio about a MIDI event notification that you'd like to receive.


Availability:

First available in version 3.2 build 136.


Input Parameters:

event - The name of the event notification you want enabled. Valid values include: onRawData.


Output Parameters:

result - Notification data for the specified event (see description of events for more detail).


Asynchronous Mode:

When this method is called asynchronously, a return object containing the output parameters is passed to the specified callback function.

ssCore.MIDI.setNotify( paramsObject [, callbackParamsObject] [, errorParamsObject] );


Synchronous Mode:

When this method is called synchronously, a return object containing the output parameters is returned to the caller immediately.

var returnObject = ssCore.MIDI.setNotify( paramsObject );


Notes:

MIDI events are triggered by messages received from the MIDI device, typically as a result of user interaction. Often, devices may also send "Active Sensing" messages every 300 milliseconds of so, to notify the system that they are still connected and active.

Notification data is returned as a string of comma separated values. In the listings below, the field names have the following meanings:

To cancel notifications about an event, use MIDI.clearNotify.

To activate the event notification system, use MIDI.start. To temporarily stop the MIDI device from generating events, use MIDI.stop.

MIDI.setNotify may be called before MIDI.start if you wish to define the required event notifications before starting the notification system. Also, there is no need to temporarily stop the notification system before making changes to registered events.

name - onRawData
type - triggered
result - "RAW_DATA,id,msec,cmd,value1,value2"

The onRawData event is triggered by the MIDI device, usually as a result of user interaction. The interpretation of the cmd, value1, and value2 are defined in the MIDI standard, available at www.midi.org.

ssCore.MIDI.setNotify({event:"onRawData"}, {callback:onRawDataReceived});

function onRawDataReceived(ret_obj, cb_obj, err_obj)
{
    if (ret_obj.success)
    {
        var v = ret_obj.result.split(",");
        ssDebug.trace("MIDI command received:");
        ssDebug.trace(" device id: " + v[1]);
        ssDebug.trace(" time offset: " + v[2] + " milliseconds");
        ssDebug.trace(" command: " + v[3]);
        ssDebug.trace(" value 1: " + v[4]);
        ssDebug.trace(" value 2: " + v[5]);
    }
}