Skip to content

Commit

Permalink
Release Propagate project Pitch Shift mode to all takes with default …
Browse files Browse the repository at this point in the history
…mode v1.2 (#1313)

Fixed bug with incorrect stretch marker mode
  • Loading branch information
AZpercussion authored Feb 9, 2024
1 parent 28065ab commit 00f9a83
Showing 1 changed file with 31 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
-- @description Propagate project Pitch Shift mode to all takes with default mode
-- @author AZ
-- @version 1.1
-- @changelog Fixed major bug with multiply items changing
-- @version 1.2
-- @changelog Fixed bug with incorrect stretch marker mode
-- @link Forum thread https://forum.cockos.com/showthread.php?t=288069
-- @donation Donate via PayPal https://www.paypal.me/AZsound
-- @about
-- #Propagate project Pitch Shift mode to all takes with default mode
-- # Propagate project Pitch Shift mode to all takes with default mode
--
-- Useful for copying content to other projects.
--
-- Just select items and run the script.
--
-- NOTE: Project has to be saved in file to let the script access to its actual settings.

--Version 1.0
--Date 06.03.2023
--Version 1.2
--Date 08.02.2023

--FUNCTIONS--

Expand All @@ -27,13 +29,16 @@ function SetMode(item)
local prj, projfn = reaper.EnumProjects( -1 )
--msg(projfn)

if (PrjSaved==nil)and (reaper.IsProjectDirty(0)==1 or projfn == '') then
if (PrjSaved==nil) and (reaper.IsProjectDirty(0)==1 or projfn == '') then
PrjSaved = reaper.ShowMessageBox
("The project has to be saved before action.\nDo you want to save the project?","Set pitch shift mode",4)
if PrjSaved == 6 then
reaper.Main_SaveProject(0, false)
prj, projfn = reaper.EnumProjects( -1 )
else return false end
else
EditsCount = nil
return false
end
end

if projfn ~= '' then
Expand Down Expand Up @@ -71,7 +76,13 @@ function SetMode(item)
EditsCount = EditsCount+1 --just for statistics
end
if tonumber(PLAYRATE[5]) < 0 then PLAYRATE[5] = PrjMode.pitch end
if tonumber(PLAYRATE[6]) == 0 then PLAYRATE[6] = PrjMode.stretch end
if tonumber(PLAYRATE[6]) == 0 then
if tonumber(PrjMode.stretch) < 2 then
PLAYRATE[6] = tonumber(PrjMode.stretch)+1
else
PLAYRATE[6] = tonumber(PrjMode.stretch)+2
end
end

line = table.concat(PLAYRATE,' ')
--msg(line)
Expand Down Expand Up @@ -103,7 +114,9 @@ function main()
for t=0, takeCount-1 do
local take = reaper.GetTake(item,t)
local mode = reaper.GetMediaItemTakeInfo_Value(take,'I_PITCHMODE')
if mode < 0 then
local strflgs = reaper.GetMediaItemTakeInfo_Value(take,'I_STRETCHFLAGS')

if mode < 0 or strflgs == 0 then
if SetMode(item) == true then break
else goto exit end
end
Expand All @@ -119,10 +132,16 @@ reaper.PreventUIRefresh(1)
reaper.Undo_BeginBlock()

main()
if EditsCount>0 then
UndoString = 'Propagate project pitch mode to takes'
reaper.ShowMessageBox('Takes were adopted: '..EditsCount,"Done",0)

if EditsCount ~= nil then
if EditsCount>0 then
UndoString = 'Propagate project pitch mode to takes'
reaper.ShowMessageBox('Done!\n Takes were adopted: '..EditsCount,"Propagate Pitch shift mode",0)
else
reaper.ShowMessageBox('There is nothing to change',"Propagate Pitch shift mode",0)
end
end

if UndoString then
reaper.Undo_EndBlock2(0, UndoString, -1)
reaper.UpdateArrange()
Expand Down

0 comments on commit 00f9a83

Please sign in to comment.