Old 08-30-2020, 10:52 AM   #41
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,589
Default

Quote:
Originally Posted by nofish View Post
For sure Reaper has an API to work with AI (e.g. CountAutomationItems, SetEnvelopePointEx etc.) or did I misunderstand?
Razor API returns data regarding selection, but it does not include AIs (only envelope tracks ATM)

Sexan is online now   Reply With Quote
Old 08-30-2020, 11:20 AM   #42
teniente powell
Human being with feelings
 
teniente powell's Avatar
 
Join Date: Oct 2016
Location: Spain
Posts: 323
Default

Quote:
Originally Posted by Embass View Post
Select 1 media item and run this script.
Any chance of adding a FX chain to that media item?
teniente powell is offline   Reply With Quote
Old 08-30-2020, 11:22 AM   #43
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

But if you have the track envelopes (pointers) you can manipulate points in AI using above mentioned API functions (though quite a bit involved as you have to loop through each AI seperatedly).
nofish is offline   Reply With Quote
Old 08-30-2020, 12:54 PM   #44
WyattRice
Human being with feelings
 
WyattRice's Avatar
 
Join Date: Sep 2009
Location: Virginia
Posts: 2,067
Default

Quote:
Originally Posted by Sexan View Post
Razor API returns data regarding selection, but it does not include AIs (only envelope tracks ATM)
Would something like this work if envelope track lanes are not enabled, but I have envelopes on on a regular track, like a pre fx envelope?
Here's an older mockup I did.
https://forum.cockos.com/showthread....75#post2135975

Many Thanks,
Wyatt
__________________
DDP To Cue Writer. | DDP Marker Editor.
WyattRice is offline   Reply With Quote
Old 08-30-2020, 01:10 PM   #45
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,589
Default

Quote:
Originally Posted by WyattRice View Post
Would something like this work if envelope track lanes are not enabled, but I have envelopes on on a regular track, like a pre fx envelope?
Here's an older mockup I did.
https://forum.cockos.com/showthread....75#post2135975

Many Thanks,
Wyatt
I know you have been waiting for this for like AGES so :

Pre-FX Volume


It may have bugs here and there and some unexpected behaviors, but I'm working on it.

BTW things may brake in the future this is experimental stuff with Dev release (which maybe will be altered,improved,added new api etc)

Set shortcut, press and hold the shortcut to manipulate with envelope (JS API is needed)


P.S. Schwa please.... for the love of god... left drag!

Last edited by Sexan; 02-13-2023 at 08:15 AM.
Sexan is online now   Reply With Quote
Old 08-30-2020, 02:24 PM   #46
musicbynumbers
Human being with feelings
 
musicbynumbers's Avatar
 
Join Date: Jun 2009
Location: South, UK
Posts: 14,214
Default

Wow! That's super powerful Sexan!
__________________
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 08-30-2020, 02:46 PM   #47
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,589
Default

Quote:
Originally Posted by nofish View Post
But if you have the track envelopes (pointers) you can manipulate points in AI using above mentioned API functions (though quite a bit involved as you have to loop through each AI seperatedly).
Tried it... but they are weird. They always have been weird with API.



This is pretty huge code to get data from them (and it is in my Area51 script also). But 5 of 10 times working with them they start to jump around doing weird things and affecting normal envelope points near by. Normal points are also detected behind them (not sure whats up with that).
Sexan is online now   Reply With Quote
Old 08-30-2020, 03:08 PM   #48
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Guys, for your area scripts, I invite you to check this function, in order to get the items inside an area (be it TS or RE or whatever).

A test code comparing it with the function that BirdBird posted (which is absolutely fine btw!!!):

Code:
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



