-
Notifications
You must be signed in to change notification settings - Fork 183
Release Toggle Track Pitch Envelope v1.0 #1611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
cfillion
merged 3 commits into
ReaTeam:master
from
grayson-solis:reapack.com_upload-1751601972537
Jul 8, 2025
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
96 changes: 96 additions & 0 deletions
96
Envelopes/graysonsolis_Toggle ReaPitch shift (cents) envelope.lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| -- @description Toggle ReaPitch shift (cents) envelope | ||
| -- @author Grayson Solis | ||
| -- @version 1.0 | ||
| -- @about | ||
| -- Toggles Shift (cents) envelope lane for ReaPitch on selected track. Adds ReaPitch if missing. Similar to the "volume" or "pan" default track envelopes. | ||
| -- The parameter used can be toggled by editing the lines below! | ||
|
|
||
| reaper.PreventUIRefresh(1) | ||
| reaper.Undo_BeginBlock() | ||
|
|
||
| local track = reaper.GetSelectedTrack(0, 0) | ||
| if not track then | ||
| reaper.PreventUIRefresh(0) | ||
| return | ||
| end | ||
|
|
||
| local before = reaper.TrackFX_GetCount(track) | ||
|
|
||
| local fx_idx = reaper.TrackFX_AddByName(track, "ReaPitch (Cockos)", false, 0) | ||
| if fx_idx < 0 then | ||
| fx_idx = reaper.TrackFX_AddByName(track, "ReaPitch (Cockos)", false, 1) | ||
| end | ||
| if fx_idx < 0 then | ||
| reaper.ShowMessageBox("Could not add/find ReaPitch.", "Error", 0) | ||
| reaper.PreventUIRefresh(0) | ||
| return | ||
| end | ||
|
|
||
| reaper.TrackFX_Show(track, fx_idx, 2) | ||
|
|
||
| local added = (reaper.TrackFX_GetCount(track) > before) | ||
|
|
||
| --[[ | ||
|
|
||
| CUSTOMIZATION TIP | ||
| To select a different ReaPitch parameter envelope, change the value | ||
| of the `param` variable below to one of the following: | ||
|
|
||
| 0: Wet | ||
| 1: Dry | ||
| 2: Enabled | ||
| 3: Shift (full range) | ||
| 4: Shift (cents) <-- current default | ||
| 5: Shift (semitones) | ||
| 6: Shift (oct) | ||
| 7: Formant adjust (full range) | ||
| 8: Formant adjust (cents) | ||
| 9: Formant adjust (semitones) | ||
| 10: Volume | ||
| 11: Pan | ||
| 12: Bypass | ||
| 13: Wet | ||
| 14: Delta | ||
|
|
||
| For example, to toggle the envelope for "Shift (semitones)", set: | ||
|
|
||
| local param = 5 | ||
|
|
||
| --]] | ||
|
|
||
| local param = 3 -- Shift (cents) YOU CAN CHANGE THIS!!!! | ||
|
|
||
| local env = reaper.GetFXEnvelope(track, fx_idx, param, true) | ||
| if not env then | ||
| reaper.ShowMessageBox("Failed to access envelope.", "Error", 0) | ||
| reaper.PreventUIRefresh(0) | ||
| return | ||
| end | ||
|
|
||
| local ok, chunk = reaper.GetEnvelopeStateChunk(env, "", false) | ||
| if not ok then | ||
| reaper.ShowMessageBox("Failed to read envelope.", "Error", 0) | ||
| reaper.PreventUIRefresh(0) | ||
| return | ||
| end | ||
|
|
||
|
|
||
| local show | ||
| if added then | ||
| show = true | ||
| else | ||
| local v1,v2,v3 = chunk:match("VIS (%d+) (%d+) (%d+)") | ||
| show = not (v1 == "1" and v2 == "1" and v3 == "1") | ||
| end | ||
|
|
||
| chunk = chunk | ||
| :gsub("ACT %d+", "ACT " .. (show and 1 or 0)) | ||
| :gsub("VIS %d+ %d+ %d+", "VIS " .. (show and "1 1 1" or "0 0 0")) | ||
| :gsub("ARM %d+", "ARM " .. (show and 1 or 0)) | ||
| :gsub("DEFSHAPE %d+", "DEFSHAPE 0") | ||
|
|
||
| reaper.SetEnvelopeStateChunk(env, chunk, false) | ||
| reaper.TrackList_AdjustWindows(false) | ||
| reaper.UpdateArrange() | ||
| reaper.Undo_EndBlock("Toggle ReaPitch shift (cents) envelope (default height)", 0) | ||
| reaper.PreventUIRefresh(0) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, while this line here (and same a bit below) is
correctly undoingthePreventUIRefreshfrom above, it forgets to the the same forUndo_BeginBlock.An easy solution would be to wait until later before enabling
PreventUIRefreshandUndo_BeginBlock. 😉Thankfully REAPER has a fail-safe against scripts doing this kind of mistake so there are no ill effects.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Schwa suggests here https://forum.cockos.com/showpost.php?p=2297817&postcount=2
Is 0 a valid argument as well?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, nope it is not. (Well, not "invalid" per se, but adding 0 just does nothing.)