Skip to content

Commit

Permalink
Release Minimize all track envelopes 1.0 (Initial Release) (#1410)
Browse files Browse the repository at this point in the history
  • Loading branch information
BenTalagan authored Jul 3, 2024
1 parent 87f9ebf commit b51dfa0
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions Envelopes/talagan_Minimize all track envelopes.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
--[[
@description Minimize all track envelopes
@version 1.0
@author Ben 'Talagan' Babut
@license MIT
@donation
https://www.paypal.com/donate/?business=3YEZMY9D6U8NC&no_recurring=1&currency_code=EUR
@changelog
- Initial release
@about
This script simply minimizes all track envelopes (it sets their heights to their minimum)
--]]

local function perform()

-- Modifying the envelope state chunk does not allow to have an undo entry
-- ... so undo is not possible, it seems. Let's still handle it as we should.
reaper.Undo_BeginBlock();

-- Loop on all tracks
local tn = reaper.CountTracks(0);
local ti = 0
for ti = 0, tn-1, 1 do
local track = reaper.GetTrack(0,ti);
local en = reaper.CountTrackEnvelopes(track);

-- Loop on each envelope for the current track
for ei = 0, en-1, 1 do
local evl = reaper.GetTrackEnvelope(track, ei);

-- ... and patch the height through the state chunk
_, str = reaper.GetEnvelopeStateChunk(evl, "", false);
str = str:gsub("\nLANEHEIGHT %d+ %d+\n", "\nLANEHEIGHT 0 0\n");
reaper.SetEnvelopeStateChunk(evl,str);
end
end

reaper.Undo_EndBlock("Minimized all track envelopes",-1);
end

perform()

0 comments on commit b51dfa0

Please sign in to comment.