Hello,
In addition to hiding an individual track from the "cog" menu in its panel, these are the Actions of which I'm aware that don't unarm the tracks when hidden and "Allow writing automation" for hidden envelopes is turned off:
- Track: Toggle track pan envelope visible
- Track: Toggle track volume envelope visible
- Envelope: Toggle hide/display selected envelope
- Track: Toggle track mute envelope visible
- Track: Toggle track pre-FX pan envelope visible
- Track: Toggle track trim envelope visible
Now, in addition to hiding them from the envelope manager or the track's envelope window, I'm finding that these actions all do unarm the tracks when "Allow writing automation" for hidden envelopes is turned off:
- Envelope: Hide all envelopes for tracks
- Envelope: Hide all envelopes for all tracks
- Toggle show all active envelopes for tracks
- Toggle show all active envelopes for all tracks
A sort-of-exception is that if an envelope does not have points added, it becomes inactive when hidden, thus showing it will also arm it. I don't know whether this behaviour has to do with one of my preferences.
What I set out to do with the following scripts was to create alternatives to those last two actions. Alternatives that behave the same except they don't unarm the envelopes.
If there is one or more visible envelopes on any of the targeted tracks, all will become hidden. If all are hidden, all become visible.
Disallowing automation writing to invisible envelopes still appears to do what it says, even if those envelopes are also armed.
THE SCRIPTS
"Toggle show all active envelopes for tracks without unarming" applies to selected tracks:
Code:
selTrackCount = reaper.CountSelectedTracks(0)
masterTrack = reaper.GetMasterTrack(0)
-- Check for any visible envelopes among all selected tracks.
for t = 0, selTrackCount, 1 do
-- After all normal selected tracks have been iterated, the master
-- track becomes the currentTrack (but only if it is selected, else
-- break).
if t == selTrackCount then
if reaper.IsTrackSelected(masterTrack) then
currentTrack = masterTrack
else break end
else
currentTrack = reaper.GetSelectedTrack(0, t)
end
envelopeCount = reaper.CountTrackEnvelopes(currentTrack)
-- Check all envelopes of the selected track for visible envelopes.
for i = 0, envelopeCount - 1, 1 do
currentEnvelope = reaper.GetTrackEnvelope(currentTrack, i)
_, chunk = reaper.GetEnvelopeStateChunk(currentEnvelope, "", 0)
_, visPos = chunk:find("VIS")
visPos = visPos + 2
if chunk:sub(visPos, visPos) == "1" then
-- If any visible envelopes, "0" will be used to make all envelopes invisible.
replacement = "0" break
end
end
end
-- If no visibile envelopes were found, "1" will be used to make all envelopes visible.
if not replacement then replacement = "1" end
-- Set visibility for all envelopes on all selected tracks.
for t = 0, selTrackCount, 1 do
if t == selTrackCount then
if reaper.IsTrackSelected(masterTrack) then
currentTrack = masterTrack
else break end
else
currentTrack = reaper.GetSelectedTrack(0, t)
end
envelopeCount = reaper.CountTrackEnvelopes(currentTrack)
for i = 0, envelopeCount - 1, 1 do
currentEnvelope = reaper.GetTrackEnvelope(currentTrack, i)
_, chunk = reaper.GetEnvelopeStateChunk(currentEnvelope, "", 0)
_, visPos = chunk:find("VIS")
visPos = visPos + 2
-- Replace visibility state in the chunk, then set it.
chunk = chunk:sub(1, visPos-1) .. replacement .. chunk:sub(visPos+1)
reaper.SetEnvelopeStateChunk(currentEnvelope, chunk, 0)
end
end
"Toggle show all active envelopes for all tracks without unarming" applies to all tracks in the project, regardless of selection:
Code:
trackCount = reaper.CountTracks(0)
-- Check for any visible envelopes among all tracks.
for t = 0, trackCount, 1 do
-- After all normal tracks have been iterated, the master track becomes
-- the currentTrack.
if t == trackCount then
currentTrack = reaper.GetMasterTrack(0)
else
currentTrack = reaper.GetTrack(0, t)
end
envelopeCount = reaper.CountTrackEnvelopes(currentTrack)
-- Check all envelopes of the selected track for visible envelopes.
for i = 0, envelopeCount - 1, 1 do
currentEnvelope = reaper.GetTrackEnvelope(currentTrack, i)
_, chunk = reaper.GetEnvelopeStateChunk(currentEnvelope, "", 0)
_, visPos = chunk:find("VIS")
visPos = visPos + 2
if chunk:sub(visPos, visPos) == "1" then
-- If any visible envelopes, "0" will be used to make all envelopes invisible.
replacement = "0" break
end
end
end
-- If no visible envelopes were found, "1" will be used to make all envelopes visible.
if not replacement then replacement = "1" end
-- Set visibility for all envelopes on all tracks.
for t = 0, trackCount, 1 do
if t == trackCount then
currentTrack = reaper.GetMasterTrack(0)
else
currentTrack = reaper.GetTrack(0, t)
end
envelopeCount = reaper.CountTrackEnvelopes(currentTrack)
for i = 0, envelopeCount - 1, 1 do
currentEnvelope = reaper.GetTrackEnvelope(currentTrack, i)
_, chunk = reaper.GetEnvelopeStateChunk(currentEnvelope, "", 0)
_, visPos = chunk:find("VIS")
visPos = visPos + 2
-- Replace visibility state in the chunk, then set it.
chunk = chunk:sub(1, visPos-1) .. replacement .. chunk:sub(visPos+1)
reaper.SetEnvelopeStateChunk(currentEnvelope, chunk, 0)
end
end
P.S. I updated this post a few times. There were some bugs. If you got the script before the last edit, re-copying may fix it.