-- amagalma function using Binary Search
function GetItemsInTimeAreaFast(track, start_pos, end_pos)
  if end_pos < start_pos then
    end_pos, start_pos = start_pos, end_pos
  end
  if end_pos - start_pos == 0 then return end
  local lo, hi, mid = 0, reaper.GetTrackNumMediaItems( track )-1
  local mid_item
  local t = {}
  while (hi >= lo) do
    mid = math.ceil((hi-lo)/2) + lo
    local item = reaper.GetTrackMediaItem( track, mid )
    local item_start = reaper.GetMediaItemInfo_Value( item, "D_POSITION" )
    local item_end = item_start + reaper.GetMediaItemInfo_Value( item, "D_LENGTH" )
    if item_start >= start_pos and item_end <= end_pos then
      t[1] = {ptr = item, st = item_start, en = item_end}
      mid_item = mid
      break
    elseif item_start >= end_pos then
      hi = mid-1
    elseif item_end <= start_pos then
      lo = mid+1
    else
      break
    end
  end
  if mid_item then
    local max = (hi - mid) >= (mid-lo) and (hi - mid) or (mid-lo)
    local forward, backward = true, true
    local n = 1
    for i = 1, max do
      if forward then
        local item = reaper.GetTrackMediaItem( track, mid_item + i )
        local item_start = reaper.GetMediaItemInfo_Value( item, "D_POSITION" )
        local item_end = item_start + reaper.GetMediaItemInfo_Value( item, "D_LENGTH" )
        if item_start >= start_pos and item_end <= end_pos then
          n = n + 1
          t[n] = {ptr = item, st = item_start, en = item_end}
        elseif item_start >= end_pos then
          forward = false
        end
      end
      if backward then
        local item = reaper.GetTrackMediaItem( track, mid_item - i )
        local item_start = reaper.GetMediaItemInfo_Value( item, "D_POSITION" )
        local item_end = item_start + reaper.GetMediaItemInfo_Value( item, "D_LENGTH" )
        if item_start >= start_pos and item_end <= end_pos then
          n = n + 1
          t[n] = {ptr = item, st = item_start, en = item_end}
        elseif item_start >= end_pos then
          backward = false
        end
      if (not forward) and (not backward) then break end
      end
    end
  end
  table.sort(t, function(a,b) return a.st < b.st end)
  return t
end

-- TEST
track = reaper.GetTrack(0, 0)
_, area = reaper.GetSetMediaTrackInfo_String(track, 'P_RAZOREDITS', '', false)
ar_st, ar_en = area:match("(%S+) (%S+)")
ar_st, ar_en = tonumber(ar_st), tonumber(ar_en)

local start = reaper.time_precise()
items = GetItemsInRange(track, ar_st, ar_en)
speed1 = reaper.time_precise() - start

start = reaper.time_precise()
items2 = GetItemsInTimeAreaFast(track, ar_st, ar_en)
speed2 = reaper.time_precise() - start

faster = speed1 > speed2 and "GetItemsInTimeAreaFast" or "GetItemsInRange"
perc = string.format("%.2f", (faster == "GetItemsInRange" and speed1/speed2 or speed2/speed1) * 100)
reaper.ShowConsoleMsg(faster .. " completes taking " .. perc .. "% of the time the other function takes\n")

Results while testing on a track with 2376 items and one RE area, at various positions:
Code:
GetItemsInTimeAreaFast completes taking 30.78% of the time the other function takes
GetItemsInTimeAreaFast completes taking 5.47% of the time the other function takes
GetItemsInTimeAreaFast completes taking 20.41% of the time the other function takes
GetItemsInTimeAreaFast completes taking 9.14% of the time the other function takes
GetItemsInTimeAreaFast completes taking 9.90% of the time the other function takes
GetItemsInTimeAreaFast completes taking 0.47% of the time the other function takes
GetItemsInTimeAreaFast completes taking 5.56% of the time the other function takes
It will greatly speed up scripts when having to deal with many tracks and items

EDIT: Correct function is at the thread. The one posted here gives only items that are 100% inside the area.
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)

Last edited by amagalma; 09-01-2020 at 03:41 AM.
amagalma is offline   Reply With Quote
Old 08-30-2020, 03:22 PM   #49
musicbynumbers
Human being with feelings
 
musicbynumbers's Avatar
 
Join Date: Jun 2009
Location: South, UK
Posts: 14,214
Default

Hmm a good test (and challenge) for getting items might be to reverse positions of all items within the razor edit area

So not only will all the item positions reverse but also the contents (both audio and midi) so as if the whole thing was already bounced to a single audio file that had been reversed.

So if you did this on a simple 3 tracks with a kick, snare and hat track. All the items would be reversed and positioned as if the whole thing was backwards

If that's possible I will be insanely impressed!
__________________
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 08-30-2020, 03:40 PM   #50
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,589
Default

