MPL tutorial: Mouse section

The Mouse section starts when an action is performed on one of the 5 on-screen controls with the mouse. Before the instructions in this section is executed the values of ControlNumber and ControlAction are filled. The ControlNumber specifies which of the 5 controls was operated with the mouse. ControlAction specifies what action was done: 1 = mouse button down, 2 = mouse moved (with mouse button down), 3 = mouse button up.

Below the instructions in (in blue) are explained (in black).

;Tempo controller
When the value of control 1 is changed then the value of the Tempo variable must change with it. The Tempo variable (in beats/minute) determines how often the MIDI clocks section is executed, provided that there was a StartClock before the StartStandBy section in the Main section. In that way it effects the tempo as it is played in this application. It has no effect on the tempo of the MIDI file after it is saved. If you would like that you should insert tempo meta events. An example of this is at the start of the main section.
If ControlNumber = 1
The following instruction will only be executed if the mouse operation is done on control 1.
Let Tempo = ControlValue@1
The Tempo is set to the value of Control 1 as listed on screen.
EndIf
If ControlNumber was not 1, processing continues here.

;Send controllers
Control 2 and 3 can be used to add all kinds of live effects with the mouse.
If ControlNumber = 3
If an action has be performed on control 3 then the following instructions will be executed.
Let Type = 3
Type 3 is control change
Let Channel = ControlValue@5
The channel is taken from the value of control 5 as listed on screen.
Let DataByte1 = ControlValue@2
DataByte1 (the control change number) is taken from the value of control 2 as listed on screen.
Let DataByte2 = ControlValue@3
DataByte2 (the control change value) is taken from the value of control 3 as listed on screen.
SendEvent
The controller is sent to the MIDI output port identified with the number in MidiOut,
Let Ticks = Multiply Clock Division
Let Ticks = Divide Ticks 24

Convert the scale of Clock (24 ticks in a beat) to the scale of Ticks in the MIDI file (ticks per beat is defined in the predeclared variable Division).
Declare PreviousClock Numeric
The MIDI file would get messy if you would insert many control changes for the same control number at the same time. Therefor no more than one is inserted for each Clock.
If Clock > PreviousClock
The following instructions are only executed if the clock time is not the same as the clock time at the previous insertion of a control change.
InsertEvent
Add an InsertEvent to the to-do-list. It will be inserted when the UpdateChains instruction is executed.
Let PreviousClock = Clock
Remember there already has been inserted a control change at this time.
Endif
Matches: If Clock > PreviousClock
EndIf
Matches: If ControlNumber = 3


Back to the Mpl main page.