# Negative track delay and Logic Scripter - recording in vs. playing back



## KeithRamsey (Mar 6, 2022)

Logic Pro question about negative track delay

I've read on this forum about a method of having different negative delays applied to different articulations in Logic Pro. (Referring the great work done by @NoamL, @Dewdman42, and @Ihnoc ) In the method, you set a large (say, -500 ms) negative delay on the track, and then have each articulation get a different positive compensatory delay in the script. So long strings would get, say, 350 ms, to result in a -150 ms negative delay, or short strings might get 450 ms, to result in a -50 ms negative delay.

My question: How does it work when you're actually playing in the part? It seems to me that when playing in, you would hear the compensatory delay but not the negative track delay-- and you'd hear an unreasonable delay until you go to play back the track, and the track delay kicks in. For example, when you play it in, the longs strings would sound 350ms later, and the shorts 450ms later, unless you were to bypass the plugin each time you record.

How do people deal with this issue? Do you just ignore the delay it as you're performing the part, seeing as the point is to get to a quantized part in the midi region?

Or is there a way to have the script only work when you're playing back the track from the sequencer, and not when recording it in?

Thanks!


----------



## Dewdman42 (Mar 6, 2022)

The scripts I did have a way that one midi channel can be designated as the live channel and be disabled from the delay process


----------



## KeithRamsey (Mar 6, 2022)

Dewdman42 said:


> The scripts I did have a way that one midi channel can be designated as the live channel and be disabled from the delay process


OK, thanks!


----------



## Dewdman42 (Mar 6, 2022)

I am also working on a version of this script for BlueCatAudio PlugNScript which should be ready in a few days with any luck. This version would work in all the other DAW's.


----------



## KeithRamsey (Mar 8, 2022)

Dewdman42 said:


> The scripts I did have a way that one midi channel can be designated as the live channel and be disabled from the delay process


I've been trying out ArtAlignGui, but the RecordThru feature doesn't seem to be working at the moment. Even when it's checked, all the midi channels still have the delay.


----------



## Dewdman42 (Mar 8, 2022)

Thanks for reporting that. Grab the latest version, which includes fix:

https://gitlab.com/dewdman42/artalign/-/tree/master/LpScripter


----------



## KeithRamsey (Mar 8, 2022)

Dewdman42 said:


> Thanks for reporting that. Grab the latest version, which includes fix:
> 
> https://gitlab.com/dewdman42/artalign/-/tree/master/LpScripter


Awesome!!! Thanks!


----------



## sathyva (Mar 9, 2022)

Dewdman42 said:


> I am also working on a version of this script for BlueCatAudio PlugNScript which should be ready in a few days with any luck. This version would work in all the other DAW's.


Wow !!! Would love to see this script in action in Cubase !


----------



## KeithRamsey (Mar 9, 2022)

Dewdman42 said:


> Thanks for reporting that. Grab the latest version, which includes fix:
> 
> https://gitlab.com/dewdman42/artalign/-/tree/master/LpScripter


TLDR: the new script only works on port 1.

------

I'm trying out this new script, and the passthrough works, and the script itself works when I'm working with an AU2 track. But when I use an AU3 instance of VEP, it seems to only work on Port 1.

when using an AU3 instance of VEP:
- the interface will only let me set options for port 1. The menu only gives the options "1" or "Select port..."
-all the instruments going through other ports are silent when the plugin is enabled

(Incidentally, when I use both this ArtAlignGui script and your Channelizer script at the same time, the Channelizer can and should go above the ArtAlignGui, script, right? (so that it provides the right channels for the ArtAlignGui script?))

Here's my Logic file, if that's helpful to you:








Zásilka služby Úschovna ke stažení


Posílejte soubory do 30 GB snadno, bezpečně a neomezenou rychlostí. Zdarma a bez registrace.




www.uschovna.cz





Thanks!


----------



## KeithRamsey (Mar 9, 2022)

Here's some jive from Scripter when I play notes on port 2:

-----------
***Creating a new MIDI engine with script***

Evaluating MIDI-processing script...


Script evaluated successfully!


Parameters were rearranged.


Parameters were rearranged.


Exception calling HandleMIDI() function:


[JS Exception] TypeError: undefined is not an object (evaluating 'idxFinder[this.port][this.channel]') line:147


Exception calling HandleMIDI() function:


[JS Exception] TypeError: undefined is not an object (evaluating 'idxFinder[this.port][this.channel]') line:147


>


----------



## KeithRamsey (Mar 9, 2022)

I changed the const variable at the beginning for MAXPORTS to 48 and that seemed to fix it.


----------



