Jump to content

Help with a script please


FredBegin

Recommended Posts

I have limited knowledge in programming.

 

My goal is:

When playing on midi channel 1, remap channel 1 NoteOn, NoteOff and ControlChange to channel 1 to 4 simultaneously.

When playing on midi channel 5, remap channel 5 NoteOn, NoteOff and ControlChange to channel 5 to 8 simultaneously.

 

The first part works

The second doesn't.

Its the first time i'm using the ''while'' condition. I don't know how to set the midi channel range from 5 to 8

 

Thanks for any help!

 

Fred

var inst1 = 1;
var inst2 = 5

function HandleMIDI(event) {

  if (event instanceof NoteOn && event.channel == inst1||
  			event instanceof NoteOff && event.channel == inst1 ||
  			event instanceof ControlChange && event.channel == inst1)	{
    
      var i = 1;
      while (i <= 4) {
         event.channel = i;
         event.send();
         i++
         }
         }
         
   
     else if (event instanceof NoteOn && event.channel == inst2||
  			event instanceof NoteOff && event.channel == inst2 ||
  			event instanceof ControlChange && event.channel == inst2)	{
    
      var i = 1;
      while (i <= 8) {//here's where i'm stucked. Should be set to send on channels 5 to 8
         event.channel = i;
         event.send();
         i++}   
  
      
   }
   else {event.send()}




    event.send(); //Pass MIDI events through the plug-in.
}

Link to comment
Share on other sites

I'm a coder, but not used the scripting in Logic yet, but looking from a code perspective you should be able to just set the starting channel (i.e. 5) so:-

 

      var i = 5;
      while (i <= 8) {....etc

 

You could also use a for loop to specify a range, but this should work providing event.channel/event.send is correct.  

 

For..loop would be something more like this:-

 

for (i = 5; i <= 8; i++) { 
         event.channel = i;
         event.send();
}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...