Page 1 of 1

midion questions. What is the second value in the msg array?

Posted: 18 Oct 2016 11:18
by GV1
Quick question.

I'm creating a script and using the midiout function. I've got it to work by doing this:

Code: Select all

midiout(0, {0x90, 60, 1});

0 = channel
0x90 = note on
60 = note
1 = ???
My only question is what is that second array value (the number 1 in my example). I thought it was velocity but this has no effect. Setting it to 1, or 127, produces the same velocity.

I'm just curious as to what this second value is. The docs are not very helpful. I'm on a Jazzmutant Lemur, but I assume the scripting is similar as Liine's version.

Re: midion questions. What is the second value in the msg ar

Posted: 18 Oct 2016 11:36
by oldgearguy
You are correct - the note on message is -- 0x9z (note on - MIDI channel z = 0-f [channel 1 to 16]), 0xnn (note number 00 - 7f), 0xvv (note velocity 00 - 7f)

Small syntax correction - the very first 0 in your example is the Lemur MIDI target, not the MIDI channel number (channel is embedded in the note message)

Re: midion questions. What is the second value in the msg ar

Posted: 18 Oct 2016 11:38
by GV1
oldgearguy wrote:You are correct - the note on message is -- 0x9z (note on - MIDI channel z = 0-f [channel 1 to 16]), 0xnn (note number 00 - 7f), 0xvv (note velocity 00 - 7f)

Small syntax correction - the very first 0 in your example is the Lemur MIDI target, not the MIDI channel number (channel is embedded in the note message)
Ahhh, that makes sense thanks. I didn't know the msg values had to be in hex.

Is there any good docs for scripting apart from the one I'm reading on the old lemur site?

Re: midion questions. What is the second value in the msg ar

Posted: 18 Oct 2016 11:46
by oldgearguy
GV1 wrote:
oldgearguy wrote:You are correct - the note on message is -- 0x9z (note on - MIDI channel z = 0-f [channel 1 to 16]), 0xnn (note number 00 - 7f), 0xvv (note velocity 00 - 7f)

Small syntax correction - the very first 0 in your example is the Lemur MIDI target, not the MIDI channel number (channel is embedded in the note message)
Ahhh, that makes sense thanks. I didn't know the msg values had to be in hex.

Is there any good docs for scripting apart from the one I'm reading on the old lemur site?
I use hex since it tends to be more obvious as to what you're doing. Most of the MIDI specs I see on-line show everything in bits (note on = 1001nnnn) or hex.
Although that doesn't explain why you don't hear/see a difference with various velocity values.

I learned the scripting by doing 3 things - reading the manual about 20 times, downloading a handful of projects created by others that demonstrated things I wanted in my template, and by creating a very simple project with only 1 or 2 objects and about 4 or 5 Monitor windows watching the values of everything as I scripted things. Often the Lemur behaves differently than you expect and it's always good in the beginning to be watching values inside scripts to see if and when they change.

If you know C/C++/Java programming, that is a big help in some areas of Lemur programming.

Re: midion questions. What is the second value in the msg ar

Posted: 18 Oct 2016 12:38
by GV1
oldgearguy wrote:
GV1 wrote:
oldgearguy wrote:You are correct - the note on message is -- 0x9z (note on - MIDI channel z = 0-f [channel 1 to 16]), 0xnn (note number 00 - 7f), 0xvv (note velocity 00 - 7f)

Small syntax correction - the very first 0 in your example is the Lemur MIDI target, not the MIDI channel number (channel is embedded in the note message)
Ahhh, that makes sense thanks. I didn't know the msg values had to be in hex.

Is there any good docs for scripting apart from the one I'm reading on the old lemur site?
I use hex since it tends to be more obvious as to what you're doing. Most of the MIDI specs I see on-line show everything in bits (note on = 1001nnnn) or hex.
Although that doesn't explain why you don't hear/see a difference with various velocity values.

I learned the scripting by doing 3 things - reading the manual about 20 times, downloading a handful of projects created by others that demonstrated things I wanted in my template, and by creating a very simple project with only 1 or 2 objects and about 4 or 5 Monitor windows watching the values of everything as I scripted things. Often the Lemur behaves differently than you expect and it's always good in the beginning to be watching values inside scripts to see if and when they change.

If you know C/C++/Java programming, that is a big help in some areas of Lemur programming.
Yeah that's what I'm doing now. I know a fair few languages (C, JS, NASM, Go etc) so this should be easy. I've been meaning to do scripting for a good few years and finally have a month off work so decided to dedicate some time to learning. Thanks for the help and advice it's much appreciated.

Re: midion questions. What is the second value in the msg ar

Posted: 18 Oct 2016 14:50
by oldgearguy
The one thing to wrap your head around is that Lemur executes in frames. I have bugged the developers over the years to provide an "Inside Lemur" type of guide that details how frames work, what happens if a script takes longer than a frame to run, etc., but so far nothing from them.

You can't do things like have a for loop for delays or an infinite while loop or have a script start something on mouse down and have it keep running easily. Again - play around with familiar programming constructs with lots of monitoring to see what is happening. The frames thing also affects the idea of state and state transitions. When you find a need to do something complex, ping the folks here. There's a few people that have really ben exercising the limits of what can be done and sometimes there's a need to use the constructs in different ways to achieve the goal.

Re: midion questions. What is the second value in the msg ar

Posted: 18 Oct 2016 15:36
by GV1
Excellent advice thank you. I am going to upgrade to the iPad version soon because Canvas looks so cool. For the moment I'm on the old Lemur.

Regarding the hexadecimal numbers. I have created a script under the project folder called 'ChordMaker'. Inside this script I have some global variables. One of them is below:

Code: Select all

decl keys = { 0x3D, 0x3E, 0x3F ...}
... Basically 12 chromatic notes from middle C. Now in another script that makes a call to midiout and passes one of the keys from the array (Execution set to manual), like so:

Code: Select all

midiout(0, {0x90, ChordMaker.keys[2], 0x7F});
The problem I'm having is nothing happens. If I hardcode the 0x3F it works fine. I can only assume I'm doing something wrong, or that the hex is being converted to a number and passing the number.

Unless ChordMaker has to return the keys for that to work. Lemur's scripting is very odd ha ha. It's like going from C to async JS :lol:

Any ideas?

Re: midion questions. What is the second value in the msg ar

Posted: 18 Oct 2016 16:10
by GV1
Fixed it. I created a container called ChordMaker (feels more like a class and allows me to organize code better). I then created a script called chromaticScale(). Now I call it from the other script like so:

Code: Select all

midion(0, {0x90, ChordMaker.chromaticScale()[0], 0x7F});
Works fine :)