Quote:
Originally Posted by musicbynumbers View Post
Hmm a good test (and challenge) for getting items might be to reverse positions of all items within the razor edit area

So not only will all the item positions reverse but also the contents (both audio and midi) so as if the whole thing was already bounced to a single audio file that had been reversed.

So if you did this on a simple 3 tracks with a kick, snare and hat track. All the items would be reversed and positioned as if the whole thing was backwards

If that's possible I will be insanely impressed!
Hold my beer
Sexan is online now   Reply With Quote
Old 08-30-2020, 04:39 PM   #51
musicbynumbers
Human being with feelings
 
musicbynumbers's Avatar
 
Join Date: Jun 2009
Location: South, UK
Posts: 14,214
Default

Holding!
__________________
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 08-30-2020, 07:04 PM   #52
WyattRice
Human being with feelings
 
WyattRice's Avatar
 
Join Date: Sep 2009
Location: Virginia
Posts: 2,067
Default

Quote:
Originally Posted by Sexan View Post
I know you have been waiting for this for like AGES so :

Pre-FX Volume

It may have bugs here and there and some unexpected behaviors, but I'm working on it.

BTW things may brake in the future this is experimental stuff with Dev release (which maybe will be altered,improved,added new api etc)

Set shortcut, press and hold the shortcut to manipulate with envelope (JS API is needed)


P.S. Schwa please.... for the love of god... left drag!
Wow! that is awesome.
I have the latest Reaper dev installed, and latest JS extension.
I assigned a shortcut key to your script, but I can't seem to get it to work.
Do I need to change any mouse modifiers, or settings.

Thanks,
Wyatt
__________________
DDP To Cue Writer. | DDP Marker Editor.
WyattRice is offline   Reply With Quote
Old 08-30-2020, 11:46 PM   #53
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,589
Default

Make a area selection, press and hold your shortcut key and move your mouse, release when done
Sexan is online now   Reply With Quote
Old 08-31-2020, 02:23 AM   #54
Vagelis
Human being with feelings
 
Vagelis's Avatar
 
Join Date: Oct 2017
Location: Larisa, Greece
Posts: 3,795
Default

Awesome Sexan! Would you add support for take envelopes as well? If possible, then
maybe a way could be when the mouse is over take envelopes, to create AS for them,else for track envelopes.
Vagelis is offline   Reply With Quote
Old 08-31-2020, 03:11 AM   #55
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,589
Default

Will try something about that
Sexan is online now   Reply With Quote
Old 08-31-2020, 03:36 AM   #56
sonictim
Human being with feelings
 
sonictim's Avatar
 
Join Date: Feb 2020
Location: Los Angeles
Posts: 463
Default Reverse items In Area Selection

Quote:
Hmm a good test (and challenge) for getting items might be to reverse positions of all items within the razor edit area

So not only will all the item positions reverse but also the contents (both audio and midi) so as if the whole thing was already bounced to a single audio file that had been reversed.

So if you did this on a simple 3 tracks with a kick, snare and hat track. All the items would be reversed and positioned as if the whole thing was backwards

If that's possible I will be insanely impressed!

The first script I ever wrote was making an area selection that reverses itself to time selection. SO I thought I'd take you up on your challenge with area selection reverse. It works, but only if the shape is square.
Attached Files
File Type: lua TJF Non Destructive Reverse Time selection.lua (7.4 KB, 185 views)
sonictim is offline   Reply With Quote
Old 08-31-2020, 05:02 AM   #57
Embass
Human being with feelings
 
Embass's Avatar
 
Join Date: Jan 2014
Posts: 923
Default

another swipe comping script (split and mute mode)
script: https://drive.google.com/file/d/1cCw...ew?usp=sharing

---------------------------------------------------------------------------------------------------
BE AWARE:
script automatically heals all media items (splits) on children tracks, so you may lose your edits!!!
---------------------------------------------------------------------------------------------------

script does not support these item types (split healing doesnt work properly):
MIDI items, overlapping items, empty items..

use normal audio items.

to avoid clicks you can enable this option in preferences:
"Create automatic fade-in/fade-out for new items.."


mouse modifiers:

alt + drag = mute lane
ctrl + alt + drag = mute all lanes
shift + drag = solo lane (add mode)
ctrl + shift + drag = solo all lanes


