@trevorn1 had some questions about event script configuration, so since it's been awhile since we talked about this I'm making a new post outlining the basic configuration for event scripts to get people started. This was always a rather hacky prototype feature that doesn't do as much as it could and the way it is configured is awkward. So, it will be changing in the future, but the basic mechanism of registering one or more scripts, and then writing them to test variables like this will be the same.
To get started with event scripts, bring up the Script Editor, and click New.
Paste this text:
#name MyEventScript
print("Event" eventType eventTrack eventMode)
Click Save and select a file name.
Next, bring up the Session Editor. Click on the Globals tab, and the Miscellany category. In the form find the field labeled Event Script. Type in the reference name of your script. This will be the words after the #name directive in the script file. If you did not have a #name in the file, then type in the file name without the extension.
Click Save in the editor and close it or move it out of the way so you can see the rest of the Mobius window.
Bring up the Script Console. The menu items for this have changed in my most recent build, I believe in build 41 it was under Scripts->MSL Console. In build 42 this is Scripts->Console
Now record something in track 1. You should see messages printing in the console window.
To make use of this you will rewrite the script to test the values of three variables passed into the script and add logic to have the side effects you want.
The variables passed to the script are: eventType, eventTrack, and eventMode.
The values for eventType will be one of:
Reset
RecordStart
RecordEnd
MuteStart
MuteEnd
ModeStart
ModeEnd
LoopStart
LoopCycle
The value of eventTrack will be the track number starting from 1.
The value of eventMode will only be relevant if eventType is either "ModeStart" or "ModeEnd". The values for this variable are a bit fuzzy right now, but will usually be the name of the mode you see in the UI, but in lowercase.
reset
record
play
overdub
mute
replace
insert
multiply
etc.
Caveat: You will not see eventMode values that are the names of some of the special modes like "pause" and "stop". This is the area where much more work needs to be done to bring the full set of interesting state changes into the event script.
As an example, one of the most common uses for an event script is to send a MIDI event to a hardware device that makes it turn a light on and off whenever a track enters or leaves Record mode. To do that you will make use of the MidiOut script function.
#name MyEventScript
if eventType == "RecordStart" {
MidiOut("control" 0 42 127)
}
else if eventType == "RecordEnd" {
MidiOut("control" 0 42 0)
}
The arguments passed to the MidiOut function must be passed in this order: status, channel, value, velocity.
The value for status is one of these strings:
noteOn
noteoff
control
program
start
stop
continue
poly
touch
bend
The values for channel, value, and velocity are the raw MIDI event numbers that start from zero and go up to 127.
What the value number represents is the note number for NoteOn or NoteOff events, the controller number for CC events, and the program number for Pgm events.
The final argument will be used only for Note and CC events and is either the note velocity or the CC value.
If you have multiple MIDI output devices configured, then there are ways to select which one to use, ask if you need that.