# Lemur midi_args



## Flycrazy (Sep 18, 2018)

Hi Folks.

MIDI_ARGS is an array. It represents: Message type, Midi Target, Midi channel in Lemur.
In this case is message type a hex value or a decimal value?

P.e.: {1,1,0) What does this mean?

Thank you so much.

Flycrazy


----------



## pmcrockett (Sep 18, 2018)

Flycrazy said:


> Hi Folks.
> 
> MIDI_ARGS is an array. It represents: Message type, Midi Target, Midi channel in Lemur.
> In this case is message type a hex value or a decimal value?
> ...



The manual's description of how the MIDI_ARGS array works isn't entirely clear, so here's my best attempt at an explanation of how to get useful data from it.

The MIDI_ARGS array itself does not contain info about message type or target. The type, target, channel, and value ranges that you set in the script header next to _Execution: On MIDI_ act as a filter for all of the incoming MIDI data. Only events that pass the filter are placed in MIDI_ARGS, and the script runs once for every event that passes.

The data that actually gets stored in MIDI_ARGS, which will all be decimal format, can be found in the manual's Appendix IV (page 147). Data 1 is MIDI_ARGS[0], Data 2 is MIDI_ARGS[1], and whatever is listed under Remarks, which is channel in most cases, is MIDI_ARGS[2]. Note that any channel data begins counting at 0, so what we would normally call channel 1 shows up as 0, channel 2 as 1, etc.

So for example, with {1 ,1, 0}, the data values are 1 and 1, and the channel is 0 (meaning channel 1). If this came from MIDI_ARGS in a script that was filtering for note on messages, then it would mean MIDI note 1 played with velocity 1. If the script was filtering for control change messages, then it would mean CC 1 with a value of 1. And so forth.

Note also that although most MIDI messages produce the three entries in MIDI_ARGS described above, a sysex message can be any length -- you'll have to use sizeof(MIDI_ARGS) to determine how many entries it has. If I remember correctly, the final entry in a sysex MIDI_ARGS is channel number even though the manual doesn't mention this.


----------



## Flycrazy (Sep 19, 2018)

Dear pmcrockett.

Thank you so much for your clear reply. Amazing!

So to check myself:

I have a script in Lemur:
Execution: on MIDI, A0-Keypressure, MIDI 7, 0-127, 1-16

I setup a Monitor object to check MIDI_ARGS.
-- Monitor.value=MIDI_ARGS; --

It shows on my iPad: {1,1,0}

This means: I received a Key-pressure(A0) Key#1, Value:CC1, On Midi channel: 1 (0 means in Lemur Midi channel 1)

Am I correct?

With regards,

Flycrazy.






pmcrockett said:


> The manual's description of how the MIDI_ARGS array works isn't entirely clear, so here's my best attempt at an explanation of how to get useful data from it.
> 
> The MIDI_ARGS array itself does not contain info about message type or target. The type, target, channel, and value ranges that you set in the script header next to _Execution: On MIDI_ act as a filter for all of the incoming MIDI data. Only events that pass the filter are placed in MIDI_ARGS, and the script runs once for every event that passes.
> 
> ...


----------



## pmcrockett (Sep 19, 2018)

Mostly correct, but if you're using key pressure (A0), then you're filtering for key aftertouch and not CC. So {1, 1, 0} would mean MIDI key 1, aftertouch value 1, channel 1.


----------



## Flycrazy (Sep 20, 2018)

Hi pmcrockett.

Thank you again for your effort. I really appreciate your response. MIDI_ARGS is clear to me.

With regards,

Flycrazy



pmcrockett said:


> Mostly correct, but if you're using key pressure (A0), then you're filtering for key aftertouch and not CC. So {1, 1, 0} would mean MIDI key 1, aftertouch value 1, channel 1.


----------

