10.6

Table Of Contents
212Logic Pro Effects
Tutorial script 15: Control Plug-ins
In Logic Pro, you can create user-definable MIDI CC messages, or you can control
plug-in parameters. TargetEvent reads the parameter to be modified from a menu where
the user can select a destination MIDI CC. Alternately, you can use the Learn Plug-In
Parameter feature to assign any plug-in parameter inserted after (below) Scripter in
the same channel strip. The chosen destination is saved with the plug-in setting.
Text following /* shows comments that explain the JavaScript code.
Tip: You can use the JavaScript “new” keyword to generate a new instance of an
Event object of any type.
TargetEvent properties:
TargetEvent.target(string) /* Name of target menu entry */
TargetEvent.value(float) /* Value of set Target from 0.0 to 1.0 */
The code shown below controls any plug-in parameter with the modwheel. To test the
function in Tutorial script 15, insert any plug-in or software instrument on the same
channel and run the script. Choose Learn plug-in parameter in the menu, then click
any plug-in parameter to control it with the modwheel.
To create a menu for the modwheel target, name the menu entry and set it to a
“target” type.
var PluginParameters = [
/* parameter 0 */
{
name:"Modwheel Target",
type:"target"
}];
HandleMIDI is called every time Scripter receives a MIDI event in Tutorial script 15.
The code shown below remaps the modulation wheel to the target chosen in the menu.
function HandleMIDI(incomingEvent)
{
/* remap modulation to target selected in menu and
check for incoming CC event with number 1 (Modwheel) */
if ((incomingEvent instanceof ControlChange) && (incomingEvent.number == 1))
{
var newEvent = new TargetEvent(); /* create new Target event */
newEvent.target = "Modwheel Target"; /* name the menu entry to be used by this event
*/
newEvent.value = incomingEvent.value / 127; /* rescale from 0..127 to 0.0...1.0 */
newEvent.send(); /* send the event */
} else
{
/* send all other events */