Old 05-20-2019, 09:24 AM   #1
zappazapper
Human being with feelings
 
zappazapper's Avatar
 
Join Date: Feb 2015
Posts: 196
Default Request modification (ReaScript)

There is a plugin called "Stereo Alignment Delay" written by Geraintluff that I want to make modifications to. I reached out to him with what I was looking for and he said that the modifications would require ReaScript, which is not his strong suit, according to him. He's given me permission to find somebody that can help me make the necessary modifications.

A brief description -

"Stereo Alignment Delay" is a phase alignment plugin in the style of Waves InPhase or SoundRadix Auto-Align. It measures the phase correlation between two signals and finds an ideal delay time and polarity to apply to one of the signals. It can be used on a stereo signal on one track or it can be used to correlate two separate tracks as it has the ability to send the signal from one instance of the plugin on one track to another instance on another track (the result of my original request and Geraintluff's gracious assistance).

The modification I'm looking for is the result of a particular problem I'm having with a mixing project I'm currently working on. 7 live shows of the same band, using the same equipment, but on different stages in different rooms. The individual signals themselves are similar enough from show to show to be able to mix them all in the same project, using the same mixer settings and effects, at least as a starting point, except that the "Stereo Alignment Delay" plugin has to be reset from show to show because of slightly different microphone placement with respect to each other. Because these are 3 hour shows, 20+ tracks each, applying/rendering the effect to the items takes a very long time and is not a realistic or very sophisticated solution. Using automation is also not an ideal solution.

What I was thinking is that since all the plugin is doing, once it is done measuring the correlation, is delaying the signal and possibly flipping the polarity, there's no reason why that necessarily has to be applied to the signal as a rendered effect, since nudging can handle the delay and polarity can be flipped on the item itself (Item Settings > Invert Phase).

So I would like to add a button on the effect called "Apply delay and polarity to selected item and reset", which would apply the delay time and polarity determined by the measured correlation to the item itself using Nudge and Invert Phase, and then reset those values on the plugin.

Can anybody help me with this? Geraintluff says he is willing to offer any help he can in terms of the JSFX stuff, but it should be pretty straight forward to anybody with ReaScript experience, which is not me either ��

Thanks in advance for any help ��

Last edited by zappazapper; 05-20-2019 at 09:32 AM.
zappazapper is offline   Reply With Quote
Old 05-21-2019, 07:36 AM   #2
geraintluff
Human being with feelings
 
geraintluff's Avatar
 
Join Date: Nov 2009
Location: mostly inside my own head
Posts: 323
Default

For clarification:

My guess is this requires a custom action. This action would need to:
  • determine the relevant Stereo Alignment Delay instance (e.g. which one is in the foreground - whatever's possible).
  • take the slider values from JSFX. Sliders 1/2 are left/right delays (in ms - may be negative), and sliders 6/7 are left/right polarity switches (0 normal, 1 inverted). For this, it's probably fine to assume both channels are the same.
  • move and optionally invert phase for all items currently selected
  • reset the slider values (1/2/6/7) to 0 in the effect instance
I don't believe this should need any modification to the JSFX, but I'm happy to help if it does.
geraintluff is offline   Reply With Quote
Old 05-21-2019, 11:51 AM   #3
geraintluff
Human being with feelings
 
geraintluff's Avatar
 
Join Date: Nov 2009
Location: mostly inside my own head
Posts: 323
Default

You know what, I've had a bash at it.

Here's a ReaScript action. When you run the action, all selected items will (hopefully) be shifted/inverted according to the Stereo Alignment Delay instance on their track (based on left channel).

It currently only works if Stereo Alignment Delay is on the same track as the item, not any parent tracks. If you want it to search parent tracks as well, I can add that in.

WARNING - there didn't seem to be a way to invert the items. (It's in the item settings, just not the API). So what I've done instead is set it to a negative volume. This might cause some subtle issues, but it was the only way I found to make it work.

Geraint
Attached Files
File Type: lua apply-alignment-delay.lua (2.1 KB, 34 views)
geraintluff is offline   Reply With Quote
Old 05-21-2019, 03:48 PM   #4
zappazapper
Human being with feelings
 
zappazapper's Avatar
 
Join Date: Feb 2015
Posts: 196
Default

Quote:
You know what, I've had a bash at it.

Here's a ReaScript action. When you run the action, all selected items will (hopefully) be shifted/inverted according to the Stereo Alignment Delay instance on their track (based on left channel).
oh, so it's not something that can be like a button on the plugin... fair enough, i'll put it in the toolbar or whatever...

Quote:
It currently only works if Stereo Alignment Delay is on the same track as the item, not any parent tracks. If you want it to search parent tracks as well, I can add that in.

in my project i'm disabling all the master/parent sends of all the tracks with items in them (i call them "tape" tracks) and sending them to a separate group of "mixer" tracks (it just seems easier to keep track of all the sidechain routing), and the plugin is on the "tape" tracks and there are no folders in the "tape" tracks, so each item is only ever going through one instance of the plugin... so not necessary for this particular application but i can see where it would be useful... i can also see where it could lead to problems, because then does the parent track's plugin get reset? and then what happens to the other child tracks?

Quote:
WARNING - there didn't seem to be a way to invert the items. (It's in the item settings, just not the API). So what I've done instead is set it to a negative volume. This might cause some subtle issues, but it was the only way I found to make it work.
fair enough... i'll test it out and let you know...