it looks like this:

Last edited by Embass; 08-31-2020 at 05:17 AM.
Embass is offline   Reply With Quote
Old 08-31-2020, 05:16 AM   #58
WyattRice
Human being with feelings
 
WyattRice's Avatar
 
Join Date: Sep 2009
Location: Virginia
Posts: 2,067
Default

Quote:
Originally Posted by Sexan View Post
Make a area selection, press and hold your shortcut key and move your mouse, release when done
I messed with it again this morning.

In my settings I have pre fx envelopes set to fader scale for default.
It doesn't work with that setting.
When I changed to amplitude scale, it worked.

Is there any possibility that the envelope volume tooltips could work with this to display the dB's when dragging the envelopes up or down?
__________________
DDP To Cue Writer. | DDP Marker Editor.
WyattRice is offline   Reply With Quote
Old 08-31-2020, 06:05 AM   #59
musicbynumbers
Human being with feelings
 
musicbynumbers's Avatar
 
Join Date: Jun 2009
Location: South, UK
Posts: 14,214
Default

Quote:
Originally Posted by sonictim View Post
The first script I ever wrote was making an area selection that reverses itself to time selection. SO I thought I'd take you up on your challenge with area selection reverse. It works, but only if the shape is square.
Nice! Thanks

Works great one audio items.

Doesn't seem to work on Midi or automation items but even just on audio that's very useful!
__________________
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 08-31-2020, 08:58 AM   #60
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,589
Default

Quote:
Originally Posted by WyattRice View Post
I messed with it again this morning.

In my settings I have pre fx envelopes set to fader scale for default.
It doesn't work with that setting.
When I changed to amplitude scale, it worked.

Is there any possibility that the envelope volume tooltips could work with this to display the dB's when dragging the envelopes up or down?
Yeah I need to add converting scale modes... can add tooltips also
Sexan is online now   Reply With Quote
Old 08-31-2020, 09:23 AM   #61
Funkybot
Human being with feelings
 
Funkybot's Avatar
 
Join Date: Jul 2007
Location: New Joisey
Posts: 5,990
Default

Quote:
Originally Posted by Embass View Post
another swipe comping script (split and mute mode)
script:


it looks like this:
This looks like it will be a Godsend for speeding up vocal comping.

Question: will it respect groups? Example: multi-track drum editing where I may have each drum track grouped but takes in multiple lanes.
Funkybot is online now   Reply With Quote
Old 08-31-2020, 09:55 AM   #62
sonictim
Human being with feelings
 
sonictim's Avatar
 
Join Date: Feb 2020
Location: Los Angeles
Posts: 463
Default

Quote:
Originally Posted by musicbynumbers View Post
Nice! Thanks

Works great one audio items.

Doesn't seem to work on Midi or automation items but even just on audio that's very useful!
If I have some time next weekend, I’ll look into it. I don’t really use MIDI or automation items in my workflow yet, but I probably should at some point.
sonictim is offline   Reply With Quote
Old 08-31-2020, 09:57 AM   #63
sonictim
Human being with feelings
 
sonictim's Avatar
 
Join Date: Feb 2020
Location: Los Angeles
Posts: 463
Default

Quote:
Originally Posted by Sexan View Post
Yeah I need to add converting scale modes... can add tooltips also
I couldn’t get it to work either, but reading this, now I know why!
sonictim is offline   Reply With Quote
Old 08-31-2020, 11:02 AM   #64
deeb
Human being with feelings
 
deeb's Avatar
 
Join Date: Feb 2017
Posts: 4,812
Default

On envelopes it's obvious the advantages and benefit of multi horizontal areas .. I wish Devs at some point make this possible with razor edit
__________________
🙏🏻
deeb is offline   Reply With Quote
Old 08-31-2020, 11:11 AM   #65
Vagelis
Human being with feelings
 
Vagelis's Avatar
 
Join Date: Oct 2017
Location: Larisa, Greece
Posts: 3,795
Default

WOW, Embass thanks so much considering another comp version with mute. Amazing can't wait to try it!
Vagelis is offline   Reply With Quote
Old 08-31-2020, 11:11 AM   #66
Vagelis
Human being with feelings
 
