MPL Tutorial



Navigation: Go to End of Page







Lynn Walls has created this tutorial. It uses an example MPL string which is followed by

an analysis of the MPL being used. The purpose of this MPL example is to map the incoming

MIDI Controller 16 data2 value ranging from 75 to 127 into a resulting range of 0 to 1.



EXAMPLE:

Change equal 191, equal 16, greaterEqual 75 | sub 75 | div 52 | lessEqual 1 | mult 200 |

get z | mod 10 | get r | set z | sub r | div 200 | get value



ANALYSIS:



MPL consists of a "chain" of segments delineated by the vertical bar character "|".

The above example MPL consists of 12 such segments. Processing starts with the

leftmost segment and proceeds to the right, segment by segment.

Each segment usually performs a specific operation on the number received from the

segment at the left, and passes the result on to the next segment at the right.



"Change" means: jOrgan will trigger the change event whenever an incoming MIDI

message satisfies the specifications of the 1st segment, and is DIFFERENT from the previously

received (if any) MIDI message that had also satisfied the constraints of the 1st segment.



1st segment: "equal 191, equal 16, greaterEqual 75" specifies the criteria for how an

incoming MIDI message will trigger the Change event.

"equal 191" corresponds to the first byte of the incoming MIDI message being watched for.

It is the COMMAND and CHANNEL NUMBER byte. The number 191 contains two distinct items

of data: the command code in the left-hand half-byte and the MIDI channel number in the

right-hand half-byte.



It's easier to understand if you convert the decimal number 191 to hexadecimal (hex).

Decimal 191 equals hexadecimal BF. Now the left half-byte is obvious: "B", and the

right half-byte is "F".

"B" is the hex representation of the MIDI command "Continuous Controller" (CC for short)

and "F" is the channel number in hex, which is equivalent to 15 in decimal. So, the

number "191" means: MIDI command for Continuous Controller on MIDI channel 15 (where MIDI

channels are numbered from 0 to 15, NOT 1 to 16).

"equal 16" corresponds to the second byte of the incoming MIDI message. It is referred to

as the MIDI "data1" byte. In the context of the CC command the data1 byte is the

controller number -- in this example: decimal 16 (or hex F).

"greaterEqual 75" specifies how the third ("data2") byte of the MIDI message will be

examined. The data2 byte of a CC MIDI message is a number ranging from 0 to 127 received

in the incoming MIDI message. So, "greaterEqual" means that the data2 VALUE must be

greater than or equal to 75 in order to trigger the Change event.

In summary: the first segment of the example MPL string above specifies that in order for

the Change event to be triggered, the incoming MIDI message command must be from a

Continuous Controller on MIDI channel 15, and the controller number must be 16, and the

data2 value from the controller must be 75 or greater. When all this is true, store

the data2 number in the system variable named "value" and pass that number on the next

segment.



2nd segment: "sub 75" means subtract 75 from whatever data2 VALUE was received from CC 16 in

the segment to the left, and pass the remainder on to the next segment to the right.



3rd segment: "div 52" means divide the number received from the segment to the left by 52 and

pass the result on to the next segment.



4th segment: "lessEqual 1" means stop processing the MPL if the number received from the left

is NOT less than or equal to 1. Otherwise pass the number received from the left segment

on to the next segment.



5th segment: "mult 200" means multiply the number received from the segment to the left by 200

and pass the result on to the next segment.



6th segment: "get z" means get the number received from the previous segment and store it in a

variable named "z", and then pass that number on to the next segment.



7th segment: "mod 10" means divide the number received from the previous segment by 10 and pass

the REMAINDER on to the next segment. (e.g. If z=155, 155/10=15 with a remainder of 5.)



8th segment: "get r" means get the number received from the previous segment and store it in a

variable named "r", and the pass the number on to the next segment.



9th segment: "set z" means retrieve the number from the variable "z" and pass it on to the next

segment.



10th segment: "sub r" means subtract the number stored in the variable "r" from the number

received from the previous segment and pass the result on to the next segment.



11th segment: "div 200" means divide the number received from the previous segment by 200 and

pass the result on to the next segment.



12th segment: "get value" means get the number received from the previous segment and store it

in the system variable "value" where it will be treated as the recomputed value received from

the Continuous Controller.



Navigation