# Midi

Subjects "bookmarked " from other pages are highlighted.

wikipedia:Midi is used throughout jOrgan to communicate with other music devices.

## MPL

jOrgan comes with its own Midi Processing Language (MPL) which allows you to dynamically construct and evaluate

wikipedia:Midi messages.

MPL expressions consist of the following commands:

Name

Description

Modifying commands

Add the value of variable n to the current value, using x as default if the variable is not defined.

sub n x

Subtract the value of variable n to the current value, using x as default if the variable is not defined.

mult n x

Multiply with the value of variable n to the current value, using x as default if the variable is not defined.

div n x

Divide the current value by the value of variable n, using x as default if the variable is not defined.

mod n x

Find the remainder of division of the current value by n, using x as default if the variable is not defined.

set n x

Set the current value to the value of variable n, using x as default if the variable is not defined.

round

Round the current value to the nearest integer.

Comparing commands

equal x

Test if the current value is equal to value x.

greater x

Test if the current value is greater than value x.

greaterEqual x

Test if the current value is greater or equal to value x.

less x

Test if the current value is less than value x.

lessEqual x

Test if the current value is less or equal to value x.

notEqual x

Test if the current value is not equal to value x.

Querying commands

get n

Get the value for variable n from the current value.

Note that upper and lower case in a command name is significant. Some elements come with built-in variables (e.g. value for

continuous elements), but you can use as many additional variables as you like.

Commands can be chained with a pipe symbol (|), in which case they are evaluated from left to right.

To send a value of 127:

` set 127`

To filter values greater 0 and storing the actual value in the variable velocity:

` greater 0 | get velocity`

To send values between 0 and 127 dependent on the variable value (which is in range 0.0 - 1.0):

` set value | mult 127`

One MPL expression is used for each byte of a wikipedia:Midi message, separated by comma (,).

To test a message for a key press on pitch 60 with velocity 100 (three bytes):

` equal 144, equal 60, equal 100`

To create a message for a key press (three bytes):

``` set 144, set 60, set 100
```

To create a wikipedia:Sysex message (ten bytes):

` set 240, set 0, set 32, set 51, set 0, set 0, set 0, set 0, set 0, set 247`

Windows may require: Midi Yoke