Vagelis's Avatar
 
Join Date: Oct 2017
Location: Larisa, Greece
Posts: 3,795
Default

Quote:
Originally Posted by Sexan View Post
Will try something about that
Awesome
Vagelis is offline   Reply With Quote
Old 08-31-2020, 03:55 PM   #67
musicbynumbers
Human being with feelings
 
musicbynumbers's Avatar
 
Join Date: Jun 2009
Location: South, UK
Posts: 14,214
Default

Quote:
Originally Posted by sonictim View Post
I couldn’t get it to work either, but reading this, now I know why!
Thanks! Take your time on it but definitely a great script and one that I think a lot of people would be glad it's in there. I know it won't get used every project but for those times when you need it... It's there!
__________________
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 09-01-2020, 04:23 AM   #68
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,589
Default

Don't know how to make proper fader scaling to work. So someone with better envelope knowledge should modify the script (some funky math needs to be included and various conversions + step zones because its jumpy on certain volumes)
Sexan is online now   Reply With Quote
Old 09-01-2020, 05:53 AM   #69
schwa
Administrator
 
schwa's Avatar
 
Join Date: Mar 2007
Location: NY
Posts: 15,747
Default

Code:
#define DEF_SCALE 1.9905358527674863     // DB2VAL(12.0)*0.5
#define DEF_SCALE_I 0.25118864315095801  // 0.5/DEF_SCALE

double DEF_VAL2SLIDER(double x)
{
  double b=DEF_SCALE;
  double tmp=b*b+4.0*b*x;
  b=(-b+sqrt(tmp))*DEF_SCALE_I;
  b=pow(b, 0.3333333333333)*1000.0;
  return b;
}

double DEF_SLIDER2VAL(double y)
{
  y *= 0.001;
  y=y*y*y;
  y += y*y;
  y *= DEF_SCALE;
  return y;
}
schwa is offline   Reply With Quote
Old 09-01-2020, 05:58 AM   #70
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,589
Default

Thank you very much!

Lets see if I will manage something out of it

Edit: Nop, not that smart with envelopes, still not sure what I need to do. Convert everything to raw first, add value to it, convert back to scaling mode?

Code:
local DEF_SCALE = 1.9905358527674863     -- DB2VAL(12.0)*0.5
local DEF_SCALE_I = 0.25118864315095801  -- 0.5/DEF_SCALE

function DEF_VAL2SLIDER(x)
  local b = DEF_SCALE
  local tmp = b * b + 4.0 * b * x
  b = (-b + math.sqrt(tmp)) * DEF_SCALE_I
  b = (b ^ 0.3333333333333) * 1000.0
  return b
end

function DEF_SLIDER2VAL(y)
  y = y * 0.001
  y = y * y * y
  y = y + (y * y)
  y = y * DEF_SCALE
  return y
end
Btw ported code to lua if someone needs

Also:
Code:
local nudgeStep = 0.006
function update()
    local x , y = reaper.GetMousePosition()
    local dx = lx - x
    local dy = ly - y
    local mouse_p = X_to_pos(x)

    local mouse_val = nudgeStep * dy -- MOUSE VALUE + STEP

    for i = 1, #edits do
        if edits[i].env_points then
            local scale_mode = reaper.GetEnvelopeScalingMode( edits[i].env )

            for j = 1, #edits[i].env_points do
                local env = edits[i].env_points[j]
                
                -- WHAT TO DO HERE?

                local warp_offset = get_warp_offset(edits[i].areaStart, edits[i].areaEnd, env.time, mouse_val, MouseSide) -- WRAP LEFT/RIGT SIDE

                env.value = MouseSide ~= "Center" and env.value + warp_offset or env.value + mouse_val -- MOUSE IN CENTER OF RE TRIM VOLUME, ELSE WRAP EDGES (DEPENDING ON MOUSE POSITION)

                reaper.SetEnvelopePoint(edits[i].env, env.id, env.time, env.value , env.shape, env.tension, env.selected, true)
            end
        end
    end

    lx = x;
    ly = y;
end
This is the code that does magic

Last edited by Sexan; 09-01-2020 at 06:38 AM.
Sexan is online now   Reply With Quote
Old 09-01-2020, 07:47 AM   #71
deeb
Human being with feelings
 
