3.5

Table Of Contents
210MainStage Effects
Usage example for Trace() object
function HandleMIDI(event)
{
Trace("Hello World!");
var int = 1;
var float = 1.234;
var str = "Teststring";
Trace("The following is a float variable: " + float +
" And now we inspect an integer: " + int +
" And here's a test string: " + str);
}
Use the MIDI event beatPos property
Every MIDI event in Scripter has a property called “beatPos” that carries the exact beat
position of the event. This makes more exact event timing possible and also handles loops
correctly. This property can be used in place of timingInfo.blockStartBeat. See Use
the JavaScript TimingInfo object.
Note: This property only works if "var NeedsTimingInfo = true", otherwise it will have
a value of 0, and will print a warning if modified.
In MainStage, type either of the following lines in the Script Editor window (both achieve
the same result):
event.send()
event.sendAtBeat(event.beatPos)
Alternatively, you can use either of the following lines in the Script Editor window (both
achieve the same result):
event.beatpos += 1; event.send()
event.sendAtBeat(event.beatPos + 1)
Usage example for the beatPos property
You can use the beatPos property to send a MIDI event at a specific beat position. In
the following example, a note off event is sent a beat later than the beat position of the
corresponding note on event.
Note: You can also use the event.sendAtBeat(pos) method to send an event at a specific
beat position. The advantage of using the beatPos property is that you don’t actually have
to send an event; you can simply use the property to retrieve the exact beat position of an
event.