thanks again...
zappazapper is offline   Reply With Quote
Old 05-22-2019, 04:10 AM   #5
geraintluff
Human being with feelings
 
geraintluff's Avatar
 
Join Date: Nov 2009
Location: mostly inside my own head
Posts: 323
Default

Quote:
Originally Posted by zappazapper View Post
oh, so it's not something that can be like a button on the plugin...
Yeah, JSFX can't really perform modifications to the project - that's a ReaScript thing.
geraintluff is offline   Reply With Quote
Old 05-22-2019, 07:45 AM   #6
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: England
Posts: 304
Default

Quote:
Originally Posted by geraintluff View Post
WARNING - there didn't seem to be a way to invert the items. (It's in the item settings, just not the API). So what I've done instead is set it to a negative volume. This might cause some subtle issues, but it was the only way I found to make it work.
Geraint
This script, plugin, and post really interested me after having read it, so I've been keeping tabs on it.

Wouldn't it be possible to use reaper.SetMediaTrackInfo_Value(track*, "B_PHASE" , number newvalue*) and send individual items to new tracks, flip their polarity, render them, and then send back to a single track?
Dafarkias is offline   Reply With Quote
Old 05-22-2019, 07:55 AM   #7
zappazapper
Human being with feelings
 
zappazapper's Avatar
 
Join Date: Feb 2015
Posts: 196
Default

Quote:
Originally Posted by Dafarkias View Post
This script, plugin, and post really interested me after having read it, so I've been keeping tabs on it.

Wouldn't it be possible to use reaper.SetMediaTrackInfo_Value(track*, "B_PHASE" , number newvalue*) and send individual items to new tracks, flip their polarity, render them, and then send back to a single track?
Rendering is the problem. 22 tracks at 3 hours a piece x 7 shows... Trying to find something that doesn't take hours to process...
zappazapper is offline   Reply With Quote
Old 05-22-2019, 08:36 AM   #8
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: England
Posts: 304
Default

Quote:
Originally Posted by zappazapper View Post
Rendering is the problem. 22 tracks at 3 hours a piece x 7 shows... Trying to find something that doesn't take hours to process...
Oops I looked at the code, and I don't think it would be necessary to send individual items to separate tracks for render at all.

Still, the API function I mentioned in my last post would invert phase for a specific track..
Dafarkias is offline   Reply With Quote
Old 11-12-2019, 12:31 PM   #9
zappazapper
Human being with feelings
 
zappazapper's Avatar
 
Join Date: Feb 2015
Posts: 196
Default

i can't believe it's taken me this long to really take a look at this...

maybe you can explain something for me... when i apply the plugin settings to the items, it sounds as though it's working but i'm not seeing any change in the position of the items... it's obviously doing something because like you said, if the plugin is set to invert the polarity, it applies a negative volume which makes the item change color, but i'm not seeing where the content of the item has moved, at least not visually...
zappazapper is offline   Reply With Quote
Old 11-13-2019, 02:58 PM   #10
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: England
Posts: 304
Default

I still think this script & idea is really cool.

It wouldn't be difficult to add a code into the script informing you the amount in which the items have been adjusted..
Dafarkias is offline   Reply With Quote
Old 11-13-2019, 04:56 PM   #11
zappazapper
Human being with feelings
 
zappazapper's Avatar
 
Join Date: Feb 2015
Posts: 196
Default

actually i figured it out... i had my item positioned at 1.1.00 and tried applying a negative delay value... since it had no room to move, it stayed where it was...

Quote:
Originally Posted by Dafarkias View Post
It wouldn't be difficult to add a code into the script informing you the amount in which the items have been adjusted..
that might be useful... maybe the same way that it tells you if the playrate of the item is not the same as the master playrate, like right on the item header... i don't know if that's possible...

also, is there a case to be made that maybe it's the contents of the item that should move, and not the item itself? does that solve the problem of not being able to apply a negative delay value to an item positioned at 1.1.00?
zappazapper is offline   Reply With Quote
Old 11-13-2019, 11:24 PM   #12
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: England
Posts: 304
Default