deeb's Avatar
 
Join Date: Feb 2017
Posts: 4,812
Default

Omg all this things would be incredible useful if native (proper gui) and horizontal multi areas for RE. Not huge but HUGE!
__________________
🙏🏻
deeb is offline   Reply With Quote
Old 09-01-2020, 10:22 AM   #72
Mercado_Negro
Moderator
 
Mercado_Negro's Avatar
 
Join Date: Aug 2007
Location: Caracas, Venezuela
Posts: 8,676
Default

I can't wait to see all this implemented natively! Awesome stuff guys!
__________________
Pressure is what turns coal into diamonds - Michael a.k.a. Runaway
Mercado_Negro is offline   Reply With Quote
Old 09-01-2020, 04:02 PM   #73
BirdBird
Human being with feelings
 
BirdBird's Avatar
 
Join Date: Mar 2019
Posts: 425
Default

Updated the code snippets over on the first page. (Thanks to Sexan for helping out with various parts) The examples no longer fit in one post so will add them down below:


GetRazorEdits()
Returns a table that contains all the selections individually.
Every element in the table has the properties:
* areaStart ----> starting point of the selection
* areaEnd ----> end point of the selection
* track ----> track that the selection is on
* items ----> items in range between areaStart <--> areaEnd, will be empty on envelopes

* isEnvelope ----> will be true if the selection is on an envelope
* envelope ----> envelope that the selection contains
* envelopeName ----> name of the envelope (Volume, Pan etc.)
* envelopePoints ----> envelope points between areaStart <--> areaEnd
* GUID ----> GUID of the envelope the selection contains



Here is an example that moves all the items in selected areas to the starting point of the areas:
Code:
local selections = GetRazorEdits()
for i = 1, #selections do
    local areaData = selections[i]
    local items = areaData.items
    for j = 1, #items do
        local item = items[j]
        reaper.SetMediaItemPosition(item, areaData.areaStart, true)
    end
end


Another example that nudges envelope points upwards a little bit:
Code:
local nudgeAmount = 0.1
local selections = GetRazorEdits()
for i = 1, #selections do
    local selection = selections[i]
    if selection.isEnvelope then
        local points = selection.envelopePoints
        local envelope = selection.envelope
        
        --nudge points
        for j = #points, 1, -1 do 
            local point = points[j]
            reaper.SetEnvelopePoint(envelope, point.id, point.time, point.value + nudgeAmount, point.shape, point.tension, point.selected, false)
        end
        reaper.Envelope_SortPoints(envelope)
    end
end


SplitRazorEdits(razorEdits)
Splits all the items in selections and returns them in a table.
Example that splits and selects all the items in selected areas:
Code:
local selections = GetRazorEdits()
local items = SplitRazorEdits(selections)
for i = 1, #items do
    local item = items[i]
    reaper.SetMediaItemSelected(item, true)
end


SetTrackRazorEdit(track, areaStart, areaEnd, clearSelection)
Used to create razor edits on tracks.
Arguments:
* track ----> track used for the selection
* areaStart ----> starting point of the selection
* areaEnd ----> end point of the selection
* clearSelection ----> will remove existing areas on track if set to true

Example that sets razor edits to all selected items:
Code:
    local itemCount = reaper.CountSelectedMediaItems(0)
    for i = 0, itemCount - 1 do
        local item = reaper.GetSelectedMediaItem(0, i)
        local track = reaper.GetMediaItem_Track(item)
        
        local itemStartPosition = reaper.GetMediaItemInfo_Value(item, 'D_POSITION')
        local itemLength = reaper.GetMediaItemInfo_Value(item, 'D_LENGTH')
        local itemEndPosition = itemStartPosition + itemLength

        SetTrackRazorEdit(track, itemStartPosition, itemEndPosition, false)
    end

SetEnvelopeRazorEdit(envelope, areaStart, areaEnd, clearSelection, optional GUID)
Works the same as SetTrackRazorEdit()
GUID can be optionally passed in to avoid chunk parsing.

