ISKernel:MIDI

From Lavish Software Wiki
Jump to navigation Jump to search

MIDI is short for Musical Instrument Digital Interface, a standard interface supported by musical instruments, mix panels, foot switches, etc. Inner Space supports input from these devices as of build 6562.

Unlike standard input devices, MIDI devices are not automatically enabled, and must be enabled via LavishScript (or some GUI that can do it for you). Enabling a MIDI device may be exclusive to one window at a time.

Once enabled, MIDI events can be routed directly to a LavishScript Object method, or to LavishGUI 2 to process as input events.

Enabling MIDI Input Devices via LavishScript

The MIDI Top-Level Object provides access to list and open MIDI devices.

The simplest way to enable all MIDI Input devices is to use the following command

MIDI:OpenAllDevicesIn

This will route MIDI input messages through LavishGUI 2 events including "onNoteMove" for notes and "onAxisMove" for most other controls.

Routing to a LavishScript Object Method

To route MIDI input messages through a LavishScript object method, that will work something more like this:

objectdef mymidicontroller
{
	method Initialize()
	{
		MIDI:OpenAllDevicesIn
	}

	method Shutdown()
	{
		MIDI:CloseAllDevicesIn
	}

	method OnMIDIEvent()
	{
		echo mymidicontroller:OnMIDIEvent ${Context(type)} [${Context.Device.Name}] [${Context.Device.DeviceName}] ${Context.Message} status=${Context.Status.Hex} code=${Context.StatusCode} channel=${Context.Channel} b1=${Context.Byte1} b2=${Context.Byte2}
	}
}

Here, the Context Top-Level Object provides a midiinevent. This provides details of the MIDI message, which can then be interpreted by the script.