Quote:
Originally Posted by zappazapper View Post
that might be useful... maybe the same way that it tells you if the playrate of the item is not the same as the master playrate, like right on the item header... i don't know if that's possible...
I was more along the lines taking about a pop-up window after you've ran the script, that informs you which item have moved, and by how much.


Quote:
Originally Posted by zappazapper View Post
...does that solve the problem of not being able to apply a negative delay value to an item positioned at 1.1.00?
That's solvable as well.

If you give me a day or two I'll try and make a few optimizations to the Lua script...

Last edited by Dafarkias; 11-13-2019 at 11:31 PM.
Dafarkias is offline   Reply With Quote
Old 11-14-2019, 03:41 AM   #13
zappazapper
Human being with feelings
 
zappazapper's Avatar
 
Join Date: Feb 2015
Posts: 196
Default

Quote:
Originally Posted by Dafarkias View Post
I was more along the lines taking about a pop-up window after you've ran the script, that informs you which item have moved, and by how much.
I see... Ya, I dunno... Something like a popup ends up just being an extra point and click in your workflow... And I don't know how useful the information is immediately after running the script because you just saw the same information on the plugin... It would only be useful if the information was available indefinitely... And even then I don't know how useful it really is...

Quote:
If you give me a day or two I'll try and make a few optimizations to the Lua script...
I'd appreciate that... I'd like to see how moving the contents of the item works vs the item itself... And if there's a better way to invert the polarity... Thanks for your assistance 👍
zappazapper is offline   Reply With Quote
Old 11-14-2019, 03:52 AM   #14
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: England
Posts: 304
Default

Quote:
Originally Posted by zappazapper View Post
I'd appreciate that... I'd like to see how moving the contents of the item works vs the item itself... And if there's a better way to invert the polarity... Thanks for your assistance 👍
That's what I'm thinking as well. I think there's actually a dedicated API function that can invert polarity..

My rationale behind the pop-up window display, was simply because I thought you were wanting a confirmation that the item(s) had been adjusted, and preferably, by how much. But if that's not an issue to you I don't need to add that in..
Dafarkias is offline   Reply With Quote
Old 11-14-2019, 03:57 AM   #15
zappazapper
Human being with feelings
 
zappazapper's Avatar
 
Join Date: Feb 2015
Posts: 196
Default

Quote:
Originally Posted by Dafarkias View Post
My rationale behind the pop-up window display, was simply because I thought you were wanting a confirmation that the item(s) had been adjusted, and preferably, by how much. But if that's not an issue to you I don't need to add that in..
Ya I think I figured out what was going on there... And maybe that info would be useful in some way further along in the workflow but I think the only good place to put it would be the item header, which I doubt is possible...
zappazapper is offline   Reply With Quote
Old 11-14-2019, 05:08 AM   #16
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: England
Posts: 304
Default

It's possible. That's a little bit out of my knowledge base, but I can do a little poking around in the API when I go to work on these mods to see if that is an option
Dafarkias is offline   Reply With Quote
Old 11-14-2019, 09:18 AM   #17
zappazapper
Human being with feelings
 
zappazapper's Avatar
 
Join Date: Feb 2015
Posts: 196
Default

Quote:
Originally Posted by Dafarkias View Post
It's possible. That's a little bit out of my knowledge base, but I can do a little poking around in the API when I go to work on these mods to see if that is an option
Cool thanks
zappazapper is offline   Reply With Quote
Old 11-14-2019, 01:47 PM   #18
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: England
Posts: 304
Default

It would be possible to add onto the actual title of the media item (in this case, active take) the actual amount adjusted by the script...

For example:

Take name before script: ACG Guitar Room

Take name after script: ACG Guitar Room (+.00137)

If that's what you meant when you said "I think the only good place to put it would be the item header" I apologize, I'm a bit thick :P
Dafarkias is offline   Reply With Quote
Old 11-14-2019, 01:56 PM   #19
zappazapper
Human being with feelings
 
zappazapper's Avatar
 
Join Date: Feb 2015
Posts: 196
Default

Quote:
Originally Posted by Dafarkias View Post
It would be possible to add onto the actual title of the media item (in this case, active take) the actual amount adjusted by the script...

For example:

Take name before script: ACG Guitar Room

Take name after script: ACG Guitar Room (+.00137)

If that's what you meant when you said "I think the only good place to put it would be the item header" I apologize, I'm a bit thick :P
Ya that's exactly what I mean...

Can it be expressed in both seconds and samples? Like "+.00136s/60smpls"?

