Logic Pro X Script to control plugins using the Reaktor MIDI-AU plugin

David@Toybox

New Member
Here's a script for Logic users to control plugins using the Reaktor MIDI-AU plugin -->

Code:
// Transforms incoming MIDI Messages

function HandleMIDI(event) {
      midichannel = GetParameter("Channel");
      ccnumber = GetParameter("Input CC Number 1");
      sendeventsthru = GetParameter("Thru");
      eventccnumber = event.number;
      eventvalue = event.value;
      inputchannel = event.channel;

    if (inputchannel == midichannel){
 
    if(event instanceof ControlChange && eventccnumber==ccnumber) {

      var newEvent = new TargetEvent();               //create new Target Event
        newEvent.target = "Target 1";                 //set menu entry to be used by this event by its name
        newEvent.value = eventvalue/128;              //set the event value
        newEvent.send();                              //send the event

      }
        else{
      
        ccnumber = GetParameter("Input CC Number 2");
      
        if(event instanceof ControlChange && eventccnumber==ccnumber) {

      var newEvent = new TargetEvent();                //create new Target Event
        newEvent.target = "Target 2";                  //set menu entry to be used by this event by its name
        newEvent.value = eventvalue/128;               //set the event value
        newEvent.send();                               //send the event

      }
            else{

       ccnumber = GetParameter("Input CC Number 3");
      
        if(event instanceof ControlChange && eventccnumber==ccnumber) {

      var newEvent = new TargetEvent();                //create new Target Event
        newEvent.target = "Target 3";                  //set menu entry to be used by this event by its name
        newEvent.value = eventvalue/128;               //set the event value
        newEvent.send();                               //send the event
      }
            else{
          
        ccnumber = GetParameter("Input CC Number 4");
                          
        if(event instanceof ControlChange && eventccnumber==ccnumber) {

      var newEvent = new TargetEvent();                //create new Target Event
        newEvent.target = "Target 4";                  //set menu entry to be used by this event by its name
        newEvent.value = eventvalue/128;               //set the event value
        newEvent.send();                               //send the event
      }
            else{
        event.send();
        }
        }
        }
        }
    if (sendeventsthru){
    event.send();
    }
    }
    else event.send(); 
}

var PluginParameters =
[
{name:"Target 1", type:"target"},
{name:"Target 2", type:"target"},
{name:"Target 3", type:"target"},
{name:"Target 4", type:"target"},
{name:"Input CC Number 1", type:"lin", minValue:0, maxValue:127, numberOfSteps:127, defaultValue:1},
{name:"Input CC Number 2", type:"lin", minValue:0, maxValue:127, numberOfSteps:127, defaultValue:1},
{name:"Input CC Number 3", type:"lin", minValue:0, maxValue:127, numberOfSteps:127, defaultValue:1},
{name:"Input CC Number 4", type:"lin", minValue:0, maxValue:127, numberOfSteps:127, defaultValue:1},
{name:"Channel", type:"lin", minValue:1, maxValue:16, numberOfSteps:15, defaultValue:1},
{name:"Thru", type:"checkbox", defaultValue:0}
];
Like this (just copy and paste the script into Logic's Scripter MIDI plugin):

 
Top