Old 08-08-2019, 07:23 AM   #1
Coachz
Human being with feelings
 
Coachz's Avatar
 
Join Date: Oct 2010
Location: Charleston, SC USA
Posts: 7,112
Default Action / API to enable master track volume

Is there a way to enable the master track volume ? I don't see an action or a function in the API listings. Thanks !

Coachz is offline   Reply With Quote
Old 08-08-2019, 07:51 AM   #2
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 1,255
Default

This should set Volume envelope active on Master track...


EDIT This is probably better, uses API to get envelope type..
Code:
local track = reaper.GetMasterTrack(0)
if track then
  local env_count = reaper.CountTrackEnvelopes(track) 
  for j = 0, env_count-1 do
    local env = reaper.GetTrackEnvelope(track, j)
    local br_env = reaper.BR_EnvAlloc(env, false)
    local active, visible, armed, inLane, laneHeight, defaultShape, _, _, _, env_type, faderScaling = reaper.BR_EnvGetProperties(br_env) 
    if (env_type == 0) then -- 0->Volume, 1->Volume (Pre-FX), 2->Pan, 3->Pan (Pre-FX), etc..
      if not active then
        reaper.BR_EnvSetProperties(br_env, true, visible, armed, inLane, laneHeight, defaultShape, faderScaling)
        reaper.BR_EnvFree(br_env, true)
      else
        reaper.BR_EnvFree(br_env, false)
      end      
      break
    else
      reaper.BR_EnvFree(br_env, false)
    end  
  end
end
First draft, detect env by name,..
Code:
local track = reaper.GetMasterTrack(0)
if track then
  local env_count = reaper.CountTrackEnvelopes(track) 
  for j = 0, env_count-1 do
    local env = reaper.GetTrackEnvelope(track, j)
    local _, name = reaper.GetEnvelopeName(env, "")
    if name == 'Volume' then
      local br_env = reaper.BR_EnvAlloc(env, false)
      local active, visible, armed, inLane, laneHeight, defaultShape, _, _, _, _, faderScaling = reaper.BR_EnvGetProperties(br_env)
      if not active then
        reaper.BR_EnvSetProperties(br_env, true, visible, armed, inLane, laneHeight, defaultShape, faderScaling)
        reaper.BR_EnvFree(br_env, true)
      else
        reaper.BR_EnvFree(br_env, false) 
      end  
      break
    end 
  end
end

Last edited by Edgemeal; 08-08-2019 at 08:59 AM. Reason: FIX first script
Edgemeal is offline   Reply With Quote
Old 08-08-2019, 08:56 AM   #3
Coachz
Human being with feelings
 
Coachz's Avatar
 
Join Date: Oct 2010
Location: Charleston, SC USA
Posts: 7,112
Default

wow, you are amazing. Thanks a million for the killer script. It works great !!

Coachz is offline   Reply With Quote
Old 08-08-2019, 09:01 AM   #4
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 1,255
Default

LOL! Updated 1st script again. It be amazing if I could post correct code on first try.
Edgemeal 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:06 AM.


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