Old 09-30-2020, 06:43 PM   #161
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Quote:
Originally Posted by gapalil001 View Post
thank you again! is this available for fade in/out by razor edit selection?
No. Could you explain how this would work? And maybe I can make it
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 10-01-2020, 10:54 PM   #162
Joe90
Human being with feelings
 
Join Date: Aug 2019
Posts: 853
Default Script request - Create Time Selection at Razor Edit Area

Some AWESOME stuff going on right here! I sincerely hope some of this makes into the official release, especially the envelope nudging handles . That would be killer.

I wanted to see if anyone could help with a simple script regarding Razor edit, and this seems like the place to ask -

I need a script to create a time selection at the razor edit area. Currently some actions that affect time selection also affect the razor edit area, and some don't. For the ones that don't, this script would be helpful as I can then make custom actions for all of my time selection shortcuts so they work with Razor edit areas too, as Razor edit is fast becoming my go-to tool instead of marquee/time selection.

I suppose this script could get weird if it were to be run with multiple area selections drawn at once, but I wouldn't be planning to do that. I guess if the script is run with multiple area selections then it should just start the time selection at start of the earliest A.S, and end it at the end of the latest one. Or alternatively it could just not run at all if more than one A.S is drawn when running it.

Thanks.
Joe90 is offline   Reply With Quote
Old 10-01-2020, 11:40 PM   #163
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by Joe90 View Post
I need a script to create a time selection at the razor edit area.
Code:
--[[
ReaScript name: js_Razor edit - Set time selection to razor areas.lua
]]
left, right = math.huge, -math.huge
for t = 0, reaper.CountTracks(0)-1 do
    local track = reaper.GetTrack(0, t)
    local razorOK, razorStr = reaper.GetSetMediaTrackInfo_String(track, "P_RAZOREDITS", "", false)
    if razorOK and #razorStr ~= 0 then
        for razorLeft, razorRight, envGuid in razorStr:gmatch([[([%d%.]+) ([%d%.]+) "([^"]*)"]]) do
            local razorLeft, razorRight = tonumber(razorLeft), tonumber(razorRight)
            if razorLeft  < left  then left  = razorLeft end
            if razorRight > right then right = razorRight end
        end
    end
end
if left <= right then
    reaper.GetSet_LoopTimeRange2(0, true, false, left, right, false)
end
juliansader is offline   Reply With Quote
Old 10-02-2020, 01:05 AM   #164
Joe90
Human being with feelings
 
Join Date: Aug 2019
Posts: 853
Default

Quote:
Originally Posted by juliansader View Post
Code:
--[[
ReaScript name: js_Razor edit - Set time selection to razor areas.lua
]]
left, right = math.huge, -math.huge
for t = 0, reaper.CountTracks(0)-1 do
    local track = reaper.GetTrack(0, t)
    local razorOK, razorStr = reaper.GetSetMediaTrackInfo_String(track, "P_RAZOREDITS", "", false)
    if razorOK and #razorStr ~= 0 then
        for razorLeft, razorRight, envGuid in razorStr:gmatch([[([%d%.]+) ([%d%.]+) "([^"]*)"]]) do
            local razorLeft, razorRight = tonumber(razorLeft), tonumber(razorRight)
            if razorLeft  < left  then left  = razorLeft end
            if razorRight > right then right = razorRight end
        end
    end
end
if left <= right then
    reaper.GetSet_LoopTimeRange2(0, true, false, left, right, false)
end
Works like a charm thank you.
Joe90 is offline   Reply With Quote
Old 10-04-2020, 08:07 AM   #165
gapalil001
Human being with feelings
 
gapalil001's Avatar
 
Join Date: May 2016
Location: Kyiv, Ukraine
Posts: 544
Default

Quote:
Originally Posted by amagalma View Post
No. Could you explain how this would work? And maybe I can make it
https://drive.google.com/file/d/12CE...ew?usp=sharing

here is how fades works in pro tools
gapalil001 is offline   Reply With Quote
Old 10-04-2020, 01:06 PM   #166
sonictim
Human being with feelings
 
sonictim's Avatar
 
Join Date: Feb 2020
Location: Los Angeles
Posts: 463
Default

Quote:
Originally Posted by gapalil001 View Post
https://drive.google.com/file/d/12CE...ew?usp=sharing

here is how fades works in pro tools
I couldn't get your link to work, but I've been working on a protools style implementation of fades with Razor Edit (and also time/item selection).. I put it in my reapack if you want to give it a try.... TJF Smart Fade... The defaults are set to the way I like to work in protools, so you may want to change them

LINK TO MY REAPACK REPOSITORY:
Code:
https://github.com/sonictim/TJF-Scripts/raw/master/index.xml

As the script deals with more than just razor edits, I didn't want to post the whole script here in this forum.

Also, just wanted to say thank you to BirdBird and Amagalma. I was able to develop it from code you had written in this forum... Cheers for that!

Last edited by sonictim; 01-24-2021 at 01:38 PM.
sonictim is offline   Reply With Quote
Old 10-05-2020, 05:48 AM   #167
gapalil001
Human being with feelings
 
gapalil001's Avatar
 
Join Date: May 2016
Location: Kyiv, Ukraine
Posts: 544
Default

Quote:
Originally Posted by sonictim View Post
I couldn't get your link to work, but I've been working on a protools style implementation of fades with Razor Edit (and also time/item selection).. I put it in my reapack if you want to give it a try.... TJF Smart Fade... The defaults are set to the way I like to work in protools, so you may want to change them

LINK TO MY REAPACK REPOSITORY:
Code:
https://github.com/sonictim/TJF-Scripts/raw/master/index.xml

As the script deals with more than just razor edits, I didn't want to post the whole script here in this forum.

Also, just wanted to say thank you to BirdBird and Amagalma. I was able to develop it from code you had written in this forum... Cheers for that!
thank you! i will check! i update the link, retry please
gapalil001 is offline   Reply With Quote
Old 10-05-2020, 09:52 AM   #168
sonictim
Human being with feelings
 
sonictim's Avatar
 
Join Date: Feb 2020
Location: Los Angeles
Posts: 463
Default

Quote:
Originally Posted by gapalil001 View Post
thank you! i will check! i update the link, retry please
You have to add the link I listed above to your reapack and then use reapack to get the script.. However, I also just attached the script to the above post so you can just download directly from there if you like...
sonictim is offline   Reply With Quote
Old 10-06-2020, 12:58 PM   #169
gapalil001
Human being with feelings
 
gapalil001's Avatar
 
Join Date: May 2016
Location: Kyiv, Ukraine
Posts: 544
Default

Quote:
Originally Posted by sonictim View Post
You have to add the link I listed above to your reapack and then use reapack to get the script.. However, I also just attached the script to the above post so you can just download directly from there if you like...
i already add your link to repository list, but i cant see scripts for fades and razor edit
gapalil001 is offline   Reply With Quote
Old 10-06-2020, 03:10 PM   #170
sonictim
Human being with feelings
 
sonictim's Avatar
 
Join Date: Feb 2020
Location: Los Angeles
Posts: 463
Default

Quote:
Originally Posted by gapalil001 View Post
i already add your link to repository list, but i cant see scripts for fades and razor edit


I'm not sure what to tell you.. there it is in my reapack... As I mentioned before, the script is attached in the post above, so you don't need reapack to get it...
sonictim is offline   Reply With Quote
Old 10-09-2020, 03:00 PM   #171
gapalil001
Human being with feelings
 
gapalil001's Avatar
 
Join Date: May 2016
Location: Kyiv, Ukraine
Posts: 544
Default

Quote:
Originally Posted by sonictim View Post


I'm not sure what to tell you.. there it is in my reapack... As I mentioned before, the script is attached in the post above, so you don't need reapack to get it...
WOW! YEA ITS WORKING FINE!
gapalil001 is offline   Reply With Quote
Old 10-09-2020, 05:24 PM   #172
Arthur McArthur
Human being with feelings
 
Arthur McArthur's Avatar
 
Join Date: Sep 2016
Location: Toronto
Posts: 744
Default

Quote:
Originally Posted by Arthur McArthur View Post
One script that would be really nice to have is "duplicate contents of razor edits to fill regions in loop points"

From: https://i.imgur.com/IBDmepu.png

to: https://i.imgur.com/n0cP2AQ.png
Many thanks to amalgama for filling this request:

Code:
-- script by amagalma 8/10/20

-- Get time selection
local tsS, tsE = reaper.GetSet_LoopTimeRange2( 0, 0, 0, 0, 0, 0 )
if tsS == tsE then return end

local tsL = tsE - tsS

local t = {}
local sel_tracks = {}
local track_cnt = reaper.CountTracks(0)
local a = 0
local tr = 0
for i = 0, track_cnt - 1 do
  local track = reaper.GetTrack(0, i)
  -- Store selected tracks
  if reaper.IsTrackSelected( track ) then
    tr = tr + 1
    sel_tracks[tr] = track
    reaper.SetTrackSelected( track, false )
  end
  local _, area = reaper.GetSetMediaTrackInfo_String(track, "P_RAZOREDITS", "", false)
  -- Store area selections
  if area ~= "" then
    a = a + 1
    local areaS, areaE = area:match("(%S+) (%S+)")
    areaS, areaE = tonumber(areaS), tonumber(areaE)
    t[a] = {tr = track, st = areaS, en = areaE, len = areaE-areaS, ar = area}
    reaper.GetSetMediaTrackInfo_String(track, "P_RAZOREDITS", "", true)
  end
end

if #t == 0 then return end

-- Store edit cursor position
local cur_pos = reaper.GetCursorPositionEx( 0 )

-- Do the thing
reaper.Undo_BeginBlock2( 0 )
reaper.PreventUIRefresh( 1 )

for n = 1, #t do
  reaper.GetSetMediaTrackInfo_String(t[n].tr, "P_RAZOREDITS", t[n].ar, true)
  reaper.SetOnlyTrackSelected( t[n].tr )
  reaper.Main_OnCommand(40914, 0) -- Set first selected track as last touched track
  reaper.Main_OnCommand(40307, 0) -- Cut selected area of items
  local times, fraction = math.modf(tsL/t[n].len)
  reaper.SetEditCurPos2( 0, tsS, false, false )
  if times > 0 then
    for i = 1, times do
      reaper.Main_OnCommand(42398, 0) -- Paste items/tracks
    end
  end
  if fraction > 0 then
    local _, area = reaper.GetSetMediaTrackInfo_String(t[n].tr, "P_RAZOREDITS", "", false)
    local a,c = area:match("(%S+) %S+ (%S+)")
    reaper.GetSetMediaTrackInfo_String(t[n].tr, "P_RAZOREDITS",
                    string.format("%f %f %s", a, a + (t[n].len * fraction), c), true)
    reaper.Main_OnCommand(40060, 0) -- Copy selected area of items
    reaper.Main_OnCommand(42398, 0) -- Paste items/tracks
  end
  reaper.GetSetMediaTrackInfo_String(t[n].tr, "P_RAZOREDITS", "", true)
end

-- Restore track selection
reaper.SetTrackSelected( t[#t].tr, false )
for i = 1, #sel_tracks do
  reaper.SetTrackSelected( sel_tracks[i], true )
end

-- Restore edit cursor position
reaper.SetEditCurPos2( 0, cur_pos, false, false )

-- Create undo
reaper.PreventUIRefresh( -1 )
reaper.UpdateArrange()
-- "Fill time selection with looped contents of razor edits"
reaper.Undo_EndBlock2( 0, "Duplicate contents of razor edits to fill tracks in loop points", 1|4|8 )
Arthur McArthur is offline   Reply With Quote
Old 10-10-2020, 08:19 AM   #173
musicbynumbers
Human being with feelings
 
musicbynumbers's Avatar
 
Join Date: Jun 2009
Location: South, UK
Posts: 14,214
Default

Hmm

I've waited a while to see if the devs will implement this for Razor but so far no joy so..

Do you lovely scripting gods know if it's possible to have a script that allows you to do a razor style timestretch but for it to only adjust the start positions of the items and to leave the item length alone?

This is what I mean by a new mouse modifier (script or "active" script) for timestretching razor edits (via the edge)

You might have to zoom into the image to see the text descriptions but instead of stretching the length of any item within the razor edit.

It does exactly the same as what it does now but without changing item lengths and only changing their start positions.

In the image example. The 2 copies to the right of the original have been stretched to double their original length but the last one has the item length the same as the original so transients are preserved etc.

Excellent for drums, transient sounds and dialogue

Click this link if image not big enough to read..
https://stash.reaper.fm/40285/Reaper...Suggestion.JPG


__________________
subproject FRs click here
note: don't search for my pseudonym on the web. The "musicbynumbers" you find is not me or the name I use for my own music.
musicbynumbers is offline   Reply With Quote
Old 10-10-2020, 05:26 PM   #174
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

Quote:
Originally Posted by musicbynumbers View Post
Hmm

I've waited a while to see if the devs will implement this for Razor but so far no joy so..

Do you lovely scripting gods know if it's possible to have a script that allows you to do a razor style timestretch but for it to only adjust the start positions of the items and to leave the item length alone?

This is what I mean by a new mouse modifier (script or "active" script) for timestretching razor edits (via the edge)

You might have to zoom into the image to see the text descriptions but instead of stretching the length of any item within the razor edit.

It does exactly the same as what it does now but without changing item lengths and only changing their start positions.

In the image example. The 2 copies to the right of the original have been stretched to double their original length but the last one has the item length the same as the original so transients are preserved etc.

Excellent for drums, transient sounds and dialogue

Click this link if image not big enough to read..
https://stash.reaper.fm/40285/Reaper...Suggestion.JPG


I think it is possible but I dont know much about deffer to be able to code it.

I think one script constantly measuring the RE length and when it is changed it change the position start and reset the item playrate to what was before.

maybe
daniellumertz is offline   Reply With Quote
Old 10-10-2020, 06:17 PM   #175
musicbynumbers
Human being with feelings
 
musicbynumbers's Avatar
 
Join Date: Jun 2009
Location: South, UK
Posts: 14,214
Default

Cool. good to hear it might be possible.

I originally thought it would be as simple as reseting the item rates after stretch but if they are already at something other than 1 before the stretch these states will need storing and recalling and maybe that's messy if there's hundreds of items over multiple tracks.

I guess I'll poke the devs for it again as its probably easier for them (or at least slightly easier)

Quote:
Originally Posted by daniellumertz View Post
I think it is possible but I dont know much about deffer to be able to code it.

I think one script constantly measuring the RE length and when it is changed it change the position start and reset the item playrate to what was before.

maybe
__________________
subproject FRs click here
note: don't search for my pseudonym on the web. The "musicbynumbers" you find is not me or the name I use for my own music.
musicbynumbers is offline   Reply With Quote
Old 10-11-2020, 12:37 AM   #176
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

Depending in how the script works I think the restoring part would not be difficult a table should resolve, or if it work in a loop per item even that wouldn't be necessary. Just need someone to try to make it hahaha

I might try, would be helpfull for me too


I would try :

--this is a sketch
saves in a list items inside RE playrate
loop:
If RE length change then
for every item inside
change playrate to previous
end

Last edited by daniellumertz; 10-11-2020 at 12:48 AM.
daniellumertz is offline   Reply With Quote
Old 10-12-2020, 07:06 AM   #177
gapalil001
Human being with feelings
 
gapalil001's Avatar
 
Join Date: May 2016
Location: Kyiv, Ukraine
Posts: 544
Default

is there any script like "split items by razor edit OR cursor position?
gapalil001 is offline   Reply With Quote
Old 10-12-2020, 10:09 AM   #178
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

Well, the normal split action split at edit cursor... OR are you saying the play cursor?

Also, about the re split, isn't a way native ? Can test it right now (cleaning my house and will bath the dog soon )

Last edited by daniellumertz; 10-16-2020 at 02:16 PM.
daniellumertz is offline   Reply With Quote
Old 10-12-2020, 10:20 AM   #179
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
Default

Quote:
Originally Posted by Embass View Post
Cool script!

Could you make a version that can handle instruments that were recorded using more than 1 mic? So instead of selecting just 1 destination track you can select multiple?
__________________

Support my feature request!
Dafarkias is offline   Reply With Quote
Old 10-12-2020, 12:59 PM   #180
AtmanActive
Human being with feelings
 
AtmanActive's Avatar
 
Join Date: Dec 2009
Location: United Kingdom
Posts: 668
Default

Quote:
Originally Posted by Embass View Post
Wow! Fantastic! Works great. This is A-W-E-S-O-M-E! Thanks Embass!
AtmanActive is offline   Reply With Quote
Old 10-13-2020, 10:57 PM   #181
deeb
Human being with feelings
 
deeb's Avatar
 
Join Date: Feb 2017
Posts: 4,812
Default

req: would be nice to have create AIs from Razor Edit instead of time selection.
__________________
🙏🏻
deeb is offline   Reply With Quote
Old 10-14-2020, 02:56 PM   #182
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by deeb View Post
req: would be nice to have create AIs from Razor Edit instead of time selection.
I've been using this script to create temporary AIs from Razor selections and apply LFOs. It can easily be adapted to create permanent AIs:
Code:
--[[
ReaScript name: js_Razor edit - Convert razor areas to temporary AIs.lua
]]

reaper.Undo_BeginBlock2(0)

tAIs = {}
pool = nil
tRazors = {}
tEnvBypass = {}
title = reaper.LocalizeString("Automation Item Properties", "common", 0)
bypassAll = (reaper.GetToggleCommandState(42213) == 1)

function ConvertRazorsToAIs()
    for t = 0, reaper.CountTracks(0)-1 do
        local track = reaper.GetTrack(0, t)
        local tGuidEnv = {} 
        for e = 0, reaper.CountTrackEnvelopes(track)-1 do
            local env = reaper.GetTrackEnvelope(track, e)
            local chunkOK, chunk = reaper.GetEnvelopeStateChunk(env, "", false)
            local guid = chunk:match("\nEGUID ({.-})")
            if guid then 
                tGuidEnv[guid] = env
                local envOptions = tonumber(chunk:match("\nACT %S+ (%S+)") or "0") or 0
                if envOptions ~= -1 and envOptions&4 == 4 then
                    tEnvBypass[env] = true
                end
                --[[local guidOK, guid = reaper.GetSetEnvelopeInfo_String(env, "GUID", "", false)
                if guidOK and guid then
                    tGuidEnv[guid] = env
                end]]
                for ai = 0, reaper.CountAutomationItems(env)-1 do
                    reaper.GetSetAutomationItemInfo(env, ai, "D_UISEL", 0, true) -- Deselect all existing AIs
                end
            end
        end
        
        razorOK, razorStr = reaper.GetSetMediaTrackInfo_String(track, "P_RAZOREDITS", "", false)
        if razorOK and #razorStr ~= 0 then
            tRazors[track] = razorStr
            reaper.GetSetMediaTrackInfo_String(track, "P_RAZOREDITS", "", true)
            for left, right, guid in razorStr:gmatch([[([%d%.]+) ([%d%.]+) "([^"]+)"]]) do
                if guid and tGuidEnv[guid] then
                    local left, right = tonumber(left), tonumber(right)
                    local length = right-left
                    origLen = origLen or length -- Will only be calculated for first razor selection found
                    local playrate = origLen/length 
                    local env = tGuidEnv[guid]
                    local ai = reaper.InsertAutomationItem(env, pool or -1, left, length)
                    -- WARNING! InsertAutomationItem may return false index, so must search manually. Assume that only new AI will be selected.
                    for ai = 0, reaper.CountAutomationItems(env)-1 do
                        if reaper.GetSetAutomationItemInfo(env, ai, "D_UISEL", 0, false) ~= 0 then
                            tAIs[#tAIs+1] = {env = env, ai = ai} -- for setting selected later
                            reaper.GetSetAutomationItemInfo(env, ai, "D_PLAYRATE", playrate, true)
                            if not pool then pool = reaper.GetSetAutomationItemInfo(env, ai, "D_POOL_ID", 0, false) end
                            reaper.Main_OnCommand(42221, 0) -- Do not connect to underlying envelope
                            break
                        end
                    end
                    
                end
            end
        end
    end
end


function atexit()
    -- AIs in envelopes that bypass the underlying envelope will not be deleted.
    -- Otherwise, select them and delete, preserving points.
    for _, t in ipairs(tAIs) do
        if bypassAll or tEnvBypass[t.env] then -- Bypass this envelope?
            reaper.GetSetAutomationItemInfo(t.env, t.ai, "D_UISEL", 0, true)
        else
            reaper.GetSetAutomationItemInfo(t.env, t.ai, "D_UISEL", 1, true)
        end
    end
    reaper.Main_OnCommand(42088, 0) -- Delete AIs, preserve points
    -- Re-select all remaining new AIs
    for _, t in ipairs(tAIs) do
        if bypassAll or tEnvBypass[t.env] then -- Bypass this envelope?
            reaper.GetSetAutomationItemInfo(t.env, t.ai, "D_UISEL", 1, true)
        end
    end
    -- Restore razor selections
    for track, razorStr in pairs(tRazors) do
        reaper.GetSetMediaTrackInfo_String(track, "P_RAZOREDITS", razorStr, true)
    end
end


function defer()
    -- Wait for Properties window to close before exiting script
    if not AIPropertiesWindow then
        AIPropertiesWindow = reaper.JS_Window_FindTop(title, true)
        reaper.defer(defer)
    elseif reaper.JS_Window_FindTop(title, true) then
        reaper.defer(defer)
    else
        return
    end
end

reaper.atexit(atexit)

ConvertRazorsToAIs()
if next(tRazors) then 
    reaper.Main_OnCommand(42090, 0) -- Envelope: Automation item properties...
    defer() -- Wait for Properties window to close before exiting script
end

reaper.UpdateArrange()
reaper.Undo_EndBlock2(0, "Convert razor selection to AIs", 0)
juliansader is offline   Reply With Quote
Old 10-15-2020, 12:55 AM   #183
mirceablue
Human being with feelings
 
Join Date: Apr 2008
Location: Brasov Romania
Posts: 140
Default copy items between projects including tracks and fx

There's a way right now to copy items under razor area and paste them in another projects including the tracks and fx the items are on?

In 6.14 dev 103 if I try to copy the selected area I don't get the track effects in the new projects and I get some empty tracks that are not in the original project.



mirceablue is offline   Reply With Quote
Old 10-15-2020, 03:04 AM   #184
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

the empty tracks are probably a bug? I have seen in older editions some other bugs pasting between projects.

I just confused if you are suggesting an script or an native behavior( I believe not, but if so the Razor Edit discussion thread).


As for native behavior I don't think it makes much sense to copy the tracks FX. ( As RE copy the items not the tracks, reaper is just inserting tracks because there is none).

For a script is probably doable hehe maybe with two action one to copy tracks and get the info about the RE pos. And one for paste the tracks and then delete everything outside time span of RE?
daniellumertz is offline   Reply With Quote
Old 10-15-2020, 06:37 AM   #185
mirceablue
Human being with feelings
 
Join Date: Apr 2008
Location: Brasov Romania
Posts: 140
Default

Thanks for the answer daniellumertz . Yes I'm not expecting the default behavior to do this but maybe a script or a mouse modifier. I was doing manually what you've suggested, maybe I will try a custom action if nothing easier comes in the future.
mirceablue is offline   Reply With Quote
Old 10-15-2020, 04:44 PM   #186
Win Conway
Human being with feelings
 
Join Date: Dec 2010
Posts: 3,826
Default

I have an idea for a razor edit script.
1 Select your razor edit.
2 It copies the razor edit areas item.
3 It pastes the copy directly to the left of the original.
4 It reverses the copy.
5 It fades the copy in.
So you could select a word inn a vocal and it would add the reverse in vocal effect, same for snares and cymbals etc.
__________________
Stop posting huge images, smaller images or thumbnail, it's not rocket science!
Win Conway is offline   Reply With Quote
Old 10-15-2020, 08:55 PM   #187
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

this could be cool, The way I do it is splitting what I want to reverse and then using
Item properties: Toggle take reverse


I Will probably try this one this weekend
daniellumertz is offline   Reply With Quote
Old 10-16-2020, 09:01 AM   #188
sonictim
Human being with feelings
 
sonictim's Avatar
 
Join Date: Feb 2020
Location: Los Angeles
Posts: 463
Default

Quote:
Originally Posted by Win Conway View Post
I have an idea for a razor edit script.
1 Select your razor edit.
2 It copies the razor edit areas item.
3 It pastes the copy directly to the left of the original.
4 It reverses the copy.
5 It fades the copy in.
So you could select a word inn a vocal and it would add the reverse in vocal effect, same for snares and cymbals etc.
This sounds like something you might even be able to do wth a custom action... trim item, duplicate, reverse, fade
sonictim is offline   Reply With Quote
Old 10-16-2020, 12:17 PM   #189
Win Conway
Human being with feelings
 
Join Date: Dec 2010
Posts: 3,826
Default

Quote:
Originally Posted by daniellumertz View Post
this could be cool, The way I do it is splitting what I want to reverse and then using
Item properties: Toggle take reverse


I Will probably try this one this weekend
Yeah this is my current workflow, but the razor script would be so much slicker.
__________________
Stop posting huge images, smaller images or thumbnail, it's not rocket science!
Win Conway is offline   Reply With Quote
Old 10-16-2020, 01:47 PM   #190
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

Try this:

there is an option to also change the items positions to the left.
Code:
 change_pos = false -- Change the postion
I was more less babysitting my cousin while writing it so somethings could need a closer look haha
97% of code is from birdbird hahaha thanksss
Code:
function literalize(str)
    return str:gsub("[%(%)%.%%%+%-%*%?%[%]%^%$]", function(c) return "%" .. c end)
end

function print(param)
  reaper.ShowConsoleMsg(tostring(param)..'\n')
end

function GetGUIDFromEnvelope(envelope)
    local ret2, envelopeChunk = reaper.GetEnvelopeStateChunk(envelope, "")
    local GUID = "{" ..  string.match(envelopeChunk, "GUID {(%S+)}") .. "}"
    return GUID
end

function GetItemsInRange(track, areaStart, areaEnd)
    local items = {}
    local itemCount = reaper.CountTrackMediaItems(track)
    for k = 0, itemCount - 1 do 
        local item = reaper.GetTrackMediaItem(track, k)
        local pos = reaper.GetMediaItemInfo_Value(item, "D_POSITION")
        local length = reaper.GetMediaItemInfo_Value(item, "D_LENGTH")
        local itemEndPos = pos+length

        --check if item is in area bounds
        if (itemEndPos > areaStart and itemEndPos <= areaEnd) or
            (pos >= areaStart and pos < areaEnd) or
            (pos <= areaStart and itemEndPos >= areaEnd) then
                table.insert(items,item)
        end
    end

    return items
end

function GetEnvelopePointsInRange(envelopeTrack, areaStart, areaEnd)
    local envelopePoints = {}

    for i = 1, reaper.CountEnvelopePoints(envelopeTrack) do
        local retval, time, value, shape, tension, selected = reaper.GetEnvelopePoint(envelopeTrack, i - 1)

        if time >= areaStart and time <= areaEnd then --point is in range
            envelopePoints[#envelopePoints + 1] = {
                id = i-1 ,
                time = time,
                value = value,
                shape = shape,
                tension = tension,
                selected = selected
            }
        end
    end

    return envelopePoints
end

function SetTrackRazorEdit(track, areaStart, areaEnd, clearSelection)
    if clearSelection == nil then clearSelection = false end
    
    if clearSelection then
        local ret, area = reaper.GetSetMediaTrackInfo_String(track, 'P_RAZOREDITS', '', false)
    
        --parse string, all this string stuff could probably be written better
        local str = {}
        for j in string.gmatch(area, "%S+") do
            table.insert(str, j)
        end
        
        --strip existing selections across the track
        local j = 1
        while j <= #str do
            local GUID = str[j+2]
            if GUID == '""' then 
                str[j] = ''
                str[j+1] = ''
                str[j+2] = ''
            end

            j = j + 3
        end

        --insert razor edit 
        local REstr = tostring(areaStart) .. ' ' .. tostring(areaEnd) .. ' ""'
        table.insert(str, REstr)

        local finalStr = ''
        for i = 1, #str do
            local space = i == 1 and '' or ' '
            finalStr = finalStr .. space .. str[i]
        end

        local ret, area = reaper.GetSetMediaTrackInfo_String(track, 'P_RAZOREDITS', finalStr, true)
        return ret
    else         
        local ret, area = reaper.GetSetMediaTrackInfo_String(track, 'P_RAZOREDITS', '', false)
        local str = area ~= nil and area .. ' ' or ''
        str = str .. tostring(areaStart) .. ' ' .. tostring(areaEnd) .. '  ""'
        
        local ret, area = reaper.GetSetMediaTrackInfo_String(track, 'P_RAZOREDITS', str, true)
        return ret
    end
end

function SetEnvelopeRazorEdit(envelope, areaStart, areaEnd, clearSelection, GUID)
    local GUID = GUID == nil and GetGUIDFromEnvelope(envelope) or GUID
    local track = reaper.Envelope_GetParentTrack(envelope)

    if clearSelection then
        local ret, area = reaper.GetSetMediaTrackInfo_String(track, 'P_RAZOREDITS', '', false)
    
        --parse string
        local str = {}
        for j in string.gmatch(area, "%S+") do
            table.insert(str, j)
        end
        
        --strip existing selections across the envelope
        local j = 1
        while j <= #str do
            local envGUID = str[j+2]
            if GUID ~= '""' and envGUID:sub(2,-2) == GUID then 
                str[j] = ''
                str[j+1] = ''
                str[j+2] = ''
            end

            j = j + 3
        end

        --insert razor edit
        local REstr = tostring(areaStart) .. ' ' .. tostring(areaEnd) .. ' ' .. GUID
        table.insert(str, REstr)

        local finalStr = ''
        for i = 1, #str do
            local space = i == 1 and '' or ' '
            finalStr = finalStr .. space .. str[i]
        end

        local ret, area = reaper.GetSetMediaTrackInfo_String(track, 'P_RAZOREDITS', finalStr, true)
        return ret
    else         
        local ret, area = reaper.GetSetMediaTrackInfo_String(track, 'P_RAZOREDITS', '', false)

        local str = area ~= nil and area .. ' ' or ''
        str = str .. tostring(areaStart) .. ' ' .. tostring(areaEnd) .. ' ' .. GUID
        
        local ret, area = reaper.GetSetMediaTrackInfo_String(track, 'P_RAZOREDITS', str, true)
        return ret
    end
end

function GetRazorEdits()
    local trackCount = reaper.CountTracks(0)
    local areaMap = {}
    for i = 0, trackCount - 1 do
        local track = reaper.GetTrack(0, i)
        local ret, area = reaper.GetSetMediaTrackInfo_String(track, 'P_RAZOREDITS', '', false)
        if area ~= '' then
            --PARSE STRING
            local str = {}
            for j in string.gmatch(area, "%S+") do
                table.insert(str, j)
            end
        
            --FILL AREA DATA
            local j = 1
            while j <= #str do
                --area data
                local areaStart = tonumber(str[j])
                local areaEnd = tonumber(str[j+1])
                local GUID = str[j+2]
                local isEnvelope = GUID ~= '""'

                --get item/envelope data
                local items = {}
                local envelopeName, envelope
                local envelopePoints
                
                if not isEnvelope then
                    items = GetItemsInRange(track, areaStart, areaEnd)
                else
                    envelope = reaper.GetTrackEnvelopeByChunkName(track, GUID:sub(2, -2))
                    local ret, envName = reaper.GetEnvelopeName(envelope)

                    envelopeName = envName
                    envelopePoints = GetEnvelopePointsInRange(envelope, areaStart, areaEnd)
                end

                local areaData = {
                    areaStart = areaStart,
                    areaEnd = areaEnd,
                    
                    track = track,
                    items = items,
                    
                    --envelope data
                    isEnvelope = isEnvelope,
                    envelope = envelope,
                    envelopeName = envelopeName,
                    envelopePoints = envelopePoints,
                    GUID = GUID:sub(2, -2)
                }

                table.insert(areaMap, areaData)

                j = j + 3
            end
        end
    end

    return areaMap
end

function SplitRazorEdits(razorEdits)
    local areaItems = {}
    local tracks = {}
    reaper.PreventUIRefresh(1)
    for i = 1, #razorEdits do
        local areaData = razorEdits[i]
        if not areaData.isEnvelope then
            local items = areaData.items
            
            --recalculate item data for tracks with previous splits
            if tracks[areaData.track] ~= nil then 
                items = GetItemsInRange(areaData.track, areaData.areaStart, areaData.areaEnd)
            end
            
            for j = 1, #items do 
                local item = items[j]
                --split items 
                local newItem = reaper.SplitMediaItem(item, areaData.areaStart)
                if newItem == nil then
                    reaper.SplitMediaItem(item, areaData.areaEnd)
                    table.insert(areaItems, item)
                else
                    reaper.SplitMediaItem(newItem, areaData.areaEnd)
                    table.insert(areaItems, newItem)
                end
            end

            tracks[areaData.track] = 1
        end
    end
    reaper.PreventUIRefresh(-1)
    
    return areaItems
end

function IsRazor()
  isarea = false
  for i = 0,  reaper.CountTracks(0) - 1 do
     local track = reaper.GetTrack(0, i)
     local ret, area = reaper.GetSetMediaTrackInfo_String(track, 'P_RAZOREDITS', '', false)
     if area ~= '' then isarea = true end 
  end
  return isarea
end


----------------
-----MAIN ACTION
----------------


reaper.Undo_BeginBlock()

change_pos = false -- Change the postion

if IsRazor() == true then
  local selections = GetRazorEdits()
  local items = SplitRazorEdits(selections)
  for i = 1, #items do -- Select Items Splited 
      local item = items[i]
      reaper.SetMediaItemSelected(item, true)
       if change_pos == true then 
          item_start = reaper.GetMediaItemInfo_Value( item, 'D_POSITION' )
          item_len = reaper.GetMediaItemInfo_Value( item, 'D_LENGTH' )
          reaper.SetMediaItemInfo_Value( item, 'D_POSITION', item_start-item_len )
       end
  end
  reaper.Main_OnCommand( 41051, -1 )-- Reverse Items 
else
end

reaper.Undo_EndBlock( 'Reverse at Razor Edits', -1 )
daniellumertz is offline   Reply With Quote
Old 10-16-2020, 11:28 PM   #191
cool
Human being with feelings
 
Join Date: Dec 2017
Location: Sunny Siberian Islands
Posts: 957
Default

Quote:
Originally Posted by juliansader View Post
Code:
--[[
ReaScript name: js_Razor edit - Set time selection to razor areas.lua
]]
left, right = math.huge, -math.huge
for t = 0, reaper.CountTracks(0)-1 do
    local track = reaper.GetTrack(0, t)
    local razorOK, razorStr = reaper.GetSetMediaTrackInfo_String(track, "P_RAZOREDITS", "", false)
    if razorOK and #razorStr ~= 0 then
        for razorLeft, razorRight, envGuid in razorStr:gmatch([[([%d%.]+) ([%d%.]+) "([^"]*)"]]) do
            local razorLeft, razorRight = tonumber(razorLeft), tonumber(razorRight)
            if razorLeft  < left  then left  = razorLeft end
            if razorRight > right then right = razorRight end
        end
    end
end
if left <= right then
    reaper.GetSet_LoopTimeRange2(0, true, false, left, right, false)
end

Thank you! Thanks to this code, I can now add Razor Edit to my old scripts.

Is there a way to select all of the items that have Razor Edit? Or, alternatively, select all the tracks that have Razor Edit? This would make the code more flexible to adapt to old scripts.
cool is offline   Reply With Quote
Old 10-17-2020, 05:15 AM   #192
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

Birdbird function can gives a list of items under re. Just need to loop thought selecting them ... not only my pc now...
daniellumertz is offline   Reply With Quote
Old 10-17-2020, 05:49 AM   #193
cool
Human being with feelings
 
Join Date: Dec 2017
Location: Sunny Siberian Islands
Posts: 957
Default

Quote:
Originally Posted by daniellumertz View Post
Birdbird function can gives a list of items under re. Just need to loop thought selecting them ... not only my pc now...

Thanks. Yes I know. His code is very good. But, it is quite large compared to the concise Juliansader code.
cool is offline   Reply With Quote
Old 10-23-2020, 01:19 PM   #194
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by cool View Post
Is there a way to select all of the items that have Razor Edit? Or, alternatively, select all the tracks that have Razor Edit? This would make the code more flexible to adapt to old scripts.
To select items:
Code:
reaper.Undo_BeginBlock2(0)
for t = 0, reaper.CountTracks(0)-1 do
    local track = reaper.GetTrack(0, t)
    local tR = {}
    local razorOK, razorStr = reaper.GetSetMediaTrackInfo_String(track, "P_RAZOREDITS", "", false)
    if razorOK and #razorStr ~= 0 then
        for razorLeft, razorRight, envGuid in razorStr:gmatch([[([%d%.]+) ([%d%.]+) "([^"]*)"]]) do
            if envGuid == "" then
                local razorLeft, razorRight = tonumber(razorLeft), tonumber(razorRight)
                table.insert(tR, {left = razorLeft, right = razorRight})
            end
        end
    end
    for i = 0, reaper.CountTrackMediaItems(track)-1 do
        local item = reaper.GetTrackMediaItem(track, i)
        reaper.SetMediaItemSelected(item, false)
        local left = reaper.GetMediaItemInfo_Value(item, "D_POSITION")
        local right = left + reaper.GetMediaItemInfo_Value(item, "D_LENGTH")
        for _, r in ipairs(tR) do
            if left < r.right and right > r.left then
                reaper.SetMediaItemSelected(item, true)
            end
        end
    end
end
reaper.UpdateArrange()
reaper.Undo_EndBlock2(0, "Select media items that overlap razor areas", -1)
For selecting tracks:
Code:
--[[
ReaScript name: js_Razor edit - Select tracks that contain razor areas
]]
reaper.Undo_BeginBlock2(0)
reaper.SetTrackSelected(reaper.GetMasterTrack(0), false)
for t = 0, reaper.CountTracks(0)-1 do
    local track = reaper.GetTrack(0, t)
    local razorOK, razorStr = reaper.GetSetMediaTrackInfo_String(track, "P_RAZOREDITS", "", false)
    if razorOK and #razorStr ~= 0 then
        reaper.SetTrackSelected(track, true)
    else
        reaper.SetTrackSelected(track, false)
    end
end
reaper.UpdateArrange()
reaper.Undo_EndBlock2(0, "Select tracks that contain razor areas", -1)
Another small script that I find useful, is this one for enclosing selected MIs and AIs in minimal razor areas. By using this script, selected MIs and AIs can finally be edited and moved together. (Warning: Razor selection does not yet work with Free Item Positioning and staced AIs.)
Code:
--[[
ReaScript name: js_Razor edit - Enclose selected media items and automation items in minimal razor areas.lua
]]
reaper.Undo_BeginBlock2(0)
tS = {}
for t = 0, reaper.CountTracks(0)-1 do
    track = reaper.GetTrack(0, t)
    for e = 0, reaper.CountTrackEnvelopes(track)-1 do
        env = reaper.GetTrackEnvelope(track, e)
        guidOK, guid = reaper.GetSetEnvelopeInfo_String(env, "GUID", "", false)
        for ai = 0, reaper.CountAutomationItems(env)-1 do
            if reaper.GetSetAutomationItemInfo(env, ai, "D_UISEL", 0, false) ~= 0 then
                left = reaper.GetSetAutomationItemInfo(env, ai, "D_POSITION", 0, false)
                right = left + reaper.GetSetAutomationItemInfo(env, ai, "D_LENGTH", 0, false)
                tS[track] = (tS[track] or "") .. string.format([[%.16f %.16f "%s" ]], left, right, guid)
            end
        end
    end
end
for i = 0, reaper.CountSelectedMediaItems(0)-1 do
    item = reaper.GetSelectedMediaItem(0, i)
    left = reaper.GetMediaItemInfo_Value(item, "D_POSITION")
    right = left + reaper.GetMediaItemInfo_Value(item, "D_LENGTH")
    track = reaper.GetMediaItemTrack(item)
    tS[track] = (tS[track] or "") .. string.format([[%.16f %.16f "" ]], left, right)
end
for track, str in pairs(tS) do
    reaper.GetSetMediaTrackInfo_String(track, "P_RAZOREDITS", str, true)
end
reaper.UpdateArrange()
reaper.Undo_EndBlock2(0, "Enclose items in minimal razor areas", -1)
juliansader is offline   Reply With Quote
Old 10-27-2020, 08:22 PM   #195
cool
Human being with feelings
 
Join Date: Dec 2017
Location: Sunny Siberian Islands
Posts: 957
Default

Juliansader, amazing! Thank you!
cool is offline   Reply With Quote
Old 11-03-2020, 08:25 AM   #196
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

any way to get/set RE colors?
daniellumertz is offline   Reply With Quote
Old 11-03-2020, 01:50 PM   #197
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by daniellumertz View Post
any way to get/set RE colors?
In the Theme development/tweaker window.
juliansader is offline   Reply With Quote
Old 11-03-2020, 02:19 PM   #198
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

I mean via script hehe
daniellumertz is offline   Reply With Quote
Old 11-04-2020, 01:41 AM   #199
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Quote:
Originally Posted by daniellumertz View Post
any way to get/set RE colors?
reaper.GetThemeColor( ini_key, flags )
reaper.SetThemeColor( ini_key, color, flags )

areasel_fill
areasel_drawmode
areasel_outline
areasel_outlinemode

example:
r, g, b = reaper.ColorFromNative( reaper.GetThemeColor( "areasel_fill", 0 ) )
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 11-04-2020, 08:45 AM   #200
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

Nhaa, thanks a lot amagalma will test soon
daniellumertz 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 10:30 AM.


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