From 8a579e74116d58c2041ad274d2a18af90eff46f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Kukovicic?= <74264340+fredKuko@users.noreply.github.com> Date: Sun, 1 Dec 2024 00:52:33 +0100 Subject: [PATCH] Release Protools rudimentary editing tools v1.0 --- Items Editing/FKVC_ProtoolsEditingTools1.lua | 30 ++++ .../FKVC_ProtoolsEditingTools1/CutLeft.lua | 47 ++++++ .../FKVC_ProtoolsEditingTools1/CutRight.lua | 37 +++++ .../MoveEditCursorToNextCut.lua | 134 ++++++++++++++++++ .../MoveEditCursorToPreviousCut.lua | 134 ++++++++++++++++++ .../NudgeCursorOnTheLeft.lua | 13 ++ .../NudgeCursorOnTheRight.lua | 13 ++ 7 files changed, 408 insertions(+) create mode 100644 Items Editing/FKVC_ProtoolsEditingTools1.lua create mode 100644 Items Editing/FKVC_ProtoolsEditingTools1/CutLeft.lua create mode 100644 Items Editing/FKVC_ProtoolsEditingTools1/CutRight.lua create mode 100644 Items Editing/FKVC_ProtoolsEditingTools1/MoveEditCursorToNextCut.lua create mode 100644 Items Editing/FKVC_ProtoolsEditingTools1/MoveEditCursorToPreviousCut.lua create mode 100644 Items Editing/FKVC_ProtoolsEditingTools1/NudgeCursorOnTheLeft.lua create mode 100644 Items Editing/FKVC_ProtoolsEditingTools1/NudgeCursorOnTheRight.lua diff --git a/Items Editing/FKVC_ProtoolsEditingTools1.lua b/Items Editing/FKVC_ProtoolsEditingTools1.lua new file mode 100644 index 000000000..68556900e --- /dev/null +++ b/Items Editing/FKVC_ProtoolsEditingTools1.lua @@ -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) diff --git a/Items Editing/FKVC_ProtoolsEditingTools1/CutLeft.lua b/Items Editing/FKVC_ProtoolsEditingTools1/CutLeft.lua new file mode 100644 index 000000000..2a68f4751 --- /dev/null +++ b/Items Editing/FKVC_ProtoolsEditingTools1/CutLeft.lua @@ -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(); diff --git a/Items Editing/FKVC_ProtoolsEditingTools1/CutRight.lua b/Items Editing/FKVC_ProtoolsEditingTools1/CutRight.lua new file mode 100644 index 000000000..a89401da6 --- /dev/null +++ b/Items Editing/FKVC_ProtoolsEditingTools1/CutRight.lua @@ -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(); diff --git a/Items Editing/FKVC_ProtoolsEditingTools1/MoveEditCursorToNextCut.lua b/Items Editing/FKVC_ProtoolsEditingTools1/MoveEditCursorToNextCut.lua new file mode 100644 index 000000000..bb4bb1f75 --- /dev/null +++ b/Items Editing/FKVC_ProtoolsEditingTools1/MoveEditCursorToNextCut.lua @@ -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(); + diff --git a/Items Editing/FKVC_ProtoolsEditingTools1/MoveEditCursorToPreviousCut.lua b/Items Editing/FKVC_ProtoolsEditingTools1/MoveEditCursorToPreviousCut.lua new file mode 100644 index 000000000..6c2ca4de3 --- /dev/null +++ b/Items Editing/FKVC_ProtoolsEditingTools1/MoveEditCursorToPreviousCut.lua @@ -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(); diff --git a/Items Editing/FKVC_ProtoolsEditingTools1/NudgeCursorOnTheLeft.lua b/Items Editing/FKVC_ProtoolsEditingTools1/NudgeCursorOnTheLeft.lua new file mode 100644 index 000000000..123a8db47 --- /dev/null +++ b/Items Editing/FKVC_ProtoolsEditingTools1/NudgeCursorOnTheLeft.lua @@ -0,0 +1,13 @@ +-- @noindex + +-- Global Variables -- +cursorPos = reaper.GetCursorPosition(0); +ips = reaper.TimeMap_curFrameRate(0); +sMax = -1/ips; +---------------------------------------------------------------------------------- +function MoveCursorOnLeft() + reaper.MoveEditCursor(sMax, 0); +end +---------------------------------------------------------------------------------- +-- Action -- +MoveCursorOnLeft(); diff --git a/Items Editing/FKVC_ProtoolsEditingTools1/NudgeCursorOnTheRight.lua b/Items Editing/FKVC_ProtoolsEditingTools1/NudgeCursorOnTheRight.lua new file mode 100644 index 000000000..81c50429f --- /dev/null +++ b/Items Editing/FKVC_ProtoolsEditingTools1/NudgeCursorOnTheRight.lua @@ -0,0 +1,13 @@ +-- @noindex + +-- Global Variables -- +cursorPos = reaper.GetCursorPosition(0); +ips = reaper.TimeMap_curFrameRate(0); +sMax = 1/ips; +---------------------------------------------------------------------------------- +function MoveCursorOnRight() + reaper.MoveEditCursor(sMax, 0); +end +---------------------------------------------------------------------------------- +-- Action -- +MoveCursorOnRight();