Jump to content

scripter to environment


Recommended Posts

I've a channel strip with a scripter plugin plugged in.

 

I'm trying this simple code:

 

 function HandleMIDI(event) {
	event.send();
	event.trace();

	if (
		event instanceof ControlChange &&
		1 == event.channel && 
		64 == event.number 
		){
		event.number = 65;
	}

	event.trace();

}

 

 

And it works inside the console log of the script editor, but if I attach a monitor to the channel strip, the data is unchanged (I don't have a midi event with number 65 in my environment).

I'm looking for a way to get those javascripted midi changes out to the environment, this would be SOOOO useful.

Has anybody done that yet?

Link to comment
Share on other sites

Hi,

 

And it works inside the console log of the script editor, but if I attach a monitor to the channel strip, the data is unchanged

You need to send the event after reassigning its number to 65 (the trace method will only print to the console and is optional):

 

 function HandleMIDI(event) {
     if (event instanceof ControlChange &&
         event.channel == 1 &&
         event.number == 64) {
         event.number = 65;
         event.send();
         event.trace();
     }
 }

 

 

(I don't have a midi event with number 65 in my environment).

I'm looking for a way to get those javascripted midi changes out to the environment, this would be SOOOO useful.

Not sure why you're approaching it this way/don't know what your goal is, but if you want work with this data in your environment it would probably be a better idea to transform it directly in your environment (using a transformer object). If for some reason you need to use the Scripter plugin for this, you'd have to use the external instrument plug-in and the IAC driver to output the data and have it loop back into Logic and the environment.

J.

Link to comment
Share on other sites

  • 2 weeks later...

If you want to be sure that all MIDI data passes through the Scripter, and also changes cc64 to cc65, write it like this (I use "e" instead of "event"):

 

function HandleMIDI(e) {

  if (e instanceof ControlChange && e.channel == 1 && e.number == 64) {

  e.number = 65;

  }

  e.send();

  e.trace();

 }

 

And if the source of your incoming MIDI is always on channel 1, there's no need to test for the MIDI channel, thus simplifying the code.

 

function HandleMIDI(e) {

    if (e instanceof ControlChange && e.number == 64) {

    e.number = 65;

    }

e.send();

e.trace();

}

Link to comment
Share on other sites

Yeah, there's definitely no need to be so verbose and it's also good idea to let other MIDI events pass through (unless you don't want them to reach the instrument for some reason).

 

Here's another variant using the ternary operator:

 

 

function HandleMIDI(e) {
    e instanceof ControlChange && e.number == 64 ? 
    e.number = 65 : 
    e.send(), e.trace();
}

 

J.

Link to comment
Share on other sites

  • 11 months later...
I've a channel strip with a scripter plugin plugged in.

 

I'm trying this simple code:

 

 function HandleMIDI(event) {
	event.send();
	event.trace();

	if (
		event instanceof ControlChange &&
		1 == event.channel && 
		64 == event.number 
		){
		event.number = 65;
	}

	event.trace();

}

 

 

And it works inside the console log of the script editor, but if I attach a monitor to the channel strip, the data is unchanged (I don't have a midi event with number 65 in my environment).

I'm looking for a way to get those javascripted midi changes out to the environment, this would be SOOOO useful.

Has anybody done that yet?

What I have found is that midi which is created or modified within a channel strip (such as in an MFX plugin), will *NOT* exit the channel strip back out to the environment.  All midi that is created or modified within the channel strip will be consumed by the instrument and suffer end of life at that point.   I would love to be corrected or clarified about this point, but that is how I'm seeing it.

 

When you connect a wire in the environment from a channel strip to a monitor, what you will see on the monitor is any midi which is being fed to the channel strip. That midi continues along the wire to the monitor.  Also any fader and meta events which happen as a result of moving faders on the channel strip or in plugins hosted on the channel strip.  Those events will also be passed on to the environment without being eaten by the instrument.  But midi events that are generated inside any plugin in the channel strip, they will not make it past the instrument out to the environment.  LPX simply does not provide that possibility.

 

I am not sure if there is a way to convert a midi event into a fader event via script ( I don't think so), if so then it might be possible to generate fader or meta events that way and get them out to the environment...but you'd have to convert them back to midi wherever you are trying to send it to that is expecting midi.

 

I guess someone needs to write an MFX plugin in actual C++ that could convert midi events to automation events (ie fader events)...and visa versa...could be useful for getting midi out to the environment.

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...