## Dewdman42 (Mar 9, 2022)

KeithRamsey said:


> TLDR: the new script only works on port 1.
> 
> ------
> 
> I'm trying out this new script, and the passthrough works, and the script itself works when I'm working with an AU2 track. But when I use an AU3 instance of VEP, it seems to only work on Port 1.



It is by that way on purpose, but you can easily change it to more ports if you want. You need to edit the line near the top of the script that says



```
MAXPORTS=1;
```


change it to say MAXPORTS=48 if you want the max ports supported by VePro. The bug only happened when I set it to 1, so if you had changed it to 48 to begin with the record thru would have also worked fine.

I have set this up as one port because the vast majority of people are only using one port so it keeps it simple, but you can change the line for more ports.

_(EDIT, I see that you already figured this out. )_



KeithRamsey said:


> (Incidentally, when I use both this ArtAlignGui script and your Channelizer script at the same time, the Channelizer can and should go above the ArtAlignGui, script, right? (so that it provides the right channels for the ArtAlignGui script?))



yes


----------



## KeithRamsey (Mar 9, 2022)

Dewdman42 said:


> It is by that way on purpose, but you can easily change it to more ports if you want. You need to edit the line near the top of the script that says
> 
> 
> 
> ...


Aha, awesome. Thanks again!


----------



## KeithRamsey (Mar 11, 2022)

Hi @Dewdman42 - I was wondering if you might consider adding a mode to this script that also moves forward note offs (and perhaps CC data)? I understand that in theory, the only part we want to modify is the initial attack-- but in practice, when you have a lot of repeated notes, it creates some weird issues if the ends of the note offs stay in the same place (overlapping notes and such.) It'd be nice to have a mode that just emulates the standard negative track delay (but on the channel by channel basis that your script offers.)

just a thought after playing around with your script for the afternoon! Thanks!


----------



## Dewdman42 (Mar 11, 2022)

At least one of the scripts had a mode for that called simple mode. I’ll look tonight, which script are you using ?


----------



## Dewdman42 (Mar 11, 2022)

The dilemma there is that your notes will be ending early in some cases but on the other hand I hear you without that you can end up with legato where you didn’t want legato or if the instrument is monophonic could be problematic. Really we should make sure it’s automatable so that you can switch that mode on the fly


----------



## KeithRamsey (Mar 11, 2022)

Dewdman42 said:


> At least one of the scripts had a mode for that called simple mode. I’ll look tonight, which script are you using ?


ArtAlignGui


----------



## KeithRamsey (Mar 11, 2022)

Dewdman42 said:


> At least one of the scripts had a mode for that called simple mode. I’ll look tonight, which script are you using ?


I see that simple correction mode, but I didn’t realize that that’s what it does! Does it send note offs as well as midi cc?


----------



## KeithRamsey (Mar 11, 2022)

Just playing around with it, and I can see that it does!  This is great. Thank you!!! 


KeithRamsey said:


> I see that simple correction mode, but I didn’t realize that that’s what it does! Does it send note offs as well as midi cc?


----------



## Dewdman42 (Mar 11, 2022)

docs are here: https://gitlab.com/dewdman42/artalign/-/wikis/ArtAlignGui.js


----------



## Dewdman42 (Mar 11, 2022)

I should probably change the name of that checkbox so that its more obvious.

Note that the simple correction mode checkbox can be automated in an automation lane in case you want to switch back and forth dynamically. With simple correction mode, all your notes will be ending their sustain earlier then they appear on the piano roll. Lots of times it doesn't matter for shorts, etc.. But for sustained sounds..then it might matter.

The only reason to really have the notes terminate early is to avoid accidentally getting legato overlaps. what kinds of problems were you having with notes not being ended early?


----------



## KeithRamsey (Mar 11, 2022)

Dewdman42 said:


> docs are here: https://gitlab.com/dewdman42/artalign/-/wikis/ArtAlignGui.js


thanks


----------



## KeithRamsey (Mar 12, 2022)

Dewdman42 said:


> I should probably change the name of that checkbox so that its more obvious.
> 
> Note that the simple correction mode checkbox can be automated in an automation lane in case you want to switch back and forth dynamically. With simple correction mode, all your notes will be ending their sustain earlier then they appear on the piano roll. Lots of times it doesn't matter for shorts, etc.. But for sustained sounds..then it might matter.
> 
> The only reason to really have the notes terminate early is to avoid accidentally getting legato overlaps. what kinds of problems were you having with notes not being ended early?


I'm making a mockup of John Williams' Superman march -- at the beginning with the rhythmic riff of repeated notes playing eighths and 16ths. There was some dropping of the sound that went away when I turned on the simple mode.