Also, it should be cumulative, as it's possible that the alignment could be adjusted multiple times, and really what the number should represent is how much adjustment would be needed to get it back to its original position.
zappazapper is offline   Reply With Quote
Old 11-15-2019, 12:51 AM   #20
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: England
Posts: 304
Default

It could, but just so that I'm on the same page, why would you run the script multiple times on the same media item? Doesn't it adjust to the most ideal position on the first execution?
Dafarkias is offline   Reply With Quote
Old 11-15-2019, 02:25 AM   #21
zappazapper
Human being with feelings
 
zappazapper's Avatar
 
Join Date: Feb 2015
Posts: 196
Default

Quote:
Originally Posted by Dafarkias View Post
It could, but just so that I'm on the same page, why would you run the script multiple times on the same media item? Doesn't it adjust to the most ideal position on the first execution?
Yes and no. It gives you some leeway to choose settings that give high correlation but not necessarily the highest correlation. Basically, even the settings that give the highest correlation result in some comb filtering, and the effect it has on frequency content might not necessarily "sound" the best compared to other settings that give slightly less than the highest correlated settings. It's entirely possible that one would go back and remeasure and choose different settings later on in the mix process and I think it makes sense to make sure the info the script gives is still accurate in that situation.
zappazapper is offline   Reply With Quote
Old 11-15-2019, 09:09 AM   #22
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: England
Posts: 304
Default

Ahhhh.

Okay that makes perfect sense. I don't think that would be an issue, to rename the take according to its initial position variance.

I'll try and take a whack at it this weekend
Dafarkias is offline   Reply With Quote
Old 11-24-2019, 03:34 AM   #23
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: England
Posts: 304
Default

Code:
function msg(param, clr) if clr then reaper.ClearConsole() end reaper.ShowConsoleMsg(tostring(param).."\n") end function up() reaper.UpdateTimeline() reaper.UpdateArrange() end

function main()
  reaper.Undo_BeginBlock()

  -- First loop: modify the items
    for t = 1, reaper.CountSelectedTracks( 0 )
  do 
    local track = reaper.GetSelectedTrack( 0, t-1 )
    local sadEffectIndex = reaper.TrackFX_GetByName(track, "Stereo Alignment Delay", false)
    
      if sadEffectIndex >= 0 
    then
    
      local delayMsL = reaper.TrackFX_GetParam(track, sadEffectIndex, 0)
      local invertedL = reaper.TrackFX_GetParam(track, sadEffectIndex, 5)
      local offset = delayMsL*0.001

        if invertedL > 0 
      then
        local phase = reaper.GetMediaTrackInfo_Value( track, "B_PHASE" )
        if phase then reaper.SetMediaTrackInfo_Value( track, "B_PHASE", 0 ) else reaper.SetMediaTrackInfo_Value( track, "B_PHASE", 1 ) end 
      end    
      
      local tret, t_name = reaper.GetSetMediaTrackInfo_String( track, "P_NAME", "", 0 )
      if tret then local a, b = string.find(t_name, "@") if a then delayMsL = delayMsL + tonumber(string.sub(t_name, a+2)) t_name = string.sub(t_name, 1, a-2) end end 
      reaper.GetSetMediaTrackInfo_String( track, "P_NAME", t_name.." @ "..tostring(delayMsL), 1 )
    
        for m = 1, reaper.CountTrackMediaItems( track ) 
      do 
        local item = reaper.GetTrackMediaItem( track, m-1 )
        local src = reaper.GetMediaItemTakeInfo_Value( reaper.GetActiveTake( item ), "D_STARTOFFS" )
        src = src - offset
        reaper.SetMediaItemTakeInfo_Value( reaper.GetActiveTake( item ), "D_STARTOFFS", src )    
      end
      reaper.TrackFX_SetParam(track, sadEffectIndex, 0, 0)
      reaper.TrackFX_SetParam(track, sadEffectIndex, 5, 0)
    end
  end
  
  up()
  reaper.Undo_EndBlock("apply Stereo Alignment Delay to items", -1)
end

main()
I've had a smack at it.

Basically, you just select whatever tracks you want to be 'processed' and run the script. The adjusted amount will be embedded in the track name.

This script assumes two things:
1.) You're using Geraint's Stereo Alignment effect in Send/Receive mode. (this script won't work properly if you're using it in regular mode!)*
2.) The adjusted amount needs to be in the 'L' channel slider. I believe that this is standard practice, but I'm not sure. You can manually adjust though, if needed.
*If you need to align the phase of a stereo item, you will need to 'split' the item to separate tracks first using an action similar to "Item: Explode multichannel audio or MIDI to new one-channel items"

Last edited by Dafarkias; 11-24-2019 at 05:22 AM.
Dafarkias is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 04:32 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.