Example that creates razor edits across all envelopes in time selection:
Code:
    local startPos, endPos = reaper.GetSet_LoopTimeRange(false, false, 0, 0, false)
    local tracks = reaper.CountTracks(0)
    for i = 0, tracks - 1 do
        local track = reaper.GetTrack(0, i)
        if reaper.IsTrackVisible(track, false) then --track is visible in TCP
            local envelopeCount = reaper.CountTrackEnvelopes(track)
            for j = 0, envelopeCount - 1 do
                local envelope = reaper.GetTrackEnvelope(track, j)
                SetEnvelopeRazorEdit(envelope, startPos, endPos, true)
            end
        end
    end


Additionally, these two are used by other functions:

GetItemsInRange(track, areaStart, areaEnd)
* Returns media items on the track between areaStart <--> areaEnd

GetEnvelopePointsInRange(envelopeTrack, areaStart, areaEnd)
* Returns points on the envelope between areaStart <--> areaEnd
__________________
ReaScript Discord Server | Scripts | JSFX

Last edited by BirdBird; 09-01-2020 at 04:24 PM.
BirdBird is offline   Reply With Quote
Old 09-01-2020, 11:05 PM   #74
svijayrathinam
Human being with feelings
 
Join Date: May 2017
Posts: 981
Default

Quote:
Originally Posted by Sexan View Post
Some testing fun with envelopes:



How Do I get my hands on this amazing script pls ? 🙏

Is it on your reapack?
svijayrathinam is offline   Reply With Quote
Old 09-01-2020, 11:24 PM   #75
sonictim
Human being with feelings
 
sonictim's Avatar
 
Join Date: Feb 2020
Location: Los Angeles
Posts: 463
Default

I'm having some issues with the main block of code... I updated your functions somethings appears to be breaking on my end... it looks like it's happening on line 178...

envelope = reaper.GetTrackEnvelopeByChunkName(track, GUID:sub(2, -2))

It is not returning an envelope for me and then the next function breaks and prevents the code from running. Here's a bit more of the code on either side for context. It's part of the GetRazorEdits() function...


Code:
         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
sonictim is offline   Reply With Quote
Old 09-01-2020, 11:46 PM   #76
BirdBird
Human being with feelings
 
BirdBird's Avatar
 
Join Date: Mar 2019
Posts: 425
Default

Quote:
Originally Posted by sonictim View Post
I'm having some issues with the main block of code... I updated your functions somethings appears to be breaking on my end... it looks like it's happening on line 178...

envelope = reaper.GetTrackEnvelopeByChunkName(track, GUID:sub(2, -2))

It is not returning an envelope for me and then the next function breaks and prevents the code from running. Here's a bit more of the code on either side for context. It's part of the GetRazorEdits() function...


Code:
         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
Make sure you are on the latest pre-release. (GetTrackEnvelopeByChunkName got updated to return envelopes from GUID on the latest one)
__________________
ReaScript Discord Server | Scripts | JSFX
BirdBird is offline   Reply With Quote
Old 09-02-2020, 01:13 AM   #77
sonictim
Human being with feelings
 
sonictim's Avatar
 
Join Date: Feb 2020
Location: Los Angeles
Posts: 463
Default

Quote:
Originally Posted by BirdBird View Post
Make sure you are on the latest pre-release. (GetTrackEnvelopeByChunkName got updated to return envelopes from GUID on the latest one)
Hahaha! Duh!! Of course! Yup I missed one! Thanks!
sonictim is offline   Reply With Quote
Old 09-02-2020, 01:26 AM   #78
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,589
Default

Quote:
Originally Posted by svijayrathinam View Post
How Do I get my hands on this amazing script pls ? 🙏

Is it on your reapack?
Its posted here as as attachment, see the top of this page.

P.S. still did not implemented fader scaling, having hard time understanding conversions
Sexan is online now   Reply With Quote
Old 09-02-2020, 03:01 AM   #79
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,589
Default

One of the best features in my Area51 script coming up soon for RE:

Standard copy (ctrl+c)
Paste = Hold for preview, Release to paste


Last edited by Sexan; 09-02-2020 at 03:55 AM.
Sexan is online now   Reply With Quote
Old 09-02-2020, 05:12 AM   #80
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Quote:
Originally Posted by Sexan View Post
P.S. still did not implemented fader scaling, having hard time understanding conversions
Would these help (just in cased you missed it..):
ScaleFromEnvelopeMode, ScaleToEnvelopeMode.
nofish 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 06:04 AM.


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