----------



## KeithRamsey (Mar 12, 2022)

KeithRamsey said:


> I'm making a mockup of John Williams' Superman march -- at the beginning with the rhythmic riff of repeated notes playing eighths and 16ths. There was some dropping of the sound that went away when I turned on the simple mode.


I looked at the sequence - and I'm not sure it's because the note ons were coming before the preceding note off-- technically, there was a gap in time even without simple mode. So I can't say for sure why it was a problem.

But I figure the simple mode is useful in that it isn't changing the relative timing of the different events in the region. (So what you see is what you get, only earlier.)


----------



## Dewdman42 (Mar 12, 2022)

The NoteOns need to be TRIGGERED early so that they sound on the grid due to very slow attack transients that are inconsistent between articulations. Real players also start moving their hands ahead of the beat instinctively so that the actual sound will not start late. 

You want the actual sound to be on the grid, not late, not early.

The end of the note should also sound on the grid, what you see is what you hear but if you really wanted to get technical you’d need to use a completely separate latency compensation for each articulation release time which may not at all match the latency of the attack and would also vary between different articulations.

Nobody has really been addressing this or thinking about it in such detail, and who wants to? Too much to think about. But I think in general it’s easier to play in parts and release early instinctively then it is to start thr attack early.

If simple mode tends to sound better or right in some way then by all means use that. I think when dealing with some libraries that have really long attack latency such as legatos and portamemtos you may find that simple mode will be starting the release too soon for the last note of a legato phrase.


----------



## Kent (Jun 11, 2022)

@Dewdman42 I've finally been able to devote some time to all this, and I wonder: 

Since the Environment really has no concept of MIDI FX plug-ins (at least as far as I can tell—it seems to assume they are the same plug-in as the loaded instrument plug-in, which is annoying), shouldn't there a way to toggle Scripter's behaviors from within Scripter itself via a MIDI control value that it's listening for?

Something like (excuse my rusty pseudo-JS):


```
controlCC = 99 // for example


if (controlCC) {
    if (LSB = 0) {
        // pass all other MIDI through without processing
    };

    if (LSB = 1) {
        // do the thing
    };

    if (LSB = n) {
        // maybe some other option
    };
);
```


----------



## Dewdman42 (Jun 11, 2022)

I'm not understanding what you're trying to do or why? 

But yes, the environment does not support any midifx plugins

And yes its certainly possible in script to listen for various midi events to come in and control its behavior that way, but its a little more involved then using normal automation. Most plugins use automation, and then if you want to use midi to control the automation, you use smart controls to affect the automation. Actual midi controlled FX plugins are very rare. But anyway, its certainly possible to do it in Scripter, but its a bit more involved.


----------



## Kent (Jun 12, 2022)

Dewdman42 said:


> I'm not understanding what you're trying to do or why?
> 
> But yes, the environment does not support any midifx plugins
> 
> And yes its certainly possible in script to listen for various midi events to come in and control its behavior that way, but its a little more involved then using normal automation. Most plugins use automation, and then if you want to use midi to control the automation, you use smart controls to affect the automation. Actual midi controlled FX plugins are very rare. But anyway, its certainly possible to do it in Scripter, but its a bit more involved.


Basically I am trying to use ArtAlign (JSON) to control the lookahead behaviors of VEP. Using Smart Controls to toggle the enable/bypass of the Scripter plug-in, however, causes some associated MIDI CC automation data I am trying to send to the VEP instance (for enabling/disabling Latency Fixer instances) to get lost... but only when disabling the Scripter plug-in. (In other words, those Latency Fixers receive all 'enable' signals, but no 'bypass' signals).

In my mind, the most elegant solution would be to have an ArtAlign that is in a Scripter that is always _enabled_, and the scripted behaviors would instead be toggled rather than the plug-in state itself.

So, something like this:







So we'd have these rules:

1. Scripter plug-in is always on.
2. Smart Controls toggle the state of the 'Compensation Enabled' checkbox.
3. If checkbox is checked, MIDI enters the preset latency compensations per port/channel etc. as defined in JSON.
4. If checkbox is empty, MIDI passes through Scripter as if Scripter did not exist.


----------



## Dewdman42 (Jun 12, 2022)

Kent said:


> Basically I am trying to use ArtAlign (JSON) to control the lookahead behaviors of VEP.



First of all ArtAlign doesn't change the lookahead behavior of VePro. It simply adds a different amount of latency to each note depending on how you have the JSON configured.




Kent said:


> Using Smart Controls to toggle the enable/bypass of the Scripter plug-in, however, causes some associated MIDI CC automation data I am trying to send to the VEP instance (for enabling/disabling Latency Fixer instances) to get lost...



Why are you enabling and disabling it? 



Kent said:


> but only when disabling the Scripter plug-in. (In other words, those Latency Fixers receive all 'enable' signals, but no 'bypass' signals).



Why would latency fixer be receiving the same automation to enable disable? that doesn't make sense.




Kent said:


> In my mind, the most elegant solution would be to have an ArtAlign that is in a Scripter that is always _enabled_, and the scripted behaviors would instead be toggled rather than the plug-in state itself.




again, I don't really understand exactly what you're trying to do. The only reason for that checkbox is not to enable it and disable it dynamically while playing. its so that you can turn it if when you want to play in a part with your midi controller, because otherwise a lot of delay will be added. its easier to play in the part with the delay minimized.

It doesn't sound you are using the script properly. please read the wiki docs careful to understand it.

I will not have any time to work on these scripts any time soon, but if you would like to contribute some ideas please post an issue request through the gitlab website.

you are of course welcome to take the script and tweak it to your heart's content if you want to dynamically enable/disable its behavior during playback but I'm not sure why you would want to do that.


----------



## Kent (Jun 12, 2022)

Dewdman42 said:


> First of all ArtAlign doesn't change the lookahead behavior of VePro. It simply adds a different amount of latency to each note depending on how you have the JSON configured.


Right, it compensates for whatever Latency Fixer values are being fed.



Dewdman42 said:


> Why are you enabling and disabling it?


I'm using it as part of a whole modal template setup where I have 1 of 2 states true — a low-latency tracking mode and a high-latency mixing mode. It shouldn't be active while I'm tracking, but it should be active while I'm mixing.



Dewdman42 said:


> Why would latency fixer be receiving the same automation to enable disable? that doesn't make sense.


It's not—it's receiving a separate control (CC33), but when Scripter plug-ins toggle (as part of a Smart Control/Summing Stack setup) they block simultaneous CC messages on disable.


Dewdman42 said:


> again, I don't really understand exactly what you're trying to do. The only reason for that checkbox is not to enable it and disable it dynamically while playing. its so that you can turn it if when you want to play in a part with your midi controller, because otherwise a lot of delay will be added. its easier to play in the part with the delay minimized.


Right, it's a modality, not something to be tweaked live.



Dewdman42 said:


> It doesn't sound you are using the script properly. please read the wiki docs careful to understand it.


I have, but it (+ a delay compensation plug-in) does not behave properly if used in the way specified in the wiki. That combo *does* behave properly when the delay compensation plug-in is hosted within VEP instead of in Logic. It works fine when drawing in automation to achieve the two toggles (that is: Latency Fixer on/off; ArtAlign active/inactive). 

However, I don't want to draw in automation to automate this (as this shouldn't be a dynamic automation, nor should it be tied to anything in the playback/rendering, but should simply be a modal state), so the only way to accomplish such a change without drawing in automation is to have a toggle button that sends a control (or multiple controls) at the same time.

But without drawn in automation, the only way to control both things simultaneously is to send it simultaneously...which is impossible when disabling Scripter blocks MIDI thru at that moment.



Dewdman42 said:


> I will not have any time to work on these scripts any time soon, but if you would like to contribute some ideas please post an issue request through the gitlab website.
> 
> you are of course welcome to take the script and tweak it to your heart's content if you want to dynamically enable/disable its behavior during playback but I'm not sure why you would want to do that.



Thankfully, that is not what I am trying to do.


----------



## Kent (Jun 12, 2022)

Thinking outside the box...

The 'Record' track (channel-port) doesn't care whether or not Scripter is engaged or bypassed, so it acts as a bridge through the whole plug-in state toggle process.

It's not pretty, but it works!


----------



## Dewdman42 (Jun 12, 2022)

Kent said:


> I have, but it (+ a delay compensation plug-in) does not behave properly if used in the way specified in the wiki. That combo *does* behave properly when the delay compensation plug-in is hosted within VEP instead of in Logic.


That's why the first line of the wiki says "its still under development". Sorry but I will not be able to spend much or any time working on these scripts any time soon, as I have moved on to DP, which has latency compensation built in.

What I can say about the latency fixer only working inside VePro, must be because VePro itself imposes more latency then the Scripter script does. Not sure, Apple has been messing around a lot lately with PDC related bugs so who knows. but yea...if you use the midi negative delay that should work better...or use it inside VePro as you already figured out. I don' have time to investigate it or update the wiki anytime in the near future. Please report bugs on the gitlab issue tracker. Thanks.

Good luck.


----------

