Old 09-21-2022, 03:41 PM   #1
ferropop
Human being with feelings
 
ferropop's Avatar
 
Join Date: Jan 2016
Location: Los Angeles, CA
Posts: 1,778
Default Razor Edit on Env : set to MIN-0-MAX

Are there any existing scripts that might achieve these 3 actions?

ORIGINAL :



MIN :



ZERO :



MAX :



I envision being able to "navigate" a Razor Edit selection over an Envelope with the arrow keys, and have quick actions to set between MIN-0-MAX and maybe actions to Expand/Compress RE, all from the keyboard.
__________________
Songs I've Written/Produced : https://sptfy.com/7SIW
Instagram : http://www.instagram.com/ferropop

Last edited by ferropop; 09-21-2022 at 04:17 PM.
ferropop is offline   Reply With Quote
Old 09-22-2022, 11:59 AM   #2
BirdBird
Human being with feelings
 
BirdBird's Avatar
 
Join Date: Mar 2019
Posts: 382
Default

value = 0 ------ minimum envelope value
value = 1 ------ maximum envelope value
value = (0, 1) - all the values between (ie. 0.5 will be halfway up the envelope)
It will be slightly off for track volume envelopes between (0, 1), but 0 and 1 will be accurate, requires SWS.
Code:
local value = 0.5 --tweak this

local o = 0.00001; 
reaper.Undo_BeginBlock(); reaper.PreventUIRefresh(1)
for i = 0, reaper.CountTracks(0) - 1 do
  local track = reaper.GetTrack(0, i)
  local _, re = reaper.GetSetMediaTrackInfo_String(track, 'P_RAZOREDITS', '', false)
  for s, e, GUID in string.gmatch(re, "(%S+) (%S+) (%S+)") do 
    if GUID == '""' then goto continue end
    for j = 0, reaper.CountTrackEnvelopes(track) - 1 do 
      local envelope = reaper.GetTrackEnvelope(track, j)
      local _, env_guid = reaper.GetSetEnvelopeInfo_String(envelope, 'GUID', '', false)
      local _, _, r_GUID = string.find(GUID, '%"(.+)%"')
      if r_GUID == env_guid then
        local br_env = reaper.BR_EnvAlloc(envelope, true)
        local _, _, _, _, _, _, min, max, _, _, fader_scaling, _ = reaper.BR_EnvGetProperties(br_env); reaper.BR_EnvFree(br_env, false)
        local r_val = min + (max - min)*value
        if fader_scaling then r_val = reaper.ScaleToEnvelopeMode(1, r_val) end
        
        local s, e = tonumber(s), tonumber(e)
        local _, sv = reaper.Envelope_Evaluate(envelope, s - o, 0, 0)
        local _, ev = reaper.Envelope_Evaluate(envelope, e + o, 0, 0)
        local _, pr_ev = reaper.Envelope_Evaluate(envelope, s - o, 0, 0)
        local _, n_ev = reaper.Envelope_Evaluate(envelope, e + o, 0, 0)
        reaper.DeleteEnvelopePointRange(envelope, s - o, e + o)
        if pr_ev ~= r_val then reaper.InsertEnvelopePoint(envelope, s, sv, 0, 0, false, true) end
        if n_ev ~= r_val then reaper.InsertEnvelopePoint(envelope, e, ev, 0, 0, false, true) end
        reaper.InsertEnvelopePoint(envelope, s + o, r_val, 0, 0, false, true)
        reaper.InsertEnvelopePoint(envelope, e - o, r_val, 0, 0, false, true)
        reaper.Envelope_SortPoints(envelope)
      end
    end
    ::continue::
  end
end
reaper.PreventUIRefresh(-1)
reaper.Undo_EndBlock("Set envelope range to: " .. math.floor(value*100 + 0.5) .. "%", -1)
BirdBird is offline   Reply With Quote
Old 09-22-2022, 01:10 PM   #3
ferropop
Human being with feelings
 
ferropop's Avatar
 
Join Date: Jan 2016
Location: Los Angeles, CA
Posts: 1,778
Default

BirBird you are a beast, thank you.

For the "0" state with envelopes like Track Volume, I'm trying to hack in a "reset points to default" line at the very end, which should properly set them to 0dB rather than being off like you mentioned.
__________________
Songs I've Written/Produced : https://sptfy.com/7SIW
Instagram : http://www.instagram.com/ferropop
ferropop is offline   Reply With Quote
Old 09-22-2022, 05:46 PM   #4
ferropop
Human being with feelings
 
ferropop's Avatar
 
Join Date: Jan 2016
Location: Los Angeles, CA
Posts: 1,778
Default

And also gonna try to figure out "tilting" the razor selection.

Wouuld be SO fast to edit envelopes based on the grid using the numpad, 4 + 6 being L + R, 7 + 9 tilting UP the Top Left/Right respectively, 1 + 3 tilting DOWN the Botton Left/Right respectively. And with the BirdBird script above, 8 would MAX, 2 would MIN, 5 would RESET.

A complete workflow for ripping up the envelope lane with grid-based edits.
__________________
Songs I've Written/Produced : https://sptfy.com/7SIW
Instagram : http://www.instagram.com/ferropop
ferropop is offline   Reply With Quote
Old 09-22-2022, 05:51 PM   #5
ferropop
Human being with feelings
 
ferropop's Avatar
 
Join Date: Jan 2016
Location: Los Angeles, CA
Posts: 1,778
Default



It's a start!

...now thinking the ability to Grow/Shrink the razor edit out to the next gridline, from the Num Pad (maybe with a modifier on 2+6) would complete this.

...also modifier on 8+2 (up/down) to "Shift RE contents up/down a bit" to get variations between MIN/RESET/MAX would be vibesss.

All from the numpad!
__________________
Songs I've Written/Produced : https://sptfy.com/7SIW
Instagram : http://www.instagram.com/ferropop

Last edited by ferropop; 09-22-2022 at 06:23 PM.
ferropop 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 03:52 AM.


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