Skip to content

Commit

Permalink
Release Protools rudimentary editing tools v1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fredKuko committed Nov 30, 2024
1 parent e8b4fcc commit 8a579e7
Show file tree
Hide file tree
Showing 7 changed files with 408 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Items Editing/FKVC_ProtoolsEditingTools1.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
-- @description Protools rudimentary editing tools
-- @author Frederic Kukovicic
-- @version 1.0
-- @provides
-- [main] FKVC_ProtoolsEditingTools1/CutLeft.lua
-- [main] FKVC_ProtoolsEditingTools1/CutRight.lua
-- [main] FKVC_ProtoolsEditingTools1/MoveEditCursorToNextCut.lua
-- [main] FKVC_ProtoolsEditingTools1/MoveEditCursorToPreviousCut.lua
-- [main] FKVC_ProtoolsEditingTools1/NudgeCursorOnTheLeft.lua
-- [main] FKVC_ProtoolsEditingTools1/NudgeCursorOnTheRight.lua
-- @about
-- # Protools rudimentary editing tools
--
-- As a long-time Pro Tools user, I relied heavily on certain daily tools for audio editing. To replicate those tools and workflows in Reaper, I decided to script similar actions so I could use them in Reaper as well. Here are the actions I recreated:
--
-- - CutLeft: Removes the left part of the selected media item from the playback position.
--
-- - CutRight: Removes the right part of the selected media item from the playback position.
--
-- - MoveEditCursorToNextCut: Moves the edit cursor to the next cut in any media item and selects it.
--
-- - MoveEditCursorToPreviousCut: Moves the edit cursor to the previous cut in any media item and selects it.
--
-- Note: The "move edit cursor" actions work on the currently selected track, or only on the first track if multiple tracks are selected.
--
-- - NudgeCursorToTheLeft: Moves the playback cursor 1 frame to the left and plays the audio.
--
-- - NudgeCursorToTheRight: Moves the playback cursor 1 frame to the right and plays the audio.

reaper.ShowMessageBox("Thank you for using this tool. Have fun!", "Message", 0)
47 changes: 47 additions & 0 deletions Items Editing/FKVC_ProtoolsEditingTools1/CutLeft.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
-- @noindex

-- Global variables --

item = reaper.GetSelectedMediaItem(0,0);
itemLength = reaper.GetMediaItemInfo_Value(item,"D_LENGTH");
itemPosition = reaper.GetMediaItemInfo_Value(item,"D_POSITION");
cursorPosition = reaper.GetCursorPosition();
refreshUI = true;

----------------------------------------------------------------------
function Reverse()
reaper.Main_OnCommand(41051,0);
end
----------------------------------------------------------------------
function Cut()

local refrshUI = false;
reaper.SetMediaItemLength(item, right, refreshUI);
end
----------------------------------------------------------------------
function MoveToCursor()

reaper.SetMediaItemPosition(item, cursorPosition, refreshUI);
end
----------------------------------------------------------------------
function Operations()
itemEnd = itemPosition + itemLength;
right = itemEnd - cursorPosition;
end
----------------------------------------------------------------------
-- Main Function --

function CutLeft()

reaper.Undo_BeginBlock()
Operations();
Reverse();
Cut();
Reverse();
MoveToCursor();
reaper.Undo_EndBlock("Cut Left",0)
end
----------------------------------------------------------------------
-- Action --

CutLeft();
37 changes: 37 additions & 0 deletions Items Editing/FKVC_ProtoolsEditingTools1/CutRight.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
-- @noindex

-- Global variables --

item = reaper.GetSelectedMediaItem(0,0);
itemPosition = reaper.GetMediaItemInfo_Value(item,"D_POSITION");
cursorPosition = reaper.GetCursorPosition();
refreshUI = true;

----------------------------------------------------------------------------------------------------------------------
function Operations()

itemStart = itemPosition;
left = cursorPosition - itemStart;

end

function Cut()

local refrshUI = false;
reaper.SetMediaItemLength(item, left, refreshUI); -- resize the item to the length of "left" by cutting "right".

end
----------------------------------------------------------------------------------------------------------------------
-- Main Function --

function CutRight()

Operations();
Cut();

end

----------------------------------------------------------------------------------------------------------------------
-- Action --

CutRight();
134 changes: 134 additions & 0 deletions Items Editing/FKVC_ProtoolsEditingTools1/MoveEditCursorToNextCut.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
-- @noindex

-- Global Variables --

cursorPos = reaper.GetCursorPosition(0);
currentTrack = reaper.GetSelectedTrack(0,0);

i = 0;
t = 0;

iMax = reaper.CountTrackMediaItems(currentTrack);
iLast = iMax - 1;

----------------------------------------------------------------------------------------------------------------------------------------------------
function MoveCursorToStartOfFirstItem()

reaper.SetEditCurPos(firstItemStart, moveview == true, seekplay == true)

end
----------------------------------------------------------------------------------------------------------------------------------------------------
function MoveCursorToStartOfItem()

reaper.SetEditCurPos(nextItemStart, moveview == true, seekplay == true)

end
----------------------------------------------------------------------------------------------------------------------------------------------------
function MoveCursorToEndOfItem()

reaper.SetEditCurPos(iEnd, moveview == true, seekplay == true)

end
----------------------------------------------------------------------------------------------------------------------------------------------------
function MoveCursorToEndOfLastItem()

reaper.SetEditCurPos(lastItemEnd, moveview == true, seekplay == true)

end
----------------------------------------------------------------------------------------------------------------------------------------------------
function SelectNextItem()

reaper.SetMediaItemSelected(nextItem, 1);

end
----------------------------------------------------------------------------------------------------------------------------------------------------
function SelectFirstItem()

reaper.SetMediaItemSelected(firstItem, 1);

end
----------------------------------------------------------------------------------------------------------------------------------------------------
function UnselectAllItems()

reaper.SelectAllMediaItems(0,0);

end
----------------------------------------------------------------------------------------------------------------------------------------------------
function MoveEditCursorToNextCut()

if iMax == 0
then return
end

for i = 0, iMax do

firstItem = reaper.GetTrackMediaItem(currentTrack,0)
firstItemStart = reaper.GetMediaItemInfo_Value(firstItem, "D_POSITION")

if cursorPos < firstItemStart

then

MoveCursorToStartOfFirstItem()
SelectFirstItem()

else

currentItem = reaper.GetTrackMediaItem(currentTrack,i);
iStart = reaper.GetMediaItemInfo_Value(currentItem,"D_POSITION");
iLength = reaper.GetMediaItemInfo_Value(currentItem,"D_LENGTH");
iEnd = iStart + iLength;

n = i + 1;
nextItem = reaper.GetTrackMediaItem(currentTrack,n);

if n ~= iMax
then nextItemStart = reaper.GetMediaItemInfo_Value(nextItem,"D_POSITION");
end

lastItem = reaper.GetTrackMediaItem(currentTrack,iLast);
lastItemStart = reaper.GetMediaItemInfo_Value(lastItem,"D_POSITION");
lastItemLength = reaper.GetMediaItemInfo_Value(lastItem,"D_LENGTH");
lastItemEnd = lastItemStart + lastItemLength;

if cursorPos >= iStart and cursorPos < iEnd
then
if nextItemStart == iEnd
then
UnselectAllItems();
SelectNextItem();
MoveCursorToEndOfItem();
break
else
MoveCursorToEndOfItem();
break
end
end

if iMax > 1
then
if cursorPos < nextItemStart and cursorPos >= iEnd
then
UnselectAllItems();
SelectNextItem();
MoveCursorToStartOfItem();
SelectNextItem();
break
end
else return
end

if cursorPos >= lastItemEnd
then break
end

end

end

end

----------------------------------------------------------------------------------------------------------------------------------------------------
-- Action --
MoveEditCursorToNextCut();

Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
-- @noindex

-- Global Variables --

cursorPos = reaper.GetCursorPosition(0);
currentTrack = reaper.GetSelectedTrack(0,0);

i = 0;
t = 0;

iMax = reaper.CountTrackMediaItems(currentTrack);
iLast = iMax-1;

----------------------------------------------------------------------------------------------------------------------------------------------------
function MoveCursorToStartOfFirstItem()

reaper.SetEditCurPos(firstItemStart, moveview == true, seekplay == true)

end
----------------------------------------------------------------------------------------------------------------------------------------------------
function MoveCursorToStartOfItem()

reaper.SetEditCurPos(iStart, moveview == true, seekplay == true)

end
----------------------------------------------------------------------------------------------------------------------------------------------------
function MoveCursorToEndOfPreviousItem()

reaper.SetEditCurPos(previousItemEnd, moveview == true, seekplay == true)

end
----------------------------------------------------------------------------------------------------------------------------------------------------
function MoveCursorToEndOfLastItem()

reaper.SetEditCurPos(lastItemEnd, moveview == true, seekplay == true)

end
----------------------------------------------------------------------------------------------------------------------------------------------------
function SelectPreviousItem()

reaper.SetMediaItemSelected(previousItem, 1);

end
----------------------------------------------------------------------------------------------------------------------------------------------------
function SelectLastItem()

reaper.SetMediaItemSelected(lastItem, 1);

end
----------------------------------------------------------------------------------------------------------------------------------------------------
function UnselectAllItems()

reaper.SelectAllMediaItems(0,0);

end
----------------------------------------------------------------------------------------------------------------------------------------------------
-- Main Function --

function MoveEditCursorToNextCut()

if iMax == 0
then return
end

for i = 0, iLast do

firstItem = reaper.GetTrackMediaItem(currentTrack,0)
firstItemStart = reaper.GetMediaItemInfo_Value(firstItem, "D_POSITION")

if cursorPos <= firstItemStart

then break

else if cursorPos > firstItemStart

then

currentItem = reaper.GetTrackMediaItem(currentTrack,i);
iStart = reaper.GetMediaItemInfo_Value(currentItem,"D_POSITION");
iLength = reaper.GetMediaItemInfo_Value(currentItem,"D_LENGTH");
iEnd = iStart + iLength;

p = i-1;
previousItem = reaper.GetTrackMediaItem(currentTrack,p);

if p ~= -1
then
previousItemStart = reaper.GetMediaItemInfo_Value(previousItem,"D_POSITION");
previousItemLength = reaper.GetMediaItemInfo_Value(previousItem,"D_LENGTH");
previousItemEnd = previousItemStart + previousItemLength;
else previousItem = firstItem;
end

lastItem = reaper.GetTrackMediaItem(currentTrack,iLast);
lastItemStart = reaper.GetMediaItemInfo_Value(lastItem,"D_POSITION");
lastItemLength = reaper.GetMediaItemInfo_Value(lastItem,"D_LENGTH");
lastItemEnd = lastItemStart + lastItemLength;

if cursorPos > iStart and cursorPos <= iEnd
then
if iStart == previousItemEnd
then
UnselectAllItems();
SelectPreviousItem();
MoveCursorToStartOfItem();
break
else
MoveCursorToStartOfItem();
break
end
end

if cursorPos <= iStart and cursorPos > previousItemEnd
then
UnselectAllItems();
SelectPreviousItem();
MoveCursorToEndOfPreviousItem();
break
end

if cursorPos > lastItemEnd
then
MoveCursorToEndOfLastItem()
SelectLastItem()
end
end
end
end
end

----------------------------------------------------------------------------------------------------------------------------------------------------
-- Action --

MoveEditCursorToNextCut();
Loading

0 comments on commit 8a579e7

Please sign in to comment.