MPL tutorial: MIDI In section
The MIDI In section starts each time a MIDI message is received at one of the opened MIDI In ports. Before this section is executed the following variables are filled: MidiIn, Type, Channel, DataByte1, DataByte2. MidiIn will contain the number of the MIDI In port were the message was received. MPL will not receive system exclusive messages.
Below the instructions in (in blue) are explained (in black).
;The recording channel is specified in control 5
Let Channel = ControlValue@5
The value listed on screen for control 5 is copied to the predeclared variable Channel.
;MIDI thru function
The same message that was recieved at the MIDI In port is now send to the MIDI Out port. Only the channel is changed. If you don't want this MIDI thru (because your MIDI keyboard controller is already producing tones on its self) then simply place a semicollon (;) before the instruction to inactivate it.
;Record anything received at the MIDI In Port
Let Ticks = Multiply Clock Division
Let Ticks = Divide Ticks 24
The number of ticks in a beat as counted by Clock is always 24. The number of ticks/beat in a MIDI file is different for each MIDI file and is specified in the variable Division. So to convert clock ticks to MIDI file ticks multiply it by division and then divide it by 24. You can do only one function at a time. Always do multiply before division. Example: clock = 17 and division = 480. 17 times 480 is 8160 and 8160/24 = 340. While 17/24 = 0 and 480 time 0 is still 0.
Let NoteLength = -1
When you insert a type 1 event (note on) then the NoteLenght variable will be used to insert both the note on and the note off event in the chain. But because we are recording in real time here, we don't no yet how long the note will last. The -1 value of the notelength forces MPL to only insert a note on event. The note off event will be inserted like all other events when it is received.
The recieved MIDI message is inserted in chain 1. Or actually a reminder for this is added to the to-do-list and it will be inserted with the UpdateChains instruction at the end of the Main section.
Back to the Mpl main page.