diff --git a/RCEditing/RCEditing.lua b/RCEditing/RCEditing.lua deleted file mode 100644 index db99c111..00000000 --- a/RCEditing/RCEditing.lua +++ /dev/null @@ -1,36 +0,0 @@ -@description ReaClassical S-D Editing Tools -@author chmaha -@version 1.0pre0902 -@changelog - Initial release of just the editing functions from ReaClassical -@metapackage -@provides - [main] RCEditing_Add Destination IN marker.lua - [main] RCEditing_Add Destination OUT Marker.lua - [main] RCEditing_Add Source IN marker.lua - [main] RCEditing_Add Source OUT marker.lua - [main] RCEditing_Delete All S-D markers.lua - [main] RCEditing_Prepare Takes.lua - [main] RCEditing_S-D Edit.lua - [main] RCEditing_Delete Leaving Silence.lua - [main] RCEditing_Delete With Ripple.lua - [main] RCEditing_Insert with timestretching.lua - [main] RCEditing_Preferences.lua - [main] RCEditing_Move to Destination IN marker.lua - [main] RCEditing_Move to Destination OUT marker.lua - [main] RCEditing_Move to Source IN marker.lua - [main] RCEditing_Move to Source OUT marker.lua - [main] RCEditing_Zoom to Destination IN marker.lua - [main] RCEditing_Zoom to Destination OUT marker.lua - [main] RCEditing_Zoom to Source IN marker.lua - [main] RCEditing_Zoom to Source OUT marker.lua - [main] RCEditing_3-point Insert Edit.lua - [main] RCEditing_Set Dest Project Marker.lua - [main] RCEditing_Set Source Project Marker.lua - [main] RCEditing_Source Markers to Item Edge.lua - [main] RCEditing_Destination Markers to Item Edge.lua - [main] RCEditing_Delete S-D Project Markers.lua -@about - These functions provide everything you need for professional source-destination editing in REAPER. - For a more complete editing, mixing and mastering solution for classical and other acoustic music, please see https://reaclassical.org - diff --git a/RCEditing/RCEditing_3-point Insert Edit.lua b/RCEditing/RCEditing_3-point Insert Edit.lua deleted file mode 100644 index 6310e2cb..00000000 --- a/RCEditing/RCEditing_3-point Insert Edit.lua +++ /dev/null @@ -1,600 +0,0 @@ ---[[ -@noindex - -This file is a part of "ReaClassical Editing" package. - -Copyright (C) 2022–2025 chmaha - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program. If not, see . -]] - --- luacheck: ignore 113 - -for key in pairs(reaper) do _G[key] = reaper[key] end -local main, markers, select_matching_folder, split_at_dest_in, create_crossfades, clean_up -local lock_items, unlock_items, ripple_lock_mode, create_dest_in, return_xfade_length, xfade -local get_first_last_items, mark_as_edit -local copy_source, move_to_project_tab, save_last_assembly_item -local load_last_assembly_item, find_second_folder_track -local check_overlapping_items, count_selected_media_items, get_selected_media_item_at ---------------------------------------------------------------------- - -local SWS_exists = APIExists("CF_GetSWSVersion") -if not SWS_exists then - MB('Please install SWS/S&M extension before running this function', 'Error: Missing Extension', 0) - return -end - -function main() - PreventUIRefresh(1) - Undo_BeginBlock() - - Main_OnCommand(41121, 0) -- Options: Disable trim content behind media items when editing - local group_state = GetToggleCommandState(1156) - if group_state ~= 1 then - Main_OnCommand(1156, 0) -- Enable item grouping - end - local proj_marker_count, source_proj, dest_proj, dest_in, _, _, _, _, source_count, pos_table, _ = markers() - - if proj_marker_count == 1 then - MB("Only one S-D project marker was found." - .. "\nUse zero for regular single project S-D editing" - .. "\nor use two for multi-tab S-D editing.", "Assembly Line Edit", 0) - return - end - - if proj_marker_count == -1 then - MB( - "Source or destination markers should be paired with the corresponding source " .. - "or destination project marker.", - "Multi-tab Assembly Line Edit", 0) - return - end - ripple_lock_mode() - move_to_project_tab(dest_proj) - - if dest_in == 1 and source_count == 2 then - local last_saved_item = load_last_assembly_item() - if last_saved_item then - local item_start = GetMediaItemInfo_Value(last_saved_item, "D_POSITION") - local item_length = GetMediaItemInfo_Value(last_saved_item, "D_LENGTH") - local item_right_edge = item_start + item_length - local dest_in_pos = pos_table[1] - local threshold = 0.0001 - if math.abs(item_right_edge - dest_in_pos) > threshold then - local input = MB( - "The DEST-IN marker has been moved since the last assembly line edit.\n" .. - "Do you want to start a new edit sequence?\n" .. - "Answering \"No\" will move the DEST-IN marker back to the previous item edge.", - "Assembly Line Edit", 3) - if input == 2 then - return - elseif input == 7 then - local i = 0 - while true do - local project, _ = EnumProjects(i) - if project == nil then - break - else - DeleteProjectMarker(project, 996, false) - end - i = i + 1 - end - AddProjectMarker2(0, false, item_right_edge, 0, "DEST-IN", 996, ColorToNative(23, 203, 223) | - 0x1000000) - end - end - end - - lock_items() - move_to_project_tab(source_proj) - - local stored_view = NamedCommandLookup("_SWS_SAVEVIEW") - Main_OnCommand(stored_view, 0) - local stored_curpos = NamedCommandLookup("_BR_SAVE_CURSOR_POS_SLOT_1") - Main_OnCommand(stored_curpos, 0) - - local _, is_selected = copy_source() - if is_selected == false then - clean_up(is_selected, proj_marker_count) - return - end - Main_OnCommand(40020, 0) -- Remove time selection - move_to_project_tab(dest_proj) - split_at_dest_in() - - if workflow == "Horizontal" then - Main_OnCommand(40311, 0) -- Set ripple-all-tracks - else - Main_OnCommand(40310, 0) -- Set ripple-per-track - end - - local paste = NamedCommandLookup("_SWS_AWPASTE") - Main_OnCommand(paste, 0) -- SWS_AWPASTE - mark_as_edit() - unlock_items() - local cur_pos, new_last_item = create_crossfades() - save_last_assembly_item(new_last_item) - clean_up(is_selected, proj_marker_count) - Main_OnCommand(40289, 0) -- Item: Unselect all items - Main_OnCommand(40310, 0) -- Toggle ripple editing per-track - create_dest_in(cur_pos) - - move_to_project_tab(source_proj) - local restore_view = NamedCommandLookup("_SWS_RESTOREVIEW") - Main_OnCommand(restore_view, 0) - local restore_curpos = NamedCommandLookup("_BR_RESTORE_CURSOR_POS_SLOT_1") - Main_OnCommand(restore_curpos, 0) - else - MB( - "Please add 3 valid source-destination markers: DEST-IN, SOURCE-IN and SOURCE-OUT" - , "Assembly Line Edit", 0) - return - end - - Undo_EndBlock('VERTICAL One-Window S-D Editing', 0) - PreventUIRefresh(-1) - UpdateArrange() - UpdateTimeline() -end - ---------------------------------------------------------------------- - -function markers() - local marker_labels = { "DEST-IN", "DEST-OUT", "SOURCE-IN", "SOURCE-OUT" } - local sd_markers = {} - for _, label in ipairs(marker_labels) do - sd_markers[label] = { count = 0, proj = nil } - end - - local num = 0 - local source_proj, dest_proj - local proj_marker_count = 0 - local pos_table = {} - local active_proj = EnumProjects(-1) - local track_number = 1 - while true do - local proj = EnumProjects(num) - if proj == nil then - break - end - local _, num_markers, num_regions = CountProjectMarkers(proj) - for i = 0, num_markers + num_regions - 1, 1 do - local _, _, pos, _, raw_label, _ = EnumProjectMarkers2(proj, i) - local number = string.match(raw_label, "(%d+):.+") - local label = string.match(raw_label, "%d*:?(.+)") or "" - - if label == "DEST-IN" then - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[1] = pos - elseif label == "DEST-OUT" then - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[2] = pos - elseif label == "SOURCE-IN" then - track_number = number - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[3] = pos - elseif label == "SOURCE-OUT" then - track_number = number - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[4] = pos - elseif string.match(label, "SOURCE PROJECT") then - source_proj = proj - proj_marker_count = proj_marker_count + 1 - elseif string.match(label, "DEST PROJECT") then - dest_proj = proj - proj_marker_count = proj_marker_count + 1 - end - end - num = num + 1 - end - - if proj_marker_count == 0 then - for _, marker in pairs(sd_markers) do - if marker.proj ~= active_proj then - marker.count = 0 - end - end - end - - local source_in = sd_markers["SOURCE-IN"].count - local source_out = sd_markers["SOURCE-OUT"].count - local dest_in = sd_markers["DEST-IN"].count - local dest_out = sd_markers["DEST-OUT"].count - - local sin = sd_markers["SOURCE-IN"].proj - local sout = sd_markers["SOURCE-OUT"].proj - local din = sd_markers["DEST-IN"].proj - local dout = sd_markers["DEST-OUT"].proj - - - local source_count = source_in + source_out - local dest_count = dest_in + dest_out - - if (source_count == 2 and sin ~= sout) or (dest_count == 2 and din ~= dout) then proj_marker_count = -1 end - - if source_proj and ((sin and sin ~= source_proj) or (sout and sout ~= source_proj)) then - proj_marker_count = -1 - end - if dest_proj and ((din and din ~= dest_proj) or (dout and dout ~= dest_proj)) then - proj_marker_count = -1 - end - - return proj_marker_count, source_proj, dest_proj, dest_in, dest_out, dest_count, - source_in, source_out, source_count, pos_table, track_number -end - ---------------------------------------------------------------------- - -function select_matching_folder() - local cursor = GetCursorPosition() - local marker_id, _ = GetLastMarkerAndCurRegion(0, cursor) - local _, _, _, _, label, _, _ = EnumProjectMarkers3(0, marker_id) - local folder_number = tonumber(string.match(label, "(%d*):SOURCE*")) - for i = 0, CountTracks(0) - 1, 1 do - local track = GetTrack(0, i) - if GetMediaTrackInfo_Value(track, "IP_TRACKNUMBER") == folder_number then - SetOnlyTrackSelected(track) - break - end - end -end - ---------------------------------------------------------------------- - -function copy_source() - local is_selected = true - local focus = NamedCommandLookup("_BR_FOCUS_ARRANGE_WND") - Main_OnCommand(focus, 0) -- BR_FOCUS_ARRANGE_WND - --Main_OnCommand(40311, 0) -- Set ripple-all-tracks - Main_OnCommand(40289, 0) -- Item: Unselect all items - GoToMarker(0, 998, false) - select_matching_folder() - local left_overlap = check_overlapping_items() - Main_OnCommand(40625, 0) -- Time Selection: Set start point - GoToMarker(0, 999, false) - local right_overlap = check_overlapping_items() - Main_OnCommand(40626, 0) -- Time Selection: Set end point - local start_time, end_time = GetSet_LoopTimeRange2(0, false, false, 0, 0, false) - local sel_length = end_time - start_time - Main_OnCommand(40718, 0) -- Select all items on selected tracks in current time selection - local selected_items = count_selected_media_items() - if left_overlap then - local first_item = get_selected_media_item_at(0) - SetMediaItemSelected(first_item, false) - selected_items = selected_items - 1 - end - if right_overlap then - local last_item = get_selected_media_item_at(selected_items - 1) - SetMediaItemSelected(last_item, false) - selected_items = selected_items - 1 - end - if selected_items == 0 then - is_selected = false - end - Main_OnCommand(40034, 0) -- Item Grouping: Select all items in group(s) - Main_OnCommand(41383, 0) -- Edit: Copy items/tracks/envelope points (depending on focus) within time selection - Main_OnCommand(40289, 0) -- Item: Unselect all items - return sel_length, is_selected -end - ---------------------------------------------------------------------- - -function split_at_dest_in() - Main_OnCommand(40927, 0) -- Options: Enable auto-crossfade on split - Main_OnCommand(40939, 0) -- Track: Select track 01 - GoToMarker(0, 996, false) - local select_under = NamedCommandLookup("_XENAKIOS_SELITEMSUNDEDCURSELTX") - Main_OnCommand(select_under, 0) -- Xenakios/SWS: Select items under edit cursor on selected tracks - Main_OnCommand(40034, 0) -- Item grouping: Select all items in groups - local selected_items = CountSelectedMediaItems(0) - Main_OnCommand(40912, 0) -- Options: Toggle auto-crossfade on split (OFF) - if selected_items > 0 then - Main_OnCommand(40186, 0) -- Item: Split items at edit or play cursor (ignoring grouping) - end - Main_OnCommand(40289, 0) -- Item: Unselect all items -end - ---------------------------------------------------------------------- - -function create_crossfades() - local first_sel_item, last_sel_item = get_first_last_items() - Main_OnCommand(40289, 0) -- Item: Unselect all items - SetMediaItemSelected(first_sel_item, true) - Main_OnCommand(41173, 0) -- Item navigation: Move cursor to start of items - Main_OnCommand(40034, 0) -- Item grouping: Select all items in groups - local xfade_len = return_xfade_length() - MoveEditCursor(-xfade_len, false) - Main_OnCommand(41305, 0) -- Item edit: Trim left edge of item to edit cursor - MoveEditCursor(xfade_len, false) - MoveEditCursor(-0.0001, false) - xfade(xfade_len) - Main_OnCommand(40289, 0) -- Item: Unselect all items - SetMediaItemSelected(last_sel_item, true) - Main_OnCommand(41174, 0) -- Item navigation: Move cursor to end of items - Main_OnCommand(40034, 0) -- Item grouping: Select all items in groups - Main_OnCommand(41311, 0) -- Item edit: Trim right edge of item to edit cursor - local cur_pos = (GetPlayState() == 0) and GetCursorPosition() or GetPlayPosition() - MoveEditCursor(0.001, false) - local select_under = NamedCommandLookup("_XENAKIOS_SELITEMSUNDEDCURSELTX") - Main_OnCommand(select_under, 0) - MoveEditCursor(-0.001, false) - MoveEditCursor(-xfade_len, false) - Main_OnCommand(41305, 0) -- Item edit: Trim left edge of item to edit cursor - MoveEditCursor(xfade_len, false) - MoveEditCursor(-0.0001, false) - xfade(xfade_len) - Main_OnCommand(40912, 0) -- Options: Toggle auto-crossfade on split (OFF) - return cur_pos, last_sel_item -end - ---------------------------------------------------------------------- - -function clean_up(is_selected, proj_marker_count) - Main_OnCommand(40020, 0) -- Time Selection: Remove time selection and loop point selection - if is_selected then - local i = 0 - while true do - local project, _ = EnumProjects(i) - if project == nil then - break - end - - if proj_marker_count ~= 2 then - DeleteProjectMarker(project, 998, false) - DeleteProjectMarker(project, 999, false) - end - DeleteProjectMarker(project, 996, false) - DeleteProjectMarker(project, 997, false) - - i = i + 1 - end - else - unlock_items() - MB("Please make sure there is material to copy between your source markers...", - "Assembly Line Edit", 0) - end -end - ---------------------------------------------------------------------- - -function lock_items() - local second_folder_track = find_second_folder_track() - - if second_folder_track == nil then - return - end - - local total_tracks = CountTracks(0) - - for track_idx = second_folder_track, total_tracks - 1 do - local track = GetTrack(0, track_idx) - - local num_items = CountTrackMediaItems(track) - - for item_idx = 0, num_items - 1 do - local item = GetTrackMediaItem(track, item_idx) - SetMediaItemInfo_Value(item, "C_LOCK", 1) - end - end -end - ---------------------------------------------------------------------- - -function unlock_items() - local total_items = CountMediaItems(0) - for i = 0, total_items - 1, 1 do - local item = GetMediaItem(0, i) - SetMediaItemInfo_Value(item, "C_LOCK", 0) - end -end - ---------------------------------------------------------------------- - -function ripple_lock_mode() - local _, original_ripple_lock_mode = get_config_var_string("ripplelockmode") - original_ripple_lock_mode = tonumber(original_ripple_lock_mode) - if original_ripple_lock_mode ~= 2 then - SNM_SetIntConfigVar("ripplelockmode", 2) - end -end - ---------------------------------------------------------------------- - -function create_dest_in(cur_pos) - SetEditCurPos(cur_pos, false, false) - AddProjectMarker2(0, false, cur_pos, 0, "DEST-IN", 996, ColorToNative(23, 203, 223) | 0x1000000) -end - ---------------------------------------------------------------------- - -function return_xfade_length() - local xfade_len = 0.035 - local _, input = GetProjExtState(0, "ReaClassical S-D Editing", "Preferences") - if input ~= "" then - local table = {} - for entry in input:gmatch('([^,]+)') do table[#table + 1] = entry end - if table[1] then xfade_len = table[1] / 1000 end - end - return xfade_len -end - ---------------------------------------------------------------------- - -function xfade(xfade_len) - local select_items = NamedCommandLookup("_XENAKIOS_SELITEMSUNDEDCURSELTX") - Main_OnCommand(select_items, 0) -- Xenakios/SWS: Select items under edit cursor on selected tracks - MoveEditCursor(-xfade_len, false) - Main_OnCommand(40625, 0) -- Time selection: Set start point - MoveEditCursor(xfade_len, false) - Main_OnCommand(40626, 0) -- Time selection: Set end point - Main_OnCommand(40916, 0) -- Item: Crossfade items within time selection - Main_OnCommand(40635, 0) -- Time selection: Remove time selection - MoveEditCursor(0.001, false) - Main_OnCommand(select_items, 0) - MoveEditCursor(-0.001, false) -end - ---------------------------------------------------------------------- - -function get_first_last_items() - local num_of_items = CountSelectedMediaItems(0) - local first_sel_item - local last_sel_item - - for i = 0, num_of_items - 1 do - local item = GetSelectedMediaItem(0, i) - local track = GetMediaItem_Track(item) - local track_num = GetMediaTrackInfo_Value(track, "IP_TRACKNUMBER") - - if track_num == 1 then - if not first_sel_item then - first_sel_item = item - end - last_sel_item = item - end - end - - return first_sel_item, last_sel_item -end - ---------------------------------------------------------------------- - -function mark_as_edit() - local selected_items = CountSelectedMediaItems(0) - for i = 0, selected_items - 1, 1 do - local item = GetSelectedMediaItem(0, i) - GetSetMediaItemInfo_String(item, "P_EXT:SD", "y", 1) - end -end - ---------------------------------------------------------------------- - -function move_to_project_tab(proj_type) - SelectProjectInstance(proj_type) -end - ---------------------------------------------------------------------- - -function save_last_assembly_item(item) - local item_guid = BR_GetMediaItemGUID(item) - SetProjExtState(0, "ReaClassical S-D Editing", "LastAssemblyItem", item_guid) -end - ---------------------------------------------------------------------- - -function load_last_assembly_item() - local _, item_guid = GetProjExtState(0, "ReaClassical S-D Editing", "LastAssemblyItem") - local item = BR_GetMediaItemByGUID(0, item_guid) - return item -end - ---------------------------------------------------------------------- - -function find_second_folder_track() - local total_tracks = CountTracks(0) - local folder_count = 0 - - for track_idx = 0, total_tracks - 1 do - local track = GetTrack(0, track_idx) - local folder_depth = GetMediaTrackInfo_Value(track, "I_FOLDERDEPTH") - - if folder_depth == 1 then - folder_count = folder_count + 1 - - if folder_count == 2 then - return track_idx - end - end - end - - return nil -end - ---------------------------------------------------------------------- - -function check_overlapping_items() - local track = GetSelectedTrack(0, 0) - if not track then - ShowMessageBox("No track selected!", "Error", 0) - return - end - - local cursor_pos = GetCursorPosition() - local num_items = CountTrackMediaItems(track) - local overlapping = false - - for i = 0, num_items - 1 do - local item1 = GetTrackMediaItem(track, i) - local start1 = GetMediaItemInfo_Value(item1, "D_POSITION") - local length1 = GetMediaItemInfo_Value(item1, "D_LENGTH") - local end1 = start1 + length1 - - if cursor_pos >= start1 and cursor_pos <= end1 then - for j = i + 1, num_items - 1 do - local item2 = GetTrackMediaItem(track, j) - local start2 = GetMediaItemInfo_Value(item2, "D_POSITION") - - if start2 < end1 and cursor_pos >= start2 then - overlapping = true - break - end - end - end - if overlapping then break end - end - - return overlapping -end - ---------------------------------------------------------------------- - -function count_selected_media_items() - local selected_count = 0 - local total_items = CountMediaItems(0) - - for i = 0, total_items - 1 do - local item = GetMediaItem(0, i) - if IsMediaItemSelected(item) then - selected_count = selected_count + 1 - end - end - - return selected_count -end - ---------------------------------------------------------------------- - -function get_selected_media_item_at(index) - local selected_count = 0 - local total_items = CountMediaItems(0) - - for i = 0, total_items - 1 do - local item = GetMediaItem(0, i) - if IsMediaItemSelected(item) then - if selected_count == index then - return item - end - selected_count = selected_count + 1 - end - end - - return nil -end - ---------------------------------------------------------------------- - -main() diff --git a/RCEditing/RCEditing_Add Destination IN marker.lua b/RCEditing/RCEditing_Add Destination IN marker.lua deleted file mode 100644 index 1657bdb8..00000000 --- a/RCEditing/RCEditing_Add Destination IN marker.lua +++ /dev/null @@ -1,113 +0,0 @@ ---[[ -@noindex - -This file is a part of "ReaClassical Editing" package. - -Copyright (C) 2022–2025 chmaha - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program. If not, see . -]] - --- luacheck: ignore 113 - -for key in pairs(reaper) do _G[key] = reaper[key] end - -local main, edge_check, return_check_length - ---------------------------------------------------------------------- - -function main() - local _, input = GetProjExtState(0, "ReaClassical S-D Editing", "Preferences") - local sdmousehover = 0 - if input ~= "" then - local table = {} - for entry in input:gmatch('([^,]+)') do table[#table + 1] = entry end - if table[3] then sdmousehover = tonumber(table[3]) or 0 end - end - - local cur_pos - if sdmousehover == 1 then - _, _, cur_pos = BR_TrackAtMouseCursor() - else - cur_pos = (GetPlayState() == 0) and GetCursorPosition() or GetPlayPosition() - end - - if cur_pos ~= -1 then - local i = 0 - while true do - local project, _ = EnumProjects(i) - if project == nil then - break - else - DeleteProjectMarker(project, 996, false) - end - i = i + 1 - end - - - if edge_check(cur_pos) == true then - local response = MB( - "The marker you are trying to add would either be on or close " .. - "to an item edge or existing crossfade. Continue?", - "Add Dest-IN Marker", 4) - if response ~= 6 then return end - end - AddProjectMarker2(0, false, cur_pos, 0, "DEST-IN", 996, ColorToNative(23,203,223) | 0x1000000) - end -end - ---------------------------------------------------------------------- - -function edge_check(cur_pos) - local num_of_items = 0 - local check_length = return_check_length() - local first_track = GetTrack(0, 0) - if first_track then num_of_items = CountTrackMediaItems(first_track) end - local clash = false - for i = 0, num_of_items - 1 do - local item = GetTrackMediaItem(first_track, i) - local item_start = GetMediaItemInfo_Value(item, "D_POSITION") - local item_fadein_len = GetMediaItemInfo_Value(item, "D_FADEINLEN") - local item_fadein_end = item_start + item_fadein_len - if cur_pos > item_start and cur_pos < item_fadein_end + check_length then - clash = true - break - end - local item_length = GetMediaItemInfo_Value(item, "D_LENGTH") - local item_end = item_start + item_length - local item_fadeout_len = GetMediaItemInfo_Value(item, "D_FADEOUTLEN") - local item_fadeout_start = item_end - item_fadeout_len - if cur_pos > item_fadeout_start - check_length and cur_pos < item_end then - clash = true - break - end - end - - return clash -end - ---------------------------------------------------------------------- - -function return_check_length() - local check_length = 0.5 - local _, input = GetProjExtState(0, "ReaClassical S-D Editing", "Preferences") - if input ~= "" then - local table = {} - for entry in input:gmatch('([^,]+)') do table[#table + 1] = entry end - if table[2] then check_length = table[2] / 1000 end - end - return check_length -end - ---------------------------------------------------------------------- - -main() diff --git a/RCEditing/RCEditing_Add Destination OUT Marker.lua b/RCEditing/RCEditing_Add Destination OUT Marker.lua deleted file mode 100644 index a7dbe5c0..00000000 --- a/RCEditing/RCEditing_Add Destination OUT Marker.lua +++ /dev/null @@ -1,112 +0,0 @@ ---[[ -@noindex - -This file is a part of "ReaClassical Editing" package. - -Copyright (C) 2022–2025 chmaha - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program. If not, see . -]] - --- luacheck: ignore 113 - -for key in pairs(reaper) do _G[key] = reaper[key] end - -local main, edge_check, return_check_length - ---------------------------------------------------------------------- - -function main() - local _, input = GetProjExtState(0, "ReaClassical S-D Editing", "Preferences") - local sdmousehover = 0 - if input ~= "" then - local table = {} - for entry in input:gmatch('([^,]+)') do table[#table + 1] = entry end - if table[3] then sdmousehover = tonumber(table[3]) or 0 end - end - - local cur_pos - if sdmousehover == 1 then - _, _, cur_pos = BR_TrackAtMouseCursor() - else - cur_pos = (GetPlayState() == 0) and GetCursorPosition() or GetPlayPosition() - end - - if cur_pos ~= -1 then - local i = 0 - while true do - local project, _ = EnumProjects(i) - if project == nil then - break - else - DeleteProjectMarker(project, 997, false) - end - i = i + 1 - end - - - if edge_check(cur_pos) == true then - local response = MB( - "The marker you are trying to add would either be on or close to an item edge or crossfade. Continue?", - "Add Dest-OUT Marker", 4) - if response ~= 6 then return end - end - AddProjectMarker2(0, false, cur_pos, 0, "DEST-OUT", 997, ColorToNative(23, 203, 223) | 0x1000000) - end -end - ---------------------------------------------------------------------- - -function edge_check(cur_pos) - local num_of_items = 0 - local check_length = return_check_length() - local first_track = GetTrack(0, 0) - if first_track then num_of_items = CountTrackMediaItems(first_track) end - local clash = false - for i = 0, num_of_items - 1 do - local item = GetTrackMediaItem(first_track, i) - local item_start = GetMediaItemInfo_Value(item, "D_POSITION") - local item_fadein_len = GetMediaItemInfo_Value(item, "D_FADEINLEN") - local item_fadein_end = item_start + item_fadein_len - if cur_pos > item_start - check_length and cur_pos < item_fadein_end then - clash = true - break - end - local item_length = GetMediaItemInfo_Value(item, "D_LENGTH") - local item_end = item_start + item_length - local item_fadeout_len = GetMediaItemInfo_Value(item, "D_FADEOUTLEN") - local item_fadeout_start = item_end - item_fadeout_len - if cur_pos > item_fadeout_start - check_length and cur_pos < item_end then - clash = true - break - end - end - - return clash -end - ---------------------------------------------------------------------- - -function return_check_length() - local check_length = 0.5 - local _, input = GetProjExtState(0, "ReaClassical S-D Editing", "Preferences") - if input ~= "" then - local table = {} - for entry in input:gmatch('([^,]+)') do table[#table + 1] = entry end - if table[2] then check_length = table[2] / 1000 end - end - return check_length -end - ---------------------------------------------------------------------- - -main() diff --git a/RCEditing/RCEditing_Add Source IN marker.lua b/RCEditing/RCEditing_Add Source IN marker.lua deleted file mode 100644 index 2d28fab2..00000000 --- a/RCEditing/RCEditing_Add Source IN marker.lua +++ /dev/null @@ -1,91 +0,0 @@ ---[[ -@noindex - -This file is a part of "ReaClassical Editing" package. - -Copyright (C) 2022–2025 chmaha - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program. If not, see . -]] - --- luacheck: ignore 113 - -for key in pairs(reaper) do _G[key] = reaper[key] end - -local main, folder_check, get_track_number - ---------------------------------------------------------------------- - -function main() - local _, input = GetProjExtState(0, "ReaClassical S-D Editing", "Preferences") - local sdmousehover = 0 - if input ~= "" then - local table = {} - for entry in input:gmatch('([^,]+)') do table[#table + 1] = entry end - if table[3] then sdmousehover = tonumber(table[3]) or 0 end - end - - local cur_pos, track - if sdmousehover == 1 then - track, _, cur_pos = BR_TrackAtMouseCursor() - else - cur_pos = (GetPlayState() == 0) and GetCursorPosition() or GetPlayPosition() - end - - if cur_pos ~= -1 then - local i = 0 - while true do - local project, _ = EnumProjects(i) - if project == nil then - break - else - DeleteProjectMarker(project, 998, false) - end - i = i + 1 - end - - local track_number = math.floor(get_track_number(track)) - AddProjectMarker2(0, false, cur_pos, 0, track_number .. ":SOURCE-IN", 998, ColorToNative(23, 223, 143) | 0x1000000) - end -end - ---------------------------------------------------------------------- - -function folder_check() - local folders = 0 - local total_tracks = CountTracks(0) - for i = 0, total_tracks - 1, 1 do - local track = GetTrack(0, i) - if GetMediaTrackInfo_Value(track, "I_FOLDERDEPTH") == 1 then - folders = folders + 1 - end - end - return folders -end - ---------------------------------------------------------------------- - -function get_track_number(track) - if not track then track = GetSelectedTrack(0, 0) end - if folder_check() == 0 or track == nil then - return 1 - elseif GetMediaTrackInfo_Value(track, "I_FOLDERDEPTH") == 1 then - return GetMediaTrackInfo_Value(track, "IP_TRACKNUMBER") - else - local folder = GetParentTrack(track) - return GetMediaTrackInfo_Value(folder, "IP_TRACKNUMBER") - end -end - ---------------------------------------------------------------------- - -main() diff --git a/RCEditing/RCEditing_Add Source OUT marker.lua b/RCEditing/RCEditing_Add Source OUT marker.lua deleted file mode 100644 index 7d15a2a8..00000000 --- a/RCEditing/RCEditing_Add Source OUT marker.lua +++ /dev/null @@ -1,92 +0,0 @@ ---[[ -@noindex - -This file is a part of "ReaClassical Editing" package. - -Copyright (C) 2022–2025 chmaha - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program. If not, see . -]] - --- luacheck: ignore 113 - - -for key in pairs(reaper) do _G[key] = reaper[key] end - -local main, folder_check, get_track_number - ---------------------------------------------------------------------- - -function main() - local _, input = GetProjExtState(0, "ReaClassical S-D Editing", "Preferences") - local sdmousehover = 0 - if input ~= "" then - local table = {} - for entry in input:gmatch('([^,]+)') do table[#table + 1] = entry end - if table[3] then sdmousehover = tonumber(table[3]) or 0 end - end - - local cur_pos, track - if sdmousehover == 1 then - track, _, cur_pos = BR_TrackAtMouseCursor() - else - cur_pos = (GetPlayState() == 0) and GetCursorPosition() or GetPlayPosition() - end - - if cur_pos ~= -1 then - local i = 0 - while true do - local project, _ = EnumProjects(i) - if project == nil then - break - else - DeleteProjectMarker(project, 999, false) - end - i = i + 1 - end - - local track_number = math.floor(get_track_number(track)) - AddProjectMarker2(0, false, cur_pos, 0, track_number .. ":SOURCE-OUT", 999, ColorToNative(23, 223, 143) | 0x1000000) - end -end - ---------------------------------------------------------------------- - -function folder_check() - local folders = 0 - local total_tracks = CountTracks(0) - for i = 0, total_tracks - 1, 1 do - local track = GetTrack(0, i) - if GetMediaTrackInfo_Value(track, "I_FOLDERDEPTH") == 1 then - folders = folders + 1 - end - end - return folders -end - ---------------------------------------------------------------------- - -function get_track_number(track) - if not track then track = GetSelectedTrack(0, 0) end - if folder_check() == 0 or track == nil then - return 1 - elseif GetMediaTrackInfo_Value(track, "I_FOLDERDEPTH") == 1 then - return GetMediaTrackInfo_Value(track, "IP_TRACKNUMBER") - else - local folder = GetParentTrack(track) - return GetMediaTrackInfo_Value(folder, "IP_TRACKNUMBER") - end -end - ---------------------------------------------------------------------- - -main() diff --git a/RCEditing/RCEditing_Delete All S-D markers.lua b/RCEditing/RCEditing_Delete All S-D markers.lua deleted file mode 100644 index fa6c24dc..00000000 --- a/RCEditing/RCEditing_Delete All S-D markers.lua +++ /dev/null @@ -1,46 +0,0 @@ ---[[ -@noindex - -This file is a part of "ReaClassical Editing" package. - -Copyright (C) 2022–2025 chmaha - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program. If not, see . -]] - --- luacheck: ignore 113 - -for key in pairs(reaper) do _G[key] = reaper[key] end - -local main - ---------------------------------------------------------------------- - -function main() - local i = 0 - while true do - local project, _ = EnumProjects(i) - if project == nil then - break - else - DeleteProjectMarker(project, 996, false) - DeleteProjectMarker(project, 997, false) - DeleteProjectMarker(project, 998, false) - DeleteProjectMarker(project, 999, false) - end - i = i + 1 - end -end - ---------------------------------------------------------------------- - -main() diff --git a/RCEditing/RCEditing_Delete Leaving Silence.lua b/RCEditing/RCEditing_Delete Leaving Silence.lua deleted file mode 100644 index 40832389..00000000 --- a/RCEditing/RCEditing_Delete Leaving Silence.lua +++ /dev/null @@ -1,99 +0,0 @@ ---[[ -@noindex - -This file is a part of "ReaClassical Editing" package. - -Copyright (C) 2022–2025 chmaha - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program. If not, see . -]] - --- luacheck: ignore 113 - -for key in pairs(reaper) do _G[key] = reaper[key] end - -local main, source_markers, select_matching_folder - ---------------------------------------------------------------------- - -function main() - PreventUIRefresh(1) - Undo_BeginBlock() - - local group_state = GetToggleCommandState(1156) - if group_state ~= 1 then - Main_OnCommand(1156, 0) -- Enable item grouping - end - - if source_markers() == 2 then - local focus = NamedCommandLookup("_BR_FOCUS_ARRANGE_WND") - Main_OnCommand(focus, 0) -- BR_FOCUS_ARRANGE_WND - Main_OnCommand(40310, 0) -- Set ripple per-track - Main_OnCommand(40289, 0) -- Item: Unselect all items - GoToMarker(0, 998, false) - select_matching_folder() - Main_OnCommand(40625, 0) -- Time Selection: Set start point - GoToMarker(0, 999, false) - Main_OnCommand(40626, 0) -- Time Selection: Set end point - Main_OnCommand(40718, 0) -- Select all items on selected tracks in current time selection - Main_OnCommand(40034, 0) -- Item Grouping: Select all items in group(s) - Main_OnCommand(41990, 0) -- Toggle ripple per-track (off) - local delete = NamedCommandLookup("_XENAKIOS_TSADEL") - Main_OnCommand(delete, 0) -- XENAKIOS_TSADEL - Main_OnCommand(40630, 0) -- Go to start of time selection - Main_OnCommand(40020, 0) -- Time Selection: Remove time selection and loop point selection - DeleteProjectMarker(NULL, 998, false) - DeleteProjectMarker(NULL, 999, false) - Main_OnCommand(40289, 0) -- Item: Unselect all items - Main_OnCommand(41990, 0) -- Toggle ripple per-track (on) - else - MB("Please use SOURCE-IN and SOURCE-OUT markers", "Delete Leaving Silence", 0) - end - Undo_EndBlock('Cut and Ripple', 0) - PreventUIRefresh(-1) - UpdateArrange() - UpdateTimeline() -end - ---------------------------------------------------------------------- - -function source_markers() - local _, num_markers, num_regions = CountProjectMarkers(0) - local exists = 0 - for i = 0, num_markers + num_regions - 1, 1 do - local _, _, _, _, label, _ = EnumProjectMarkers(i) - if string.match(label, "%d+:SOURCE[-]IN") or string.match(label, "%d+:SOURCE[-]OUT") then - exists = exists + 1 - end - end - return exists -end - ---------------------------------------------------------------------- - -function select_matching_folder() - local cursor = GetCursorPosition() - local marker_id, _ = GetLastMarkerAndCurRegion(0, cursor) - local _, _, _, _, label, _, _ = EnumProjectMarkers3(0, marker_id) - local folder_number = tonumber(string.match(label, "(%d*):SOURCE*")) - for i = 0, CountTracks(0) - 1, 1 do - local track = GetTrack(0, i) - if GetMediaTrackInfo_Value(track, "IP_TRACKNUMBER") == folder_number then - SetOnlyTrackSelected(track) - break - end - end -end - ---------------------------------------------------------------------- - -main() diff --git a/RCEditing/RCEditing_Delete S-D Project Markers.lua b/RCEditing/RCEditing_Delete S-D Project Markers.lua deleted file mode 100755 index 1b4b46fe..00000000 --- a/RCEditing/RCEditing_Delete S-D Project Markers.lua +++ /dev/null @@ -1,44 +0,0 @@ ---[[ -@noindex - -This file is a part of "ReaClassical Editing" package. - -Copyright (C) 2022–2025 chmaha - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program. If not, see . -]] - --- luacheck: ignore 113 - -for key in pairs(reaper) do _G[key] = reaper[key] end - -local main - ---------------------------------------------------------------------- - -function main() - local i = 0; - while true do - local project, _ = EnumProjects(i) - if project == nil then - break - else - DeleteProjectMarker(project, 1000, false) - DeleteProjectMarker(project, 1001, false) - end - i = i + 1 - end -end - ---------------------------------------------------------------------- - -main() diff --git a/RCEditing/RCEditing_Delete With Ripple.lua b/RCEditing/RCEditing_Delete With Ripple.lua deleted file mode 100644 index fb4efa60..00000000 --- a/RCEditing/RCEditing_Delete With Ripple.lua +++ /dev/null @@ -1,188 +0,0 @@ ---[[ -@noindex - -This file is a part of "ReaClassical Editing" package. - -Copyright (C) 2022–2025 chmaha - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program. If not, see . -]] - --- luacheck: ignore 113 - -for key in pairs(reaper) do _G[key] = reaper[key] end - -local main, source_markers, select_matching_folder, lock_items -local unlock_items, ripple_lock_mode, return_xfade_length, xfade - ---------------------------------------------------------------------- - -local SWS_exists = APIExists("CF_GetSWSVersion") -if not SWS_exists then - MB('Please install SWS/S&M extension before running this function', 'Error: Missing Extension', 0) - return -end - -function main() - PreventUIRefresh(1) - Undo_BeginBlock() - Main_OnCommand(40927, 0) -- Options: Enable auto-crossfade on split - Main_OnCommand(41121,0) -- Options: Disable trim content behind media items when editing - local group_state = GetToggleCommandState(1156) - if group_state ~= 1 then - Main_OnCommand(1156, 0) -- Enable item grouping - end - if source_markers() == 2 then - ripple_lock_mode() - local focus = NamedCommandLookup("_BR_FOCUS_ARRANGE_WND") - Main_OnCommand(focus, 0) -- BR_FOCUS_ARRANGE_WND - GoToMarker(0, 998, false) - lock_items() - Main_OnCommand(40289, 0) -- Item: Unselect all items - Main_OnCommand(40625, 0) -- Time Selection: Set start point - GoToMarker(0, 999, false) - Main_OnCommand(40626, 0) -- Time Selection: Set end point - Main_OnCommand(40718, 0) -- Select all items on selected tracks in current time selection - Main_OnCommand(40034, 0) -- Item Grouping: Select all items in group(s) - local folder = GetSelectedTrack(0, 0) - - if workflow == "Vertical" and GetMediaTrackInfo_Value(folder, "IP_TRACKNUMBER") == 1 then - Main_OnCommand(40310, 0) -- Set ripple-per-track - else - Main_OnCommand(40311, 0) -- Set ripple-all-tracks - end - local delete = NamedCommandLookup("_XENAKIOS_TSADEL") - Main_OnCommand(delete, 0) -- XENAKIOS_TSADEL - Main_OnCommand(40630, 0) -- Go to start of time selection - unlock_items() - local xfade_len = return_xfade_length() - MoveEditCursor(xfade_len, false) - local select_under = NamedCommandLookup("_XENAKIOS_SELITEMSUNDEDCURSELTX") - Main_OnCommand(select_under, 0) -- Xenakios/SWS: Select items under edit cursor on selected tracks - MoveEditCursor(-xfade_len * 2, false) - Main_OnCommand(41305, 0) -- Item edit: Trim left edge of item to edit cursor - Main_OnCommand(40630, 0) -- Go to start of time selection - xfade(xfade_len) - Main_OnCommand(40020, 0) -- Time Selection: Remove time selection and loop point selection - DeleteProjectMarker(NULL, 998, false) - DeleteProjectMarker(NULL, 999, false) - Main_OnCommand(40289, 0) -- Item: Unselect all items - Main_OnCommand(40310, 0) -- Ripple per-track - else - MB("Please use SOURCE-IN and SOURCE-OUT markers", "Delete With Ripple", 0) - end - Undo_EndBlock('Cut and Ripple', 0) - PreventUIRefresh(-1) - UpdateArrange() - UpdateTimeline() -end - ---------------------------------------------------------------------- - -function source_markers() - local _, num_markers, num_regions = CountProjectMarkers(0) - local exists = 0 - for i = 0, num_markers + num_regions - 1, 1 do - local _, _, _, _, label, _ = EnumProjectMarkers(i) - if string.match(label, "%d+:SOURCE[-]IN") or string.match(label, "%d+:SOURCE[-]OUT") then - exists = exists + 1 - end - end - return exists -end - ---------------------------------------------------------------------- - -function select_matching_folder() - local cursor = GetCursorPosition() - local marker_id, _ = GetLastMarkerAndCurRegion(0, cursor) - local _, _, _, _, label, _, _ = EnumProjectMarkers3(0, marker_id) - local folder_number = tonumber(string.match(label, "(%d*):SOURCE*")) - for i = 0, CountTracks(0) - 1, 1 do - local track = GetTrack(0, i) - if GetMediaTrackInfo_Value(track, "IP_TRACKNUMBER") == folder_number then - SetOnlyTrackSelected(track) - break - end - end -end - ---------------------------------------------------------------------- - -function lock_items() - select_matching_folder() - Main_OnCommand(40182, 0) -- select all items - local select_children = NamedCommandLookup("_SWS_SELCHILDREN2") - Main_OnCommand(select_children, 0) -- select children of folder - local unselect_items = NamedCommandLookup("_SWS_UNSELONTRACKS") - Main_OnCommand(unselect_items, 0) -- unselect items in folder - local unselect_children = NamedCommandLookup("_SWS_UNSELCHILDREN") - Main_OnCommand(unselect_children, 0) -- unselect children of folder - local total_items = CountSelectedMediaItems(0) - for i = 0, total_items - 1, 1 do - local item = GetSelectedMediaItem(0, i) - SetMediaItemInfo_Value(item, "C_LOCK", 1) - end -end - ---------------------------------------------------------------------- - -function unlock_items() - local total_items = CountMediaItems(0) - for i = 0, total_items - 1, 1 do - local item = GetMediaItem(0, i) - SetMediaItemInfo_Value(item, "C_LOCK", 0) - end -end - ---------------------------------------------------------------------- - -function ripple_lock_mode() - local _, original_ripple_lock_mode = get_config_var_string("ripplelockmode") - original_ripple_lock_mode = tonumber(original_ripple_lock_mode) - if original_ripple_lock_mode ~= 2 then - SNM_SetIntConfigVar("ripplelockmode", 2) - end -end - ---------------------------------------------------------------------- - -function return_xfade_length() - local xfade_len = 0.035 - local _, input = GetProjExtState(0, "ReaClassical S-D Editing", "Preferences") - if input ~= "" then - local table = {} - for entry in input:gmatch('([^,]+)') do table[#table + 1] = entry end - if table[1] then xfade_len = table[1] / 1000 end - end - return xfade_len -end - ---------------------------------------------------------------------- - -function xfade(xfade_len) - local select_items = NamedCommandLookup("_XENAKIOS_SELITEMSUNDEDCURSELTX") - Main_OnCommand(select_items, 0) -- Xenakios/SWS: Select items under edit cursor on selected tracks - MoveEditCursor(-xfade_len, false) - Main_OnCommand(40625, 0) -- Time selection: Set start point - MoveEditCursor(xfade_len, false) - Main_OnCommand(40626, 0) -- Time selection: Set end point - Main_OnCommand(40916, 0) -- Item: Crossfade items within time selection - Main_OnCommand(40635, 0) -- Time selection: Remove time selection - MoveEditCursor(0.001, false) - Main_OnCommand(select_items, 0) - MoveEditCursor(-0.001, false) -end - ---------------------------------------------------------------------- - -main() \ No newline at end of file diff --git a/RCEditing/RCEditing_Destination Markers to Item Edge.lua b/RCEditing/RCEditing_Destination Markers to Item Edge.lua deleted file mode 100644 index d1414f10..00000000 --- a/RCEditing/RCEditing_Destination Markers to Item Edge.lua +++ /dev/null @@ -1,113 +0,0 @@ ---[[ -@noindex - -This file is a part of "ReaClassical Editing" package. - -Copyright (C) 2022–2025 chmaha - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program. If not, see . -]] - --- luacheck: ignore 113 - -for key in pairs(reaper) do _G[key] = reaper[key] end - -local main - ---------------------------------------------------------------------- - -function main() - Undo_BeginBlock() - local left_pos, right_pos, selected - local start_time, end_time = GetSet_LoopTimeRange(false, false, 0, 0, false) - if start_time ~= end_time then - left_pos = start_time - right_pos = end_time - else - local parent_track = GetTrack(0, 0) - selected = CountSelectedMediaItems(0) - - if selected == 0 then - MB( - "Please select one or more consecutive media items " .. - "in the first folder or make a time selection before running the function.", - "Destination Markers to Item Edge / Time Selection: Error", 0) - return - end - - local folder_tracks = {} - local num_tracks = CountTracks(0) - - for i = 0, num_tracks - 1 do - local track = GetTrack(0, i) - if i == 0 or GetParentTrack(track) == parent_track then - table.insert(folder_tracks, track) - else - break - end - end - for i = 0, selected - 1 do - local item = GetSelectedMediaItem(0, i) - local item_track = GetMediaItem_Track(item) - - local found = false - for _, folder_track in ipairs(folder_tracks) do - if item_track == folder_track then - found = true - break - end - end - - if not found then - MB("Any selected items should be in the first folder.", "Error", 0) - return - end - end - -- Set marker positions - local first_item = GetSelectedMediaItem(0, 0) - left_pos = GetMediaItemInfo_Value(first_item, "D_POSITION") - local last_item - if selected > 1 then - last_item = GetSelectedMediaItem(0, selected - 1) - local start = GetMediaItemInfo_Value(last_item, "D_POSITION") - local length = GetMediaItemInfo_Value(last_item, "D_LENGTH") - right_pos = start + length - else - local length = GetMediaItemInfo_Value(first_item, "D_LENGTH") - right_pos = left_pos + length - end - end - - - -- Remove old markers - local i = 0 - while true do - local project, _ = EnumProjects(i) - if project == nil then - break - else - DeleteProjectMarker(project, 996, false) - DeleteProjectMarker(project, 997, false) - end - i = i + 1 - end - - -- add new markers - AddProjectMarker2(0, false, left_pos, 0, "DEST-IN", 996, ColorToNative(23,203,223) | 0x1000000) - AddProjectMarker2(0, false, right_pos, 0, "DEST-OUT", 997, ColorToNative(23,203,223) | 0x1000000) - - Undo_EndBlock("Destination Markers to Item Edge", 0) -end - ---------------------------------------------------------------------- - -main() diff --git a/RCEditing/RCEditing_Insert with timestretching.lua b/RCEditing/RCEditing_Insert with timestretching.lua deleted file mode 100644 index 8baea2a6..00000000 --- a/RCEditing/RCEditing_Insert with timestretching.lua +++ /dev/null @@ -1,578 +0,0 @@ ---[[ -@noindex - -This file is a part of "ReaClassical Editing" package. - -Copyright (C) 2022–2025 chmaha - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program. If not, see . -]] - --- luacheck: ignore 113 - -for key in pairs(reaper) do _G[key] = reaper[key] end - -local main, select_matching_folder, copy_source, split_at_dest_in -local create_crossfades, clean_up, lock_items, unlock_items, ripple_lock_mode -local return_xfade_length, xfade, get_first_last_items, markers -local mark_as_edit, move_to_project_tab, find_second_folder_track -local check_overlapping_items, count_selected_media_items, get_selected_media_item_at - ---------------------------------------------------------------------- - -local SWS_exists = APIExists("CF_GetSWSVersion") -if not SWS_exists then - MB('Please install SWS/S&M extension before running this function', 'Error: Missing Extension', 0) - return -end - -function main() - PreventUIRefresh(1) - Undo_BeginBlock() - ripple_lock_mode() - Main_OnCommand(41121, 0) -- Options: Disable trim content behind media items when editing - local group_state = GetToggleCommandState(1156) - if group_state ~= 1 then - Main_OnCommand(1156, 0) -- Enable item grouping - end - local proj_marker_count, source_proj, dest_proj, _, _, dest_count, _, _, source_count, _, _ = markers() - - if proj_marker_count == 1 then - MB("Only one S-D project marker was found." - .. "\nUse zero for regular single project S-D editing" - .. "\nor use two for multi-tab S-D editing.", "Source-Destination Edit", 0) - return - end - - if proj_marker_count == -1 then - MB( - "Source or destination markers should be paired with the " .. - "corresponding source or destination project marker.", - "Multi-tab Source-Destination Edit", 0) - return - end - - if dest_count + source_count == 4 then - local selected_items = {} - - move_to_project_tab(dest_proj) - move_to_project_tab(source_proj) - local xfade_len = return_xfade_length() - local total_selected, parent_selected = copy_source(xfade_len) - if total_selected == 0 then - Main_OnCommand(40020, 0) -- Time Selection: Remove time selection and loop point selection - unlock_items() - MB("Please make sure there is material to copy between your source markers.", - "Insert with timestretching", 0) - return - end - Main_OnCommand(40020, 0) -- remove time selection - move_to_project_tab(dest_proj) - lock_items() - split_at_dest_in() - Main_OnCommand(40625, 0) -- Time Selection: Set start point - GoToMarker(0, 997, false) - Main_OnCommand(40626, 0) -- Time Selection: Set end point - Main_OnCommand(40718, 0) -- Select all items on selected tracks in current time selection - Main_OnCommand(40034, 0) -- Item Grouping: Select all items in group(s) - Main_OnCommand(40630, 0) -- Go to start of time selection - Main_OnCommand(40309, 0) -- ripple off - local delete = NamedCommandLookup("_XENAKIOS_TSADEL") - Main_OnCommand(delete, 0) -- Adaptive Delete - Main_OnCommand(40289, 0) -- Item: Unselect all items - - local state = GetToggleCommandState(1156) - if state == 1 then - Main_OnCommand(1156, 0) -- Options: Toggle item grouping and track media/razor edit grouping - end - if parent_selected > 1 then - MoveEditCursor(-xfade_len * 15, false) -- move cursor back xfade length - end - Main_OnCommand(42398, 0) -- Item: Paste items/tracks - GoToMarker(0, 996, false) - if parent_selected > 1 then - MoveEditCursor(-xfade_len * 15, false) -- move cursor back xfade length - end - Main_OnCommand(40625, 0) -- Time Selection: Set start point - - for i = 0, total_selected - 1, 1 do - selected_items[i] = GetSelectedMediaItem(0, i) - end - Main_OnCommand(40289, 0) -- Item: Unselect all items - local first_item = selected_items[0] - - local item_color = GetMediaItemInfo_Value(first_item, "I_CUSTOMCOLOR") - - for _, v in pairs(selected_items) do - SetMediaItemSelected(v, true) - SetMediaItemInfo_Value(v, "C_LOCK", 0) - end - if parent_selected == 1 then - Main_OnCommand(41206, 0) -- Item: Move and stretch items to fit time selection - else - Main_OnCommand(40362, 0) -- glue items - GoToMarker(0, 996, false) - Main_OnCommand(40511, 0) -- trim items left of cursor - Main_OnCommand(40625, 0) -- Time Selection: Set start point - Main_OnCommand(41206, 0) -- Item: Move and stretch items to fit time selection - end - Main_OnCommand(40032, 0) -- group selected items - mark_as_edit() - local num_of_selected = CountSelectedMediaItems() - for i = 0, num_of_selected - 1, 1 do - local item = GetSelectedMediaItem(0, i) - SetMediaItemInfo_Value(item, "I_CUSTOMCOLOR", item_color) - end - - state = GetToggleCommandState(1156) - if state == 0 then - Main_OnCommand(1156, 0) -- Options: Toggle item grouping and track media/razor edit grouping - end - unlock_items() - create_crossfades(xfade_len) - clean_up(proj_marker_count) - Main_OnCommand(40289, 0) -- Item: Unselect all items - Main_OnCommand(40310, 0) -- Toggle ripple editing per-track - else - MB("Please add 4 markers: DEST-IN, DEST-OUT, SOURCE-IN and SOURCE-OUT", - "Insert with timestretching", - 0) - end - - Undo_EndBlock('Insert with timestretching', 0) - PreventUIRefresh(-1) - UpdateArrange() - UpdateTimeline() -end - ---------------------------------------------------------------------- - -function select_matching_folder() - local cursor = GetCursorPosition() - local marker_id, _ = GetLastMarkerAndCurRegion(0, cursor) - local _, _, _, _, label, _, _ = EnumProjectMarkers3(0, marker_id) - local folder_number = tonumber(string.match(label, "(%d*):SOURCE*")) - for i = 0, CountTracks(0) - 1, 1 do - local track = GetTrack(0, i) - if GetMediaTrackInfo_Value(track, "IP_TRACKNUMBER") == folder_number then - SetOnlyTrackSelected(track) - break - end - end -end - ---------------------------------------------------------------------- - -function copy_source(xfade_len) - local focus = NamedCommandLookup("_BR_FOCUS_ARRANGE_WND") - Main_OnCommand(focus, 0) -- BR_FOCUS_ARRANGE_WND - Main_OnCommand(40311, 0) -- Set ripple-all-tracks - Main_OnCommand(40289, 0) -- Item: Unselect all items - GoToMarker(0, 998, false) - select_matching_folder() - local left_overlap = check_overlapping_items() - Main_OnCommand(40625, 0) -- Time Selection: Set start point - GoToMarker(0, 999, false) - local right_overlap = check_overlapping_items() - Main_OnCommand(40626, 0) -- Time Selection: Set end point - Main_OnCommand(40718, 0) -- Select all items on selected tracks in current time selection - local parent_track_selected_items = count_selected_media_items() - if left_overlap then - local first_item = get_selected_media_item_at(0) - SetMediaItemSelected(first_item, false) - parent_track_selected_items = parent_track_selected_items - 1 - end - if right_overlap then - local last_item = get_selected_media_item_at(parent_track_selected_items - 1) - SetMediaItemSelected(last_item, false) - parent_track_selected_items = parent_track_selected_items - 1 - end - Main_OnCommand(40034, 0) -- Item Grouping: Select all items in group(s) - if parent_track_selected_items > 1 then - local loop_start, loop_end = GetSet_LoopTimeRange(false, false, 0, 0, false) - local new_loop_start = loop_start - (xfade_len * 15) - GetSet_LoopTimeRange(true, false, new_loop_start, loop_end, false) - end - - local total_selected_items = count_selected_media_items() - - Main_OnCommand(41383, 0) -- Edit: Copy items/tracks/envelope points (depending on focus) within time selection - Main_OnCommand(40289, 0) -- Item: Unselect all items - - return total_selected_items, parent_track_selected_items -end - ---------------------------------------------------------------------- - -function split_at_dest_in() - Main_OnCommand(40927, 0) -- Options: Enable auto-crossfade on split - Main_OnCommand(40939, 0) -- Track: Select track 01 - GoToMarker(0, 996, false) - local select_under = NamedCommandLookup("_XENAKIOS_SELITEMSUNDEDCURSELTX") - Main_OnCommand(select_under, 0) -- Xenakios/SWS: Select items under edit cursor on selected tracks - Main_OnCommand(40034, 0) -- Item grouping: Select all items in groups - local selected_items = CountSelectedMediaItems(0) - Main_OnCommand(40912, 0) -- Options: Toggle auto-crossfade on split (OFF) - if selected_items > 0 then - Main_OnCommand(40186, 0) -- Item: Split items at edit or play cursor (ignoring grouping) - end - Main_OnCommand(40289, 0) -- Item: Unselect all items -end - ---------------------------------------------------------------------- - -function create_crossfades(xfade_len) - local first_sel_item, last_sel_item = get_first_last_items() - Main_OnCommand(40289, 0) -- Item: Unselect all items - SetMediaItemSelected(first_sel_item, true) - Main_OnCommand(41173, 0) -- Item navigation: Move cursor to start of items - Main_OnCommand(40034, 0) -- Item grouping: Select all items in groups - MoveEditCursor(-xfade_len, false) - Main_OnCommand(41305, 0) -- Item edit: Trim left edge of item to edit cursor - MoveEditCursor(xfade_len, false) - MoveEditCursor(-0.0001, false) - xfade(xfade_len) - Main_OnCommand(40289, 0) -- Item: Unselect all items - SetMediaItemSelected(last_sel_item, true) - Main_OnCommand(41174, 0) -- Item navigation: Move cursor to end of items - Main_OnCommand(40034, 0) -- Item grouping: Select all items in groups - Main_OnCommand(41311, 0) -- Item edit: Trim right edge of item to edit cursor - MoveEditCursor(0.001, false) - local select_under = NamedCommandLookup("_XENAKIOS_SELITEMSUNDEDCURSELTX") - Main_OnCommand(select_under, 0) - MoveEditCursor(-0.001, false) - MoveEditCursor(-xfade_len, false) - Main_OnCommand(41305, 0) -- Item edit: Trim left edge of item to edit cursor - MoveEditCursor(xfade_len, false) - MoveEditCursor(-0.0001, false) - xfade(xfade_len) - Main_OnCommand(40912, 0) -- Options: Toggle auto-crossfade on split (OFF) -end - ---------------------------------------------------------------------- - -function clean_up(proj_marker_count) - local i = 0 - while true do - local project, _ = EnumProjects(i) - if project == nil then - break - end - - if proj_marker_count ~= 2 then - DeleteProjectMarker(project, 998, false) - DeleteProjectMarker(project, 999, false) - end - DeleteProjectMarker(project, 996, false) - DeleteProjectMarker(project, 997, false) - - i = i + 1 - end -end - ---------------------------------------------------------------------- - -function lock_items() - local second_folder_track = find_second_folder_track() - - if second_folder_track == nil then - return - end - - local total_tracks = CountTracks(0) - - for track_idx = second_folder_track, total_tracks - 1 do - local track = GetTrack(0, track_idx) - - local num_items = CountTrackMediaItems(track) - - for item_idx = 0, num_items - 1 do - local item = GetTrackMediaItem(track, item_idx) - SetMediaItemInfo_Value(item, "C_LOCK", 1) - end - end -end - ---------------------------------------------------------------------- - -function unlock_items() - local total_items = CountMediaItems(0) - for i = 0, total_items - 1, 1 do - local item = GetMediaItem(0, i) - SetMediaItemInfo_Value(item, "C_LOCK", 0) - end -end - ---------------------------------------------------------------------- - -function ripple_lock_mode() - local _, original_ripple_lock_mode = get_config_var_string("ripplelockmode") - original_ripple_lock_mode = tonumber(original_ripple_lock_mode) - if original_ripple_lock_mode ~= 2 then - SNM_SetIntConfigVar("ripplelockmode", 2) - end -end - ---------------------------------------------------------------------- - -function return_xfade_length() - local xfade_len = 0.035 - local _, input = GetProjExtState(0, "ReaClassical S-D Editing", "Preferences") - if input ~= "" then - local table = {} - for entry in input:gmatch('([^,]+)') do table[#table + 1] = entry end - if table[1] then xfade_len = table[1] / 1000 end - end - return xfade_len -end - ---------------------------------------------------------------------- - -function xfade(xfade_len) - local select_items = NamedCommandLookup("_XENAKIOS_SELITEMSUNDEDCURSELTX") - Main_OnCommand(select_items, 0) -- Xenakios/SWS: Select items under edit cursor on selected tracks - MoveEditCursor(-xfade_len, false) - Main_OnCommand(40625, 0) -- Time selection: Set start point - MoveEditCursor(xfade_len, false) - Main_OnCommand(40626, 0) -- Time selection: Set end point - Main_OnCommand(40916, 0) -- Item: Crossfade items within time selection - Main_OnCommand(40635, 0) -- Time selection: Remove time selection - MoveEditCursor(0.001, false) - Main_OnCommand(select_items, 0) - MoveEditCursor(-0.001, false) -end - ---------------------------------------------------------------------- - -function get_first_last_items() - local num_of_items = CountSelectedMediaItems(0) - local first_sel_item - local last_sel_item - - for i = 0, num_of_items - 1 do - local item = GetSelectedMediaItem(0, i) - local track = GetMediaItem_Track(item) - local track_num = GetMediaTrackInfo_Value(track, "IP_TRACKNUMBER") - - if track_num == 1 then - if not first_sel_item then - first_sel_item = item - end - last_sel_item = item - end - end - - return first_sel_item, last_sel_item -end - ---------------------------------------------------------------------- - -function markers() - local marker_labels = { "DEST-IN", "DEST-OUT", "SOURCE-IN", "SOURCE-OUT" } - local sd_markers = {} - for _, label in ipairs(marker_labels) do - sd_markers[label] = { count = 0, proj = nil } - end - - local num = 0 - local source_proj, dest_proj - local proj_marker_count = 0 - local pos_table = {} - local active_proj = EnumProjects(-1) - local track_number = 1 - while true do - local proj = EnumProjects(num) - if proj == nil then - break - end - local _, num_markers, num_regions = CountProjectMarkers(proj) - for i = 0, num_markers + num_regions - 1, 1 do - local _, _, pos, _, raw_label, _ = EnumProjectMarkers2(proj, i) - local number = string.match(raw_label, "(%d+):.+") - local label = string.match(raw_label, "%d*:?(.+)") or "" - - if label == "DEST-IN" then - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[1] = pos - elseif label == "DEST-OUT" then - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[2] = pos - elseif label == "SOURCE-IN" then - track_number = number - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[3] = pos - elseif label == "SOURCE-OUT" then - track_number = number - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[4] = pos - elseif string.match(label, "SOURCE PROJECT") then - source_proj = proj - proj_marker_count = proj_marker_count + 1 - elseif string.match(label, "DEST PROJECT") then - dest_proj = proj - proj_marker_count = proj_marker_count + 1 - end - end - num = num + 1 - end - - if proj_marker_count == 0 then - for _, marker in pairs(sd_markers) do - if marker.proj ~= active_proj then - marker.count = 0 - end - end - end - - local source_in = sd_markers["SOURCE-IN"].count - local source_out = sd_markers["SOURCE-OUT"].count - local dest_in = sd_markers["DEST-IN"].count - local dest_out = sd_markers["DEST-OUT"].count - - local sin = sd_markers["SOURCE-IN"].proj - local sout = sd_markers["SOURCE-OUT"].proj - local din = sd_markers["DEST-IN"].proj - local dout = sd_markers["DEST-OUT"].proj - - - local source_count = source_in + source_out - local dest_count = dest_in + dest_out - - if (source_count == 2 and sin ~= sout) or (dest_count == 2 and din ~= dout) then proj_marker_count = -1 end - - if source_proj and ((sin and sin ~= source_proj) or (sout and sout ~= source_proj)) then - proj_marker_count = -1 - end - if dest_proj and ((din and din ~= dest_proj) or (dout and dout ~= dest_proj)) then - proj_marker_count = -1 - end - - return proj_marker_count, source_proj, dest_proj, dest_in, dest_out, dest_count, - source_in, source_out, source_count, pos_table, track_number -end - ---------------------------------------------------------------------- - -function mark_as_edit() - local selected_items = CountSelectedMediaItems(0) - for i = 0, selected_items - 1, 1 do - local item = GetSelectedMediaItem(0, i) - GetSetMediaItemInfo_String(item, "P_EXT:SD", "y", 1) - end -end - ---------------------------------------------------------------------- - -function move_to_project_tab(proj_type) - SelectProjectInstance(proj_type) -end - ---------------------------------------------------------------------- - -function find_second_folder_track() - local total_tracks = CountTracks(0) - local folder_count = 0 - - for track_idx = 0, total_tracks - 1 do - local track = GetTrack(0, track_idx) - local folder_depth = GetMediaTrackInfo_Value(track, "I_FOLDERDEPTH") - - if folder_depth == 1 then - folder_count = folder_count + 1 - - if folder_count == 2 then - return track_idx - end - end - end - - return nil -end - ---------------------------------------------------------------------- - -function check_overlapping_items() - local track = GetSelectedTrack(0, 0) - if not track then - ShowMessageBox("No track selected!", "Error", 0) - return - end - - local cursor_pos = GetCursorPosition() - local num_items = CountTrackMediaItems(track) - local overlapping = false - - for i = 0, num_items - 1 do - local item1 = GetTrackMediaItem(track, i) - local start1 = GetMediaItemInfo_Value(item1, "D_POSITION") - local length1 = GetMediaItemInfo_Value(item1, "D_LENGTH") - local end1 = start1 + length1 - - if cursor_pos >= start1 and cursor_pos <= end1 then - for j = i + 1, num_items - 1 do - local item2 = GetTrackMediaItem(track, j) - local start2 = GetMediaItemInfo_Value(item2, "D_POSITION") - - if start2 < end1 and cursor_pos >= start2 then - overlapping = true - break - end - end - end - if overlapping then break end - end - - return overlapping -end - ---------------------------------------------------------------------- - -function count_selected_media_items() - local selected_count = 0 - local total_items = CountMediaItems(0) - - for i = 0, total_items - 1 do - local item = GetMediaItem(0, i) - if IsMediaItemSelected(item) then - selected_count = selected_count + 1 - end - end - - return selected_count -end - ---------------------------------------------------------------------- - -function get_selected_media_item_at(index) - local selected_count = 0 - local total_items = CountMediaItems(0) - - for i = 0, total_items - 1 do - local item = GetMediaItem(0, i) - if IsMediaItemSelected(item) then - if selected_count == index then - return item - end - selected_count = selected_count + 1 - end - end - - return nil -end - ---------------------------------------------------------------------- - -main() diff --git a/RCEditing/RCEditing_Move to Destination IN marker.lua b/RCEditing/RCEditing_Move to Destination IN marker.lua deleted file mode 100644 index 2a1df6f6..00000000 --- a/RCEditing/RCEditing_Move to Destination IN marker.lua +++ /dev/null @@ -1,136 +0,0 @@ ---[[ -@noindex - -This file is a part of "ReaClassical Editing" package. - -Copyright (C) 2022–2025 chmaha - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program. If not, see . -]] - --- luacheck: ignore 113 - -for key in pairs(reaper) do _G[key] = reaper[key] end - -local main, markers, move_to_project_tab - ---------------------------------------------------------------------- - -function main() - local _, _, dest_proj = markers() - - if dest_proj then - move_to_project_tab(dest_proj) - end - - GoToMarker(0, 996, false) -end - ---------------------------------------------------------------------- - -function markers() - local marker_labels = { "DEST-IN", "DEST-OUT", "SOURCE-IN", "SOURCE-OUT" } - local sd_markers = {} - for _, label in ipairs(marker_labels) do - sd_markers[label] = { count = 0, proj = nil } - end - - local num = 0 - local source_proj, dest_proj - local proj_marker_count = 0 - local pos_table = {} - local active_proj = EnumProjects(-1) - local track_number = 1 - while true do - local proj = EnumProjects(num) - if proj == nil then - break - end - local _, num_markers, num_regions = CountProjectMarkers(proj) - for i = 0, num_markers + num_regions - 1, 1 do - local _, _, pos, _, raw_label, _ = EnumProjectMarkers2(proj, i) - local number = string.match(raw_label, "(%d+):.+") - local label = string.match(raw_label, "%d*:?(.+)") or "" - - if label == "DEST-IN" then - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[1] = pos - elseif label == "DEST-OUT" then - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[2] = pos - elseif label == "SOURCE-IN" then - track_number = number - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[3] = pos - elseif label == "SOURCE-OUT" then - track_number = number - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[4] = pos - elseif string.match(label, "SOURCE PROJECT") then - source_proj = proj - proj_marker_count = proj_marker_count + 1 - elseif string.match(label, "DEST PROJECT") then - dest_proj = proj - proj_marker_count = proj_marker_count + 1 - end - end - num = num + 1 - end - - if proj_marker_count == 0 then - for _, marker in pairs(sd_markers) do - if marker.proj ~= active_proj then - marker.count = 0 - end - end - end - - local source_in = sd_markers["SOURCE-IN"].count - local source_out = sd_markers["SOURCE-OUT"].count - local dest_in = sd_markers["DEST-IN"].count - local dest_out = sd_markers["DEST-OUT"].count - - local sin = sd_markers["SOURCE-IN"].proj - local sout = sd_markers["SOURCE-OUT"].proj - local din = sd_markers["DEST-IN"].proj - local dout = sd_markers["DEST-OUT"].proj - - - local source_count = source_in + source_out - local dest_count = dest_in + dest_out - - if (source_count == 2 and sin ~= sout) or (dest_count == 2 and din ~= dout) then proj_marker_count = -1 end - - if source_proj and ((sin and sin ~= source_proj) or (sout and sout ~= source_proj)) then - proj_marker_count = -1 - end - if dest_proj and ((din and din ~= dest_proj) or (dout and dout ~= dest_proj)) then - proj_marker_count = -1 - end - - return proj_marker_count, source_proj, dest_proj, dest_in, dest_out, dest_count, - source_in, source_out, source_count, pos_table, track_number -end - ---------------------------------------------------------------------- - -function move_to_project_tab(proj_type) - SelectProjectInstance(proj_type) -end - ---------------------------------------------------------------------- - -main() diff --git a/RCEditing/RCEditing_Move to Destination OUT marker.lua b/RCEditing/RCEditing_Move to Destination OUT marker.lua deleted file mode 100644 index 9ab6cd04..00000000 --- a/RCEditing/RCEditing_Move to Destination OUT marker.lua +++ /dev/null @@ -1,136 +0,0 @@ ---[[ -@noindex - -This file is a part of "ReaClassical Editing" package. - -Copyright (C) 2022–2025 chmaha - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program. If not, see . -]] - --- luacheck: ignore 113 - -for key in pairs(reaper) do _G[key] = reaper[key] end - -local main, markers, move_to_project_tab - ---------------------------------------------------------------------- - -function main() - local _, _, dest_proj = markers() - - if dest_proj then - move_to_project_tab(dest_proj) - end - - GoToMarker(0, 997, false) -end - ---------------------------------------------------------------------- - -function markers() - local marker_labels = { "DEST-IN", "DEST-OUT", "SOURCE-IN", "SOURCE-OUT" } - local sd_markers = {} - for _, label in ipairs(marker_labels) do - sd_markers[label] = { count = 0, proj = nil } - end - - local num = 0 - local source_proj, dest_proj - local proj_marker_count = 0 - local pos_table = {} - local active_proj = EnumProjects(-1) - local track_number = 1 - while true do - local proj = EnumProjects(num) - if proj == nil then - break - end - local _, num_markers, num_regions = CountProjectMarkers(proj) - for i = 0, num_markers + num_regions - 1, 1 do - local _, _, pos, _, raw_label, _ = EnumProjectMarkers2(proj, i) - local number = string.match(raw_label, "(%d+):.+") - local label = string.match(raw_label, "%d*:?(.+)") or "" - - if label == "DEST-IN" then - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[1] = pos - elseif label == "DEST-OUT" then - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[2] = pos - elseif label == "SOURCE-IN" then - track_number = number - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[3] = pos - elseif label == "SOURCE-OUT" then - track_number = number - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[4] = pos - elseif string.match(label, "SOURCE PROJECT") then - source_proj = proj - proj_marker_count = proj_marker_count + 1 - elseif string.match(label, "DEST PROJECT") then - dest_proj = proj - proj_marker_count = proj_marker_count + 1 - end - end - num = num + 1 - end - - if proj_marker_count == 0 then - for _, marker in pairs(sd_markers) do - if marker.proj ~= active_proj then - marker.count = 0 - end - end - end - - local source_in = sd_markers["SOURCE-IN"].count - local source_out = sd_markers["SOURCE-OUT"].count - local dest_in = sd_markers["DEST-IN"].count - local dest_out = sd_markers["DEST-OUT"].count - - local sin = sd_markers["SOURCE-IN"].proj - local sout = sd_markers["SOURCE-OUT"].proj - local din = sd_markers["DEST-IN"].proj - local dout = sd_markers["DEST-OUT"].proj - - - local source_count = source_in + source_out - local dest_count = dest_in + dest_out - - if (source_count == 2 and sin ~= sout) or (dest_count == 2 and din ~= dout) then proj_marker_count = -1 end - - if source_proj and ((sin and sin ~= source_proj) or (sout and sout ~= source_proj)) then - proj_marker_count = -1 - end - if dest_proj and ((din and din ~= dest_proj) or (dout and dout ~= dest_proj)) then - proj_marker_count = -1 - end - - return proj_marker_count, source_proj, dest_proj, dest_in, dest_out, dest_count, - source_in, source_out, source_count, pos_table, track_number -end - ---------------------------------------------------------------------- - -function move_to_project_tab(proj_type) - SelectProjectInstance(proj_type) -end - ---------------------------------------------------------------------- - -main() diff --git a/RCEditing/RCEditing_Move to Source IN marker.lua b/RCEditing/RCEditing_Move to Source IN marker.lua deleted file mode 100644 index f2a2079a..00000000 --- a/RCEditing/RCEditing_Move to Source IN marker.lua +++ /dev/null @@ -1,136 +0,0 @@ ---[[ -@noindex - -This file is a part of "ReaClassical Editing" package. - -Copyright (C) 2022–2025 chmaha - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program. If not, see . -]] - --- luacheck: ignore 113 - -for key in pairs(reaper) do _G[key] = reaper[key] end - -local main, markers, move_to_project_tab - ---------------------------------------------------------------------- - -function main() - local _, source_proj = markers() - - if source_proj then - move_to_project_tab(source_proj) - end - - GoToMarker(0, 998, false) -end - ---------------------------------------------------------------------- - -function markers() - local marker_labels = { "DEST-IN", "DEST-OUT", "SOURCE-IN", "SOURCE-OUT" } - local sd_markers = {} - for _, label in ipairs(marker_labels) do - sd_markers[label] = { count = 0, proj = nil } - end - - local num = 0 - local source_proj, dest_proj - local proj_marker_count = 0 - local pos_table = {} - local active_proj = EnumProjects(-1) - local track_number = 1 - while true do - local proj = EnumProjects(num) - if proj == nil then - break - end - local _, num_markers, num_regions = CountProjectMarkers(proj) - for i = 0, num_markers + num_regions - 1, 1 do - local _, _, pos, _, raw_label, _ = EnumProjectMarkers2(proj, i) - local number = string.match(raw_label, "(%d+):.+") - local label = string.match(raw_label, "%d*:?(.+)") or "" - - if label == "DEST-IN" then - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[1] = pos - elseif label == "DEST-OUT" then - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[2] = pos - elseif label == "SOURCE-IN" then - track_number = number - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[3] = pos - elseif label == "SOURCE-OUT" then - track_number = number - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[4] = pos - elseif string.match(label, "SOURCE PROJECT") then - source_proj = proj - proj_marker_count = proj_marker_count + 1 - elseif string.match(label, "DEST PROJECT") then - dest_proj = proj - proj_marker_count = proj_marker_count + 1 - end - end - num = num + 1 - end - - if proj_marker_count == 0 then - for _, marker in pairs(sd_markers) do - if marker.proj ~= active_proj then - marker.count = 0 - end - end - end - - local source_in = sd_markers["SOURCE-IN"].count - local source_out = sd_markers["SOURCE-OUT"].count - local dest_in = sd_markers["DEST-IN"].count - local dest_out = sd_markers["DEST-OUT"].count - - local sin = sd_markers["SOURCE-IN"].proj - local sout = sd_markers["SOURCE-OUT"].proj - local din = sd_markers["DEST-IN"].proj - local dout = sd_markers["DEST-OUT"].proj - - - local source_count = source_in + source_out - local dest_count = dest_in + dest_out - - if (source_count == 2 and sin ~= sout) or (dest_count == 2 and din ~= dout) then proj_marker_count = -1 end - - if source_proj and ((sin and sin ~= source_proj) or (sout and sout ~= source_proj)) then - proj_marker_count = -1 - end - if dest_proj and ((din and din ~= dest_proj) or (dout and dout ~= dest_proj)) then - proj_marker_count = -1 - end - - return proj_marker_count, source_proj, dest_proj, dest_in, dest_out, dest_count, - source_in, source_out, source_count, pos_table, track_number -end - ---------------------------------------------------------------------- - -function move_to_project_tab(proj_type) - SelectProjectInstance(proj_type) -end - ---------------------------------------------------------------------- - -main() diff --git a/RCEditing/RCEditing_Move to Source OUT marker.lua b/RCEditing/RCEditing_Move to Source OUT marker.lua deleted file mode 100644 index b2e24543..00000000 --- a/RCEditing/RCEditing_Move to Source OUT marker.lua +++ /dev/null @@ -1,136 +0,0 @@ ---[[ -@noindex - -This file is a part of "ReaClassical Editing" package. - -Copyright (C) 2022–2025 chmaha - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program. If not, see . -]] - --- luacheck: ignore 113 - -for key in pairs(reaper) do _G[key] = reaper[key] end - -local main, markers, move_to_project_tab - ---------------------------------------------------------------------- - -function main() - local _, source_proj = markers() - - if source_proj then - move_to_project_tab(source_proj) - end - - GoToMarker(0, 999, false) -end - ---------------------------------------------------------------------- - -function markers() - local marker_labels = { "DEST-IN", "DEST-OUT", "SOURCE-IN", "SOURCE-OUT" } - local sd_markers = {} - for _, label in ipairs(marker_labels) do - sd_markers[label] = { count = 0, proj = nil } - end - - local num = 0 - local source_proj, dest_proj - local proj_marker_count = 0 - local pos_table = {} - local active_proj = EnumProjects(-1) - local track_number = 1 - while true do - local proj = EnumProjects(num) - if proj == nil then - break - end - local _, num_markers, num_regions = CountProjectMarkers(proj) - for i = 0, num_markers + num_regions - 1, 1 do - local _, _, pos, _, raw_label, _ = EnumProjectMarkers2(proj, i) - local number = string.match(raw_label, "(%d+):.+") - local label = string.match(raw_label, "%d*:?(.+)") or "" - - if label == "DEST-IN" then - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[1] = pos - elseif label == "DEST-OUT" then - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[2] = pos - elseif label == "SOURCE-IN" then - track_number = number - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[3] = pos - elseif label == "SOURCE-OUT" then - track_number = number - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[4] = pos - elseif string.match(label, "SOURCE PROJECT") then - source_proj = proj - proj_marker_count = proj_marker_count + 1 - elseif string.match(label, "DEST PROJECT") then - dest_proj = proj - proj_marker_count = proj_marker_count + 1 - end - end - num = num + 1 - end - - if proj_marker_count == 0 then - for _, marker in pairs(sd_markers) do - if marker.proj ~= active_proj then - marker.count = 0 - end - end - end - - local source_in = sd_markers["SOURCE-IN"].count - local source_out = sd_markers["SOURCE-OUT"].count - local dest_in = sd_markers["DEST-IN"].count - local dest_out = sd_markers["DEST-OUT"].count - - local sin = sd_markers["SOURCE-IN"].proj - local sout = sd_markers["SOURCE-OUT"].proj - local din = sd_markers["DEST-IN"].proj - local dout = sd_markers["DEST-OUT"].proj - - - local source_count = source_in + source_out - local dest_count = dest_in + dest_out - - if (source_count == 2 and sin ~= sout) or (dest_count == 2 and din ~= dout) then proj_marker_count = -1 end - - if source_proj and ((sin and sin ~= source_proj) or (sout and sout ~= source_proj)) then - proj_marker_count = -1 - end - if dest_proj and ((din and din ~= dest_proj) or (dout and dout ~= dest_proj)) then - proj_marker_count = -1 - end - - return proj_marker_count, source_proj, dest_proj, dest_in, dest_out, dest_count, - source_in, source_out, source_count, pos_table, track_number -end - ---------------------------------------------------------------------- - -function move_to_project_tab(proj_type) - SelectProjectInstance(proj_type) -end - ---------------------------------------------------------------------- - -main() diff --git a/RCEditing/RCEditing_Preferences.lua b/RCEditing/RCEditing_Preferences.lua deleted file mode 100644 index d2c9e3ac..00000000 --- a/RCEditing/RCEditing_Preferences.lua +++ /dev/null @@ -1,132 +0,0 @@ ---[[ -@noindex - -This file is a part of "ReaClassical Editing" package. - -Copyright (C) 2022–2025 chmaha - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program. If not, see . -]] - --- luacheck: ignore 113 - -for key in pairs(reaper) do _G[key] = reaper[key] end - -local main, display_prefs, load_prefs, save_prefs, pref_check - -local default_values = '35,500,0' -local NUM_OF_ENTRIES = select(2, default_values:gsub(",", ",")) + 1 -local labels = { - 'S-D Crossfade length (ms)', - 'S-D Marker Check (ms)', - 'Add S-D Markers at Mouse Hover' -} - ---------------------------------------------------------------------- - -function main() - local pass - local input - repeat - local ret - ret, input = display_prefs() - if not ret then return end - if ret then pass = pref_check(input) end - until pass - - save_prefs(input) -end - ------------------------------------------------------------------------ - -function display_prefs() - local saved = load_prefs(NUM_OF_ENTRIES) - local input_labels = table.concat(labels, ',') - local ret, input = GetUserInputs('ReaClassical S-D Editing Preferences', NUM_OF_ENTRIES, input_labels, saved) - return ret, input -end - ------------------------------------------------------------------------ - -function load_prefs() - local _, saved = GetProjExtState(0, "ReaClassical S-D Editing", "Preferences") - if saved == "" then return default_values end - - local saved_entries = {} - - for entry in saved:gmatch('([^,]+)') do - saved_entries[#saved_entries + 1] = entry - end - - if #saved_entries < NUM_OF_ENTRIES then - local i = 1 - for entry in default_values:gmatch("([^,]+)") do - if i == #saved_entries + 1 then - saved_entries[i] = entry - end - i = i + 1 - end - elseif #saved_entries > NUM_OF_ENTRIES then - local j = 1 - for entry in default_values:gmatch("([^,]+)") do - saved_entries[j] = entry - j = j + 1 - end - end - - saved = table.concat(saved_entries, ',') - - return saved -end - ------------------------------------------------------------------------ - -function save_prefs(input) - SetProjExtState(0, "ReaClassical S-D Editing", "Preferences", input) -end - ------------------------------------------------------------------------ - -function pref_check(input) - local pass = true - local table = {} - local invalid_msg = "" - for entry in input:gmatch('([^,]*)') do - table[#table + 1] = entry - if entry == "" or tonumber(entry) == nil or tonumber(entry) < 0 then - pass = false - invalid_msg = "Entries should not be strings or left empty." - end - end - - local binary_error_msg = "" - -- separate check for binary options - if #table == NUM_OF_ENTRIES then - local num_3 = tonumber(table[3]) - if (num_3 and num_3 > 1) then - binary_error_msg = "Mouse Hover option must be set to 0 or 1.\n" - pass = false - end - end - - local error_msg = binary_error_msg .. invalid_msg - - if not pass then - MB(error_msg, "Error", 0) - end - - return pass -end - ------------------------------------------------------------------------ - -main() diff --git a/RCEditing/RCEditing_Prepare Takes.lua b/RCEditing/RCEditing_Prepare Takes.lua deleted file mode 100644 index f9e731a9..00000000 --- a/RCEditing/RCEditing_Prepare Takes.lua +++ /dev/null @@ -1,369 +0,0 @@ ---[[ -@noindex - -This file is a part of "ReaClassical Editing" package. - -Copyright (C) 2022–2025 chmaha - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program. If not, see . -]] - --- luacheck: ignore 113 - -for key in pairs(reaper) do _G[key] = reaper[key] end - -local main, shift, vertical_razor, horizontal_group -local vertical_group, horizontal, vertical, copy_track_items -local tracks_per_folder, empty_items_check, folder_check -local trackname_check - ---------------------------------------------------------------------- - -local SWS_exists = APIExists("CF_GetSWSVersion") -if not SWS_exists then - MB('Please install SWS/S&M extension before running this function', 'Error: Missing Extension', 0) - return -end - -function main() - local group_state = GetToggleCommandState(1156) - if group_state ~= 1 then - Main_OnCommand(1156, 0) -- Enable item grouping - end - local cur_pos = (GetPlayState() == 0) and GetCursorPosition() or GetPlayPosition() - local start_time, end_time = GetSet_ArrangeView2(0, false, 0, 0, 0, 0) - SetProjExtState(0, "ReaClassical S-D Editing", "arrangestarttime", start_time) - SetProjExtState(0, "ReaClassical S-D Editing", "arrangeendtime", end_time) - local num_of_project_items = CountMediaItems(0) - if num_of_project_items == 0 then - MB("Please add your takes before running...", "Prepare Takes", 0) - return - end - local empty_count = empty_items_check(num_of_project_items) - if empty_count > 0 then - MB("Error: Empty items found. Delete them to continue.", "Prepare Takes", 0) - return - end - - PreventUIRefresh(1) - Undo_BeginBlock() - - for track_idx = 0, reaper.CountTracks(0) - 1 do - local track = reaper.GetTrack(0, track_idx) - for item_idx = 0, reaper.CountTrackMediaItems(track) - 1 do - local item = reaper.GetTrackMediaItem(track, item_idx) - reaper.SetMediaItemInfo_Value(item, "I_GROUPID", 0) - end - end - - Main_OnCommand(40769, 0) -- Unselect (clear selection of) all tracks/items/envelope points - local folders, tracks_per_group = folder_check() - local total_tracks = folders * tracks_per_group - local empty = false - for i = 0, total_tracks - 1, 1 do - local track = GetTrack(0, i) - if GetMediaTrackInfo_Value(track, "I_FOLDERDEPTH") == 1.0 then - local items = CountTrackMediaItems(track) - if items == 0 then - for j = i + 1, i + 1 + tracks_per_group, 1 do - local child_track = GetTrack(0, j) - local child_items = CountTrackMediaItems(child_track) - if child_items > 0 then - empty = true - break - end - end - end - end - end - - local first_item = GetMediaItem(0, 0) - local position = GetMediaItemInfo_Value(first_item, "D_POSITION") - if position == 0.0 then - shift() - end - - if empty then - local folder_size = tracks_per_folder() - copy_track_items(folder_size, total_tracks) - end - - if folders == 0 or folders == 1 then - horizontal() - else - vertical() - end - - local _, prev_start_time = GetProjExtState(0, "ReaClassical S-D Editing", "arrangestarttime") - local _, prev_end_time = GetProjExtState(0, "ReaClassical S-D Editing", "arrangeendtime") - GetSet_ArrangeView2(0, true, 0, 0, prev_start_time, prev_end_time) - SetEditCurPos(cur_pos, 0, 0) - - local scroll_up = NamedCommandLookup("_XENAKIOS_TVPAGEHOME") - Main_OnCommand(scroll_up, 0) - - SetProjExtState(0, "ReaClassical S-D Editing", "arrangestarttime", "") - SetProjExtState(0, "ReaClassical S-D Editing", "arrangeendtime", "") - - if empty then - MB( - "Some folder tracks are empty. If the folders are not completely empty, items " .. - "from first child tracks were copied to folder tracks and muted to act as guide tracks." - , "Guide Tracks Created", 0) - end - Undo_EndBlock('Prepare Takes', 0) - PreventUIRefresh(-1) - UpdateArrange() - UpdateTimeline() -end - ---------------------------------------------------------------------- - -function shift() - Main_OnCommand(40182, 0) -- select all items - local nudge_right = NamedCommandLookup("_SWS_NUDGESAMPLERIGHT") - Main_OnCommand(nudge_right, 0) -- shift items by 1 sample to the right - Main_OnCommand(40289, 0) -- unselect all items -end - ---------------------------------------------------------------------- - -function vertical_razor() - Main_OnCommand(40042, 0) -- Transport: Go to start of project - local select_children = NamedCommandLookup("_SWS_SELCHILDREN2") - Main_OnCommand(select_children, 0) -- Select child tracks - Main_OnCommand(42579, 0) -- Track: Remove selected tracks from all track media/razor editing groups - Main_OnCommand(42578, 0) -- Track: Create new track media/razor editing group from selected tracks - Main_OnCommand(40421, 0) -- Item: Select all items in track -end - ---------------------------------------------------------------------- - -function horizontal_group(string, group) - if string == "horizontal" then - Main_OnCommand(40296, 0) -- Track: Select all tracks - else - local select_children = NamedCommandLookup("_SWS_SELCHILDREN2") - Main_OnCommand(select_children, 0) -- Select child tracks - end - - local selected = GetSelectedMediaItem(0, 0) - local start = GetMediaItemInfo_Value(selected, "D_POSITION") - local length = GetMediaItemInfo_Value(selected, "D_LENGTH") - SetEditCurPos(start + (length / 2), false, false) -- move to middle of item - local select_under = NamedCommandLookup("_XENAKIOS_SELITEMSUNDEDCURSELTX") - Main_OnCommand(select_under, 0) -- XENAKIOS_SELITEMSUNDEDCURSELTX - - local num_selected_items = CountSelectedMediaItems(0) - for i = 0, num_selected_items - 1 do - local item = GetSelectedMediaItem(0, i) - if item then - SetMediaItemInfo_Value(item, "I_GROUPID", group) - end - end -end - ---------------------------------------------------------------------- - -function vertical_group(length, group) - local track = GetSelectedTrack(0, 0) - local item = AddMediaItemToTrack(track) - SetMediaItemPosition(item, length + 1, false) - - Main_OnCommand(40417, 0) -- Item navigation: Select and move to next item - repeat - local selected = GetSelectedMediaItem(0, 0) - local start = GetMediaItemInfo_Value(selected, "D_POSITION") - local item_length = GetMediaItemInfo_Value(selected, "D_LENGTH") - SetEditCurPos(start + (item_length / 2), false, false) -- move to middle of item - local select_under = NamedCommandLookup("_XENAKIOS_SELITEMSUNDEDCURSELTX") - Main_OnCommand(select_under, 0) -- XENAKIOS_SELITEMSUNDEDCURSELTX - - local num_selected_items = reaper.CountSelectedMediaItems(0) - for i = 0, num_selected_items - 1 do - local selected_item = reaper.GetSelectedMediaItem(0, i) - if selected_item then - reaper.SetMediaItemInfo_Value(selected_item, "I_GROUPID", group) - end - end - group = group + 1 - Main_OnCommand(40417, 0) -- Item navigation: Select and move to next item - until IsMediaItemSelected(item) == true - - DeleteTrackMediaItem(track, item) - return group -end - ---------------------------------------------------------------------- - -function horizontal() - local length = GetProjectLength(0) - local first_track = GetTrack(0, 0) - local new_item = AddMediaItemToTrack(first_track) - SetMediaItemPosition(new_item, length + 1, false) - - if first_track then - SetOnlyTrackSelected(first_track) -- Select only the first track - end - SetEditCurPos(0, false, false) - - local workflow = "horizontal" - local group = 1 - Main_OnCommand(40417, 0) -- Item navigation: Select and move to next item - repeat - horizontal_group(workflow, group) - group = group + 1 - Main_OnCommand(40417, 0) -- Item navigation: Select and move to next item - until IsMediaItemSelected(new_item) == true - - DeleteTrackMediaItem(first_track, new_item) - SelectAllMediaItems(0, false) - Main_OnCommand(42579, 0) -- Track: Remove selected tracks from all track media/razor editing groups - Main_OnCommand(42578, 0) -- Track: Create new track media/razor editing group from selected tracks - Main_OnCommand(40297, 0) -- Track: Unselect (clear selection of) all tracks - SetEditCurPos(0, false, false) -end - ---------------------------------------------------------------------- - -function vertical() - local select_all_folders = NamedCommandLookup("_SWS_SELALLPARENTS") - Main_OnCommand(select_all_folders, 0) -- select all folders - local num_of_folders = CountSelectedTracks(0) - local length = GetProjectLength(0) - local first_track = GetTrack(0, 0) - - local new_item = AddMediaItemToTrack(first_track) - SetMediaItemPosition(new_item, length + 1, false) - local group = 1 - SetOnlyTrackSelected(first_track) - SetEditCurPos(0, false, false) - local workflow = "vertical" - Main_OnCommand(40417, 0) -- Item navigation: Select and move to next item - repeat - horizontal_group(workflow, group) - group = group + 1 - Main_OnCommand(40417, 0) -- Item navigation: Select and move to next item - until IsMediaItemSelected(new_item) == true - - DeleteTrackMediaItem(first_track, new_item) - local next_folder = NamedCommandLookup("_SWS_SELNEXTFOLDER") - local start = 1 - start = 2 - Main_OnCommand(next_folder, 0) -- select next folder - - for _ = start, num_of_folders, 1 do - vertical_razor() - local next_group = vertical_group(length, group) - Main_OnCommand(next_folder, 0) -- select next folder - group = next_group - end - SelectAllMediaItems(0, false) - Main_OnCommand(40297, 0) -- Track: Unselect (clear selection of) all tracks - SetEditCurPos(0, false, false) -end - ---------------------------------------------------------------------- - -function copy_track_items(folder_size, total_tracks) - local pos = 0; - for i = 1, total_tracks - 1, folder_size do - local track = GetTrack(0, i) - local previous_track = GetTrack(0, i - 1) - local count_items = CountTrackMediaItems(previous_track) - if count_items > 0 then goto continue end -- guard clause for populated folder - SetOnlyTrackSelected(track) - local num_of_items = CountTrackMediaItems(track) - if num_of_items == 0 then goto continue end -- guard clause for empty first child - for j = 0, num_of_items - 1 do - local item = GetTrackMediaItem(track, j) - if j == 0 then - pos = GetMediaItemInfo_Value(item, "D_POSITION") - end - SetMediaItemSelected(item, 1) - end - Main_OnCommand(40698, 0) -- Edit: Copy items - SetOnlyTrackSelected(previous_track) - SetEditCurPos(pos, false, false) - Main_OnCommand(42398, 0) -- Item: Paste items/tracks - Main_OnCommand(40719, 0) -- Item properties: Mute - Main_OnCommand(40769, 0) -- Unselect (clear selection of) all tracks/items/envelope points - ::continue:: - end -end - ---------------------------------------------------------------------- - -function tracks_per_folder() - local first_track = GetTrack(0, 0) - SetOnlyTrackSelected(first_track) - local select_children = NamedCommandLookup("_SWS_SELCHILDREN2") - Main_OnCommand(select_children, 0) -- SWS: Select children of selected folder track(s) - local selected_tracks = CountSelectedTracks(0) - Main_OnCommand(40297, 0) -- Track: Unselect (clear selection of) all tracks - return selected_tracks -end - ---------------------------------------------------------------------- - -function empty_items_check(num_of_items) - local count = 0 - for i = 0, num_of_items - 1, 1 do - local current_item = GetMediaItem(0, i) - local take = GetActiveTake(current_item) - if not take then - count = count + 1 - end - end - return count -end - ---------------------------------------------------------------------- - -function folder_check() - local folders = 0 - local tracks_per_group = 1 - local total_tracks = CountTracks(0) - for i = 0, total_tracks - 1, 1 do - local track = GetTrack(0, i) - local _, mixer_state = GetSetMediaTrackInfo_String(track, "P_EXT:mixer", "", 0) - local _, aux_state = GetSetMediaTrackInfo_String(track, "P_EXT:aux", "", 0) - local _, submix_state = GetSetMediaTrackInfo_String(track, "P_EXT:submix", "", 0) - local _, rt_state = GetSetMediaTrackInfo_String(track, "P_EXT:roomtone", "", 0) - local _, ref_state = GetSetMediaTrackInfo_String(track, "P_EXT:rcref", "", 0) - local _, rcmaster_state = GetSetMediaTrackInfo_String(track, "P_EXT:rcmaster", "", 0) - - local special_states = mixer_state == "y" or aux_state == "y" or submix_state == "y" - or rt_state == "y" or ref_state == "y" or rcmaster_state == "y" - local special_names = trackname_check(track, "^M:") or trackname_check(track, "^RCMASTER") - or trackname_check(track, "^@") or trackname_check(track, "^#") or trackname_check(track, "^RoomTone") - or trackname_check(track, "^REF") - - if GetMediaTrackInfo_Value(track, "I_FOLDERDEPTH") == 1 then - folders = folders + 1 - elseif folders == 1 and not (special_states or special_names) then - tracks_per_group = tracks_per_group + 1 - end - end - return folders, tracks_per_group, total_tracks -end - ---------------------------------------------------------------------- - -function trackname_check(track, string) - local _, trackname = GetSetMediaTrackInfo_String(track, "P_NAME", "", false) - return string.find(trackname, string) -end - ---------------------------------------------------------------------- - -main() diff --git a/RCEditing/RCEditing_S-D Edit.lua b/RCEditing/RCEditing_S-D Edit.lua deleted file mode 100644 index 0887b4ec..00000000 --- a/RCEditing/RCEditing_S-D Edit.lua +++ /dev/null @@ -1,643 +0,0 @@ ---[[ -@noindex - -This file is a part of "ReaClassical Editing" package. - -Copyright (C) 2022–2025 chmaha - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program. If not, see . -]] - --- luacheck: ignore 113 - -for key in pairs(reaper) do _G[key] = reaper[key] end - -local main, markers, add_source_marker -local get_track_length, select_matching_folder, copy_source, split_at_dest_in -local create_crossfades, clean_up, lock_items, unlock_items -local ripple_lock_mode, return_xfade_length, xfade -local get_first_last_items, mark_as_edit -local move_to_project_tab, find_second_folder_track -local check_overlapping_items, count_selected_media_items, get_selected_media_item_at - ---------------------------------------------------------------------- - -local SWS_exists = APIExists("CF_GetSWSVersion") -if not SWS_exists then - MB('Please install SWS/S&M extension before running this function', 'Error: Missing Extension', 0) - return -end - -function main() - PreventUIRefresh(1) - Undo_BeginBlock() - Main_OnCommand(41121,0) -- Options: Disable trim content behind media items when editing - local group_state = GetToggleCommandState(1156) - if group_state ~= 1 then - Main_OnCommand(1156, 0) -- Enable item grouping - end - local proj_marker_count, source_proj, dest_proj, dest_in, dest_out, dest_count, source_in, - source_out, source_count, pos_table, track_number = markers() - - if proj_marker_count == 1 then - MB("Only one S-D project marker was found." - .. "\nUse zero for regular single project S-D editing" - .. "\nor use two for multi-tab S-D editing.", "Source-Destination Edit", 0) - return - end - - if proj_marker_count == -1 or proj_marker_count == 1 then - MB( - "Source or destination markers should be paired with " .. - "the corresponding source or destination project marker.", - "Multi-tab Source-Destination Edit", 0) - return - end - - ripple_lock_mode() - if dest_count + source_count == 3 and pos_table ~= nil then -- add one extra marker for 3-point editing - local distance - local pos - if dest_in == 0 then - pos = pos_table[2] - distance = pos_table[4] - pos_table[3] - move_to_project_tab(dest_proj) - AddProjectMarker2(0, false, pos - distance, 0, "DEST-IN", 996, ColorToNative(23,203,223) | 0x1000000) - elseif dest_out == 0 then - pos = pos_table[1] - distance = pos_table[4] - pos_table[3] - move_to_project_tab(dest_proj) - AddProjectMarker2(0, false, pos + distance, 0, "DEST-OUT", 997, ColorToNative(23,203,223) | 0x1000000) - elseif source_in == 0 then - pos = pos_table[4] - distance = pos_table[1] - pos_table[2] - move_to_project_tab(source_proj) - add_source_marker(pos, distance, track_number, "SOURCE-IN", 998) - elseif source_out == 0 then - pos = pos_table[3] - distance = pos_table[2] - pos_table[1] - move_to_project_tab(source_proj) - add_source_marker(pos, distance, track_number, "SOURCE-OUT", 999) - end - elseif dest_count == 1 and source_count == 1 then -- add two extra markers 2-point editing - if dest_in == 1 and source_in == 1 then - move_to_project_tab(dest_proj) - local source_end - if proj_marker_count == 2 then - source_end = GetProjectLength(0) - else - source_end = get_track_length(track_number) - end - move_to_project_tab(source_proj) - add_source_marker(source_end, 0, track_number, "SOURCE-OUT", 999) - local dest_end = GetProjectLength(0) - move_to_project_tab(dest_proj) - AddProjectMarker2(0, false, dest_end, 0, "DEST-OUT", 997, ColorToNative(23,203,223) | 0x1000000) - elseif dest_out == 1 and source_out == 1 then - move_to_project_tab(source_proj) - add_source_marker(0, 0, track_number, "SOURCE-IN", 998) - move_to_project_tab(dest_proj) - AddProjectMarker2(0, false, 0, 0, "DEST-IN", 996, ColorToNative(23,203,223) | 0x1000000) - elseif source_in == 1 and dest_out == 1 then - move_to_project_tab(dest_proj) - local source_end - if proj_marker_count == 2 then - source_end = GetProjectLength(0) - else - source_end = get_track_length(track_number) - end - move_to_project_tab(source_proj) - add_source_marker(source_end, 0, track_number, "SOURCE-OUT", 999) - move_to_project_tab(dest_proj) - AddProjectMarker2(0, false, 0, 0, "DEST-IN", 996, ColorToNative(23,203,223) | 0x1000000) - elseif source_out == 1 and dest_in == 1 then - move_to_project_tab(source_proj) - add_source_marker(0, 0, track_number, "SOURCE-IN", 998) - local dest_end = GetProjectLength(0) - move_to_project_tab(dest_proj) - AddProjectMarker2(0, false, dest_end, 0, "DEST-OUT", 997, ColorToNative(23,203,223) | 0x1000000) - end - elseif source_count == 2 and dest_count == 0 and pos_table ~= nil and proj_marker_count == 0 then - AddProjectMarker2(0, false, pos_table[3], 0, "DEST-IN", 996, ColorToNative(23,203,223) | 0x1000000) - AddProjectMarker2(0, false, pos_table[4], 0, "DEST-OUT", 997, ColorToNative(23,203,223) | 0x1000000) - end - - local _, _, _, _, _, new_dest_count, _, _, new_source_count, _, _ = markers() - if new_dest_count + new_source_count == 4 then -- final check we actually have 4 S-D markers - move_to_project_tab(dest_proj) - lock_items() - move_to_project_tab(source_proj) - local _, is_selected = copy_source() - if is_selected == false then - clean_up(is_selected, proj_marker_count, source_count, source_in, source_out) - return - end - Main_OnCommand(40020, 0) -- remove time selection - move_to_project_tab(dest_proj) - split_at_dest_in() - Main_OnCommand(40625, 0) -- Time Selection: Set start point - GoToMarker(0, 997, false) - Main_OnCommand(40289, 0) - Main_OnCommand(40626, 0) -- Time Selection: Set end point - Main_OnCommand(40718, 0) -- Select all items on selected tracks in current time selection - Main_OnCommand(40034, 0) -- Item Grouping: Select all items in group(s) - Main_OnCommand(40630, 0) -- Go to start of time selection - - if workflow == "Horizontal" then - Main_OnCommand(40311, 0) -- Set ripple-all-tracks - else - Main_OnCommand(40310, 0) -- Set ripple-per-track - end - - local delete = NamedCommandLookup("_XENAKIOS_TSADEL") - Main_OnCommand(delete, 0) -- Adaptive Delete - local paste = NamedCommandLookup("_SWS_AWPASTE") - Main_OnCommand(paste, 0) -- SWS_AWPASTE - mark_as_edit() - unlock_items() - create_crossfades() - clean_up(is_selected, proj_marker_count, source_count, source_in, source_out) - Main_OnCommand(40289, 0) -- Item: Unselect all items - Main_OnCommand(40310, 0) -- Toggle ripple editing per-track - else - MB( - "Please add at least 2 valid source-destination markers: \n" .. - "2-point edit: Either 1 DEST and 1 SOURCE marker (any combination) " .. - "or both SOURCE markers (when not in multi-tab mode)\n" .. - "3-point edit: Any combination of 3 markers \n 4-point edit: DEST-IN, DEST-OUT, SOURCE-IN and SOURCE-OUT" - , "Source-Destination Edit", 0) - return - end - - Undo_EndBlock('S-D Edit', 0) - PreventUIRefresh(-1) - UpdateArrange() - UpdateTimeline() -end - ---------------------------------------------------------------------- - -function markers() - local marker_labels = { "DEST-IN", "DEST-OUT", "SOURCE-IN", "SOURCE-OUT" } - local sd_markers = {} - for _, label in ipairs(marker_labels) do - sd_markers[label] = { count = 0, proj = nil } - end - - local num = 0 - local source_proj, dest_proj - local proj_marker_count = 0 - local pos_table = {} - local active_proj = EnumProjects(-1) - local track_number = 1 - while true do - local proj = EnumProjects(num) - if proj == nil then - break - end - local _, num_markers, num_regions = CountProjectMarkers(proj) - for i = 0, num_markers + num_regions - 1, 1 do - local _, _, pos, _, raw_label, _ = EnumProjectMarkers2(proj, i) - local number = string.match(raw_label, "(%d+):.+") - local label = string.match(raw_label, "%d*:?(.+)") or "" - - if label == "DEST-IN" then - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[1] = pos - elseif label == "DEST-OUT" then - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[2] = pos - elseif label == "SOURCE-IN" then - track_number = number - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[3] = pos - elseif label == "SOURCE-OUT" then - track_number = number - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[4] = pos - elseif string.match(label, "SOURCE PROJECT") then - source_proj = proj - proj_marker_count = proj_marker_count + 1 - elseif string.match(label, "DEST PROJECT") then - dest_proj = proj - proj_marker_count = proj_marker_count + 1 - end - end - num = num + 1 - end - - if proj_marker_count == 0 then - for _, marker in pairs(sd_markers) do - if marker.proj ~= active_proj then - marker.count = 0 - end - end - end - - local source_in = sd_markers["SOURCE-IN"].count - local source_out = sd_markers["SOURCE-OUT"].count - local dest_in = sd_markers["DEST-IN"].count - local dest_out = sd_markers["DEST-OUT"].count - - local sin = sd_markers["SOURCE-IN"].proj - local sout = sd_markers["SOURCE-OUT"].proj - local din = sd_markers["DEST-IN"].proj - local dout = sd_markers["DEST-OUT"].proj - - - local source_count = source_in + source_out - local dest_count = dest_in + dest_out - - if (source_count == 2 and sin ~= sout) or (dest_count == 2 and din ~= dout) then proj_marker_count = -1 end - - if source_proj and ((sin and sin ~= source_proj) or (sout and sout ~= source_proj)) then - proj_marker_count = -1 - end - if dest_proj and ((din and din ~= dest_proj) or (dout and dout ~= dest_proj)) then - proj_marker_count = -1 - end - - return proj_marker_count, source_proj, dest_proj, dest_in, dest_out, dest_count, - source_in, source_out, source_count, pos_table, track_number -end - ---------------------------------------------------------------------- - -function add_source_marker(pos, distance, track_number, label, num) - DeleteProjectMarker(NULL, num, false) - AddProjectMarker2(0, false, pos + distance, 0, track_number .. ":" .. label, num, ColorToNative(23, 223, 143) | 0x1000000) -end - ---------------------------------------------------------------------- - -function get_track_length(track_number) - local track = GetTrack(0, track_number) - local num_of_items = GetTrackNumMediaItems(track) - local item = GetTrackMediaItem(track, num_of_items - 1) - local item_pos = GetMediaItemInfo_Value(item, "D_POSITION") - local item_length = GetMediaItemInfo_Value(item, "D_LENGTH") - local end_of_track = item_pos + item_length - return end_of_track -end - ---------------------------------------------------------------------- - -function select_matching_folder() - local cursor = GetCursorPosition() - local marker_id, _ = GetLastMarkerAndCurRegion(0, cursor) - local _, _, _, _, label, _, _ = EnumProjectMarkers3(0, marker_id) - local folder_number = tonumber(string.match(label, "(%d*):SOURCE*")) - for i = 0, CountTracks(0) - 1, 1 do - local track = GetTrack(0, i) - if GetMediaTrackInfo_Value(track, "IP_TRACKNUMBER") == folder_number then - SetOnlyTrackSelected(track) - break - end - end -end - ---------------------------------------------------------------------- - -function copy_source() - local is_selected = true - local focus = NamedCommandLookup("_BR_FOCUS_ARRANGE_WND") - Main_OnCommand(focus, 0) -- BR_FOCUS_ARRANGE_WND - Main_OnCommand(40311, 0) -- Set ripple-all-tracks - Main_OnCommand(40289, 0) -- Item: Unselect all items - GoToMarker(0, 998, false) - select_matching_folder() - local left_overlap = check_overlapping_items() - Main_OnCommand(40625, 0) -- Time Selection: Set start point - GoToMarker(0, 999, false) - local right_overlap = check_overlapping_items() - Main_OnCommand(40626, 0) -- Time Selection: Set end point - local start_time, end_time = GetSet_LoopTimeRange2(0, false, false, 0, 0, false) - local sel_length = end_time - start_time - Main_OnCommand(40718, 0) -- Select all items on selected tracks in current time selection - local selected_items = count_selected_media_items() - if left_overlap then - local first_item = get_selected_media_item_at(0) - SetMediaItemSelected(first_item, false) - selected_items = selected_items - 1 - end - if right_overlap then - local last_item = get_selected_media_item_at(selected_items - 1) - SetMediaItemSelected(last_item, false) - selected_items = selected_items - 1 - end - if selected_items == 0 then - is_selected = false - end - Main_OnCommand(40034, 0) -- Item Grouping: Select all items in group(s) - Main_OnCommand(41383, 0) -- Edit: Copy items/tracks/envelope points (depending on focus) within time selection - Main_OnCommand(40289, 0) -- Item: Unselect all items - return sel_length, is_selected -end - ---------------------------------------------------------------------- - -function split_at_dest_in() - Main_OnCommand(40769, 0) -- unselect all items/tracks etc - Main_OnCommand(40927, 0) -- Options: Enable auto-crossfade on split - Main_OnCommand(40939, 0) -- Track: Select track 01 - GoToMarker(0, 996, false) - local select_under = NamedCommandLookup("_XENAKIOS_SELITEMSUNDEDCURSELTX") - Main_OnCommand(select_under, 0) -- Xenakios/SWS: Select items under edit cursor on selected tracks - Main_OnCommand(40034, 0) -- Item grouping: Select all items in groups - local selected_items = CountSelectedMediaItems(0) - Main_OnCommand(40912, 0) -- Options: Toggle auto-crossfade on split (OFF) - if selected_items > 0 then - Main_OnCommand(40186, 0) -- Item: Split items at edit or play cursor (ignoring grouping) - end - Main_OnCommand(40289, 0) -- Item: Unselect all items -end - ---------------------------------------------------------------------- - -function create_crossfades() - local first_sel_item, last_sel_item = get_first_last_items() - Main_OnCommand(40289, 0) -- Item: Unselect all items - SetMediaItemSelected(first_sel_item, true) - Main_OnCommand(41173, 0) -- Item navigation: Move cursor to start of items - Main_OnCommand(40034, 0) -- Item grouping: Select all items in groups - local xfade_len = return_xfade_length() - MoveEditCursor(-xfade_len, false) - Main_OnCommand(41305, 0) -- Item edit: Trim left edge of item to edit cursor - MoveEditCursor(xfade_len, false) - MoveEditCursor(-0.0001, false) - xfade(xfade_len) - Main_OnCommand(40289, 0) -- Item: Unselect all items - SetMediaItemSelected(last_sel_item, true) - Main_OnCommand(41174, 0) -- Item navigation: Move cursor to end of items - Main_OnCommand(40034, 0) -- Item grouping: Select all items in groups - Main_OnCommand(41311, 0) -- Item edit: Trim right edge of item to edit cursor - MoveEditCursor(0.001, false) - local select_under = NamedCommandLookup("_XENAKIOS_SELITEMSUNDEDCURSELTX") - Main_OnCommand(select_under, 0) - if CountSelectedMediaItems(0) == 0 then return end - MoveEditCursor(-0.001, false) - MoveEditCursor(-xfade_len, false) - Main_OnCommand(41305, 0) -- Item edit: Trim left edge of item to edit cursor - MoveEditCursor(xfade_len, false) - MoveEditCursor(-0.0001, false) - xfade(xfade_len) - Main_OnCommand(40912, 0) -- Options: Toggle auto-crossfade on split (OFF) -end - ---------------------------------------------------------------------- - -function clean_up(is_selected, proj_marker_count, source_count, source_in, source_out) - Main_OnCommand(40020, 0) -- Time Selection: Remove time selection and loop point selection - if is_selected then - local i = 0 - while true do - local project, _ = EnumProjects(i) - if project == nil then - break - end - if proj_marker_count ~= 2 then - DeleteProjectMarker(project, 996, false) - DeleteProjectMarker(project, 997, false) - DeleteProjectMarker(project, 998, false) - DeleteProjectMarker(project, 999, false) - else - if source_count == 1 then - if source_in == 0 then - DeleteProjectMarker(project, 998, false) -- Delete SOURCE-IN marker - elseif source_out == 0 then - DeleteProjectMarker(project, 999, false) -- Delete SOURCE-OUT marker - end - end - DeleteProjectMarker(project, 996, false) -- Delete DEST-IN marker - DeleteProjectMarker(project, 997, false) -- Delete DEST-OUT marker - end - - i = i + 1 - end - else - unlock_items() - MB("Please make sure there is material to copy between your source markers...", - "Source-Destination Edit", 0) - end -end - ---------------------------------------------------------------------- - -function lock_items() - local second_folder_track = find_second_folder_track() - - if second_folder_track == nil then - return - end - - local total_tracks = CountTracks(0) - - for track_idx = second_folder_track, total_tracks - 1 do - local track = GetTrack(0, track_idx) - - local num_items = CountTrackMediaItems(track) - - for item_idx = 0, num_items - 1 do - local item = GetTrackMediaItem(track, item_idx) - SetMediaItemInfo_Value(item, "C_LOCK", 1) - end - end -end - ---------------------------------------------------------------------- - -function unlock_items() - local total_items = CountMediaItems(0) - for i = 0, total_items - 1, 1 do - local item = GetMediaItem(0, i) - SetMediaItemInfo_Value(item, "C_LOCK", 0) - end -end - ---------------------------------------------------------------------- - -function ripple_lock_mode() - local _, original_ripple_lock_mode = get_config_var_string("ripplelockmode") - original_ripple_lock_mode = tonumber(original_ripple_lock_mode) - if original_ripple_lock_mode ~= 2 then - SNM_SetIntConfigVar("ripplelockmode", 2) - end -end - ---------------------------------------------------------------------- - -function return_xfade_length() - local xfade_len = 0.035 - local _, input = GetProjExtState(0, "ReaClassical S-D Editing", "Preferences") - if input ~= "" then - local table = {} - for entry in input:gmatch('([^,]+)') do table[#table + 1] = entry end - if table[1] then xfade_len = table[1] / 1000 end - end - return xfade_len -end - ---------------------------------------------------------------------- - -function xfade(xfade_len) - local select_items = NamedCommandLookup("_XENAKIOS_SELITEMSUNDEDCURSELTX") - Main_OnCommand(select_items, 0) -- Xenakios/SWS: Select items under edit cursor on selected tracks - MoveEditCursor(-xfade_len, false) - Main_OnCommand(40625, 0) -- Time selection: Set start point - MoveEditCursor(xfade_len, false) - Main_OnCommand(40626, 0) -- Time selection: Set end point - Main_OnCommand(40916, 0) -- Item: Crossfade items within time selection - Main_OnCommand(40635, 0) -- Time selection: Remove time selection - MoveEditCursor(0.001, false) - Main_OnCommand(select_items, 0) - MoveEditCursor(-0.001, false) -end - ---------------------------------------------------------------------- - -function get_first_last_items() - local num_of_items = CountSelectedMediaItems(0) - local first_sel_item - local last_sel_item - - for i = 0, num_of_items - 1 do - local item = GetSelectedMediaItem(0, i) - local track = GetMediaItem_Track(item) - local track_num = GetMediaTrackInfo_Value(track, "IP_TRACKNUMBER") - - if track_num == 1 then - if not first_sel_item then - first_sel_item = item - end - last_sel_item = item - end - end - - return first_sel_item, last_sel_item -end - ---------------------------------------------------------------------- - -function mark_as_edit() - local selected_items = CountSelectedMediaItems(0) - for i = 0, selected_items - 1, 1 do - local item = GetSelectedMediaItem(0, i) - GetSetMediaItemInfo_String(item, "P_EXT:SD", "y", 1) - end -end - ---------------------------------------------------------------------- - -function move_to_project_tab(proj_type) - SelectProjectInstance(proj_type) -end - ---------------------------------------------------------------------- - -function find_second_folder_track() - local total_tracks = CountTracks(0) - local folder_count = 0 - - for track_idx = 0, total_tracks - 1 do - local track = GetTrack(0, track_idx) - local folder_depth = GetMediaTrackInfo_Value(track, "I_FOLDERDEPTH") - - if folder_depth == 1 then - folder_count = folder_count + 1 - - if folder_count == 2 then - return track_idx - end - end - end - - return nil -end - ---------------------------------------------------------------------- - -function check_overlapping_items() - local track = GetSelectedTrack(0, 0) - if not track then - ShowMessageBox("No track selected!", "Error", 0) - return - end - - local cursor_pos = GetCursorPosition() - local num_items = CountTrackMediaItems(track) - local overlapping = false - - for i = 0, num_items - 1 do - local item1 = GetTrackMediaItem(track, i) - local start1 = GetMediaItemInfo_Value(item1, "D_POSITION") - local length1 = GetMediaItemInfo_Value(item1, "D_LENGTH") - local end1 = start1 + length1 - - if cursor_pos >= start1 and cursor_pos <= end1 then - for j = i + 1, num_items - 1 do - local item2 = GetTrackMediaItem(track, j) - local start2 = GetMediaItemInfo_Value(item2, "D_POSITION") - - if start2 < end1 and cursor_pos >= start2 then - overlapping = true - break - end - end - end - if overlapping then break end - end - - return overlapping -end - ---------------------------------------------------------------------- - -function count_selected_media_items() - local selected_count = 0 - local total_items = CountMediaItems(0) - - for i = 0, total_items - 1 do - local item = GetMediaItem(0, i) - if IsMediaItemSelected(item) then - selected_count = selected_count + 1 - end - end - - return selected_count -end - ---------------------------------------------------------------------- - -function get_selected_media_item_at(index) - local selected_count = 0 - local total_items = CountMediaItems(0) - - for i = 0, total_items - 1 do - local item = GetMediaItem(0, i) - if IsMediaItemSelected(item) then - if selected_count == index then - return item - end - selected_count = selected_count + 1 - end - end - - return nil -end - ---------------------------------------------------------------------- - -main() \ No newline at end of file diff --git a/RCEditing/RCEditing_Set Dest Project Marker.lua b/RCEditing/RCEditing_Set Dest Project Marker.lua deleted file mode 100644 index 20d17857..00000000 --- a/RCEditing/RCEditing_Set Dest Project Marker.lua +++ /dev/null @@ -1,45 +0,0 @@ ---[[ -@noindex - -This file is a part of "ReaClassical Editing" package. - -Copyright (C) 2022–2025 chmaha - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program. If not, see . -]] - --- luacheck: ignore 113 - -for key in pairs(reaper) do _G[key] = reaper[key] end - -local main - ---------------------------------------------------------------------- - -function main() - local cur_pos = (GetPlayState() == 0) and GetCursorPosition() or GetPlayPosition() - local i = 0; - while true do - local project, _ = EnumProjects(i) - if project == nil then - break - else - DeleteProjectMarker(project, 1001, false) - end - i = i + 1 - end - AddProjectMarker2(-1, false, cur_pos, 0, "DEST PROJECT", 1001, ColorToNative(183, 79, 105) | 0x1000000) -end - ---------------------------------------------------------------------- - -main() diff --git a/RCEditing/RCEditing_Set Source Project Marker.lua b/RCEditing/RCEditing_Set Source Project Marker.lua deleted file mode 100644 index 8dc5ceee..00000000 --- a/RCEditing/RCEditing_Set Source Project Marker.lua +++ /dev/null @@ -1,45 +0,0 @@ ---[[ -@noindex - -This file is a part of "ReaClassical Editing" package. - -Copyright (C) 2022–2025 chmaha - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program. If not, see . -]] - --- luacheck: ignore 113 - -for key in pairs(reaper) do _G[key] = reaper[key] end - -local main - ---------------------------------------------------------------------- - -function main() - local cur_pos = (GetPlayState() == 0) and GetCursorPosition() or GetPlayPosition() - local i = 0; - while true do - local project, _ = EnumProjects(i) - if project == nil then - break - else - DeleteProjectMarker(project, 1000, false) - end - i = i + 1 - end - AddProjectMarker2(-1, false, cur_pos, 0, "SOURCE PROJECT", 1000, ColorToNative(105, 79, 183) | 0x1000000) -end - ---------------------------------------------------------------------- - -main() diff --git a/RCEditing/RCEditing_Source Markers to Item Edge.lua b/RCEditing/RCEditing_Source Markers to Item Edge.lua deleted file mode 100644 index e699b21b..00000000 --- a/RCEditing/RCEditing_Source Markers to Item Edge.lua +++ /dev/null @@ -1,108 +0,0 @@ ---[[ -@noindex - -This file is a part of "ReaClassical Editing" package. - -Copyright (C) 2022–2025 chmaha - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program. If not, see . -]] - --- luacheck: ignore 113 - -for key in pairs(reaper) do _G[key] = reaper[key] end - -local main, folder_check, get_track_number - ---------------------------------------------------------------------- - -function main() - Undo_BeginBlock() - local left_pos, right_pos - local start_time, end_time = GetSet_LoopTimeRange(false, false, 0, 0, false) - if start_time ~= end_time then - left_pos = start_time - right_pos = end_time - else - local num = CountSelectedMediaItems(0) - if num == 0 then - MB( - "Please select one or more consecutive media items on a parent track " .. - "or make a time selection before running the function.", - "Source Markers to Item Edge or Time Selection: Error", 0) - return - end - - local first_item = GetSelectedMediaItem(0, 0) - left_pos = GetMediaItemInfo_Value(first_item, "D_POSITION") - local last_item - if num > 1 then - last_item = GetSelectedMediaItem(0, num - 1) - local start = GetMediaItemInfo_Value(last_item, "D_POSITION") - local length = GetMediaItemInfo_Value(last_item, "D_LENGTH") - right_pos = start + length - else - local length = GetMediaItemInfo_Value(first_item, "D_LENGTH") - right_pos = left_pos + length - end - end - - local i = 0 - while true do - local project, _ = EnumProjects(i) - if project == nil then - break - else - DeleteProjectMarker(project, 998, false) - DeleteProjectMarker(project, 999, false) - end - i = i + 1 - end - - local track_number = math.floor(get_track_number()) - AddProjectMarker2(0, false, left_pos, 0, track_number .. ":SOURCE-IN", 998, ColorToNative(23, 223, 143) | 0x1000000) - AddProjectMarker2(0, false, right_pos, 0, track_number .. ":SOURCE-OUT", 999, ColorToNative(23, 223, 143) | 0x1000000) - - Undo_EndBlock("Source Markers to Item Edge", 0) -end - ---------------------------------------------------------------------- - -function folder_check() - local folders = 0 - local total_tracks = CountTracks(0) - for i = 0, total_tracks - 1, 1 do - local track = GetTrack(0, i) - if GetMediaTrackInfo_Value(track, "I_FOLDERDEPTH") == 1 then - folders = folders + 1 - end - end - return folders -end - ---------------------------------------------------------------------- - -function get_track_number() - local selected = GetSelectedTrack(0, 0) - if folder_check() == 0 or selected == nil then - return 1 - elseif GetMediaTrackInfo_Value(selected, "I_FOLDERDEPTH") == 1 then - return GetMediaTrackInfo_Value(selected, "IP_TRACKNUMBER") - else - local folder = GetParentTrack(selected) - return GetMediaTrackInfo_Value(folder, "IP_TRACKNUMBER") - end -end - ---------------------------------------------------------------------- - -main() diff --git a/RCEditing/RCEditing_Zoom to Destination IN marker.lua b/RCEditing/RCEditing_Zoom to Destination IN marker.lua deleted file mode 100644 index 6ee82bb9..00000000 --- a/RCEditing/RCEditing_Zoom to Destination IN marker.lua +++ /dev/null @@ -1,158 +0,0 @@ ---[[ -@noindex - -This file is a part of "ReaClassical Editing" package. - -Copyright (C) 2022–2025 chmaha - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program. If not, see . -]] - --- luacheck: ignore 113 - -for key in pairs(reaper) do _G[key] = reaper[key] end - -local main, markers, move_to_project_tab, zoom - ---------------------------------------------------------------------- - -local SWS_exists = APIExists("CF_GetSWSVersion") -if not SWS_exists then - MB('Please install SWS/S&M extension before running this function', 'Error: Missing Extension', 0) - return -end - -function main() - local _, _, dest_proj = markers() - - if dest_proj then - move_to_project_tab(dest_proj) - end - - GoToMarker(0, 996, false) - zoom() -end - ---------------------------------------------------------------------- - -function zoom() - local cur_pos = (GetPlayState() == 0) and GetCursorPosition() or GetPlayPosition() - SetEditCurPos(cur_pos - 3, false, false) - Main_OnCommand(40625, 0) -- Time selection: Set start point - SetEditCurPos(cur_pos + 3, false, false) - Main_OnCommand(40626, 0) -- Time selection: Set end point - local zoom_to_selection = NamedCommandLookup("_SWS_ZOOMSIT") - Main_OnCommand(zoom_to_selection, 0) -- SWS: Zoom to selected items or time selection - SetEditCurPos(cur_pos, false, false) - Main_OnCommand(1012, 0) -- View: Zoom in horizontal - Main_OnCommand(40635, 0) -- Time selection: Remove (unselect) time selection -end - ---------------------------------------------------------------------- - -function markers() - local marker_labels = { "DEST-IN", "DEST-OUT", "SOURCE-IN", "SOURCE-OUT" } - local sd_markers = {} - for _, label in ipairs(marker_labels) do - sd_markers[label] = { count = 0, proj = nil } - end - - local num = 0 - local source_proj, dest_proj - local proj_marker_count = 0 - local pos_table = {} - local active_proj = EnumProjects(-1) - local track_number = 1 - while true do - local proj = EnumProjects(num) - if proj == nil then - break - end - local _, num_markers, num_regions = CountProjectMarkers(proj) - for i = 0, num_markers + num_regions - 1, 1 do - local _, _, pos, _, raw_label, _ = EnumProjectMarkers2(proj, i) - local number = string.match(raw_label, "(%d+):.+") - local label = string.match(raw_label, "%d*:?(.+)") or "" - - if label == "DEST-IN" then - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[1] = pos - elseif label == "DEST-OUT" then - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[2] = pos - elseif label == "SOURCE-IN" then - track_number = number - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[3] = pos - elseif label == "SOURCE-OUT" then - track_number = number - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[4] = pos - elseif string.match(label, "SOURCE PROJECT") then - source_proj = proj - proj_marker_count = proj_marker_count + 1 - elseif string.match(label, "DEST PROJECT") then - dest_proj = proj - proj_marker_count = proj_marker_count + 1 - end - end - num = num + 1 - end - - if proj_marker_count == 0 then - for _, marker in pairs(sd_markers) do - if marker.proj ~= active_proj then - marker.count = 0 - end - end - end - - local source_in = sd_markers["SOURCE-IN"].count - local source_out = sd_markers["SOURCE-OUT"].count - local dest_in = sd_markers["DEST-IN"].count - local dest_out = sd_markers["DEST-OUT"].count - - local sin = sd_markers["SOURCE-IN"].proj - local sout = sd_markers["SOURCE-OUT"].proj - local din = sd_markers["DEST-IN"].proj - local dout = sd_markers["DEST-OUT"].proj - - - local source_count = source_in + source_out - local dest_count = dest_in + dest_out - - if (source_count == 2 and sin ~= sout) or (dest_count == 2 and din ~= dout) then proj_marker_count = -1 end - - if source_proj and ((sin and sin ~= source_proj) or (sout and sout ~= source_proj)) then - proj_marker_count = -1 - end - if dest_proj and ((din and din ~= dest_proj) or (dout and dout ~= dest_proj)) then - proj_marker_count = -1 - end - - return proj_marker_count, source_proj, dest_proj, dest_in, dest_out, dest_count, source_in, - source_out, source_count, pos_table, track_number -end - ---------------------------------------------------------------------- - -function move_to_project_tab(proj_type) - SelectProjectInstance(proj_type) -end - ---------------------------------------------------------------------- - -main() diff --git a/RCEditing/RCEditing_Zoom to Destination OUT marker.lua b/RCEditing/RCEditing_Zoom to Destination OUT marker.lua deleted file mode 100644 index 68cf71a1..00000000 --- a/RCEditing/RCEditing_Zoom to Destination OUT marker.lua +++ /dev/null @@ -1,158 +0,0 @@ ---[[ -@noindex - -This file is a part of "ReaClassical Editing" package. - -Copyright (C) 2022–2025 chmaha - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program. If not, see . -]] - --- luacheck: ignore 113 - -for key in pairs(reaper) do _G[key] = reaper[key] end - -local main, markers, move_to_project_tab, zoom - ---------------------------------------------------------------------- - -local SWS_exists = APIExists("CF_GetSWSVersion") -if not SWS_exists then - MB('Please install SWS/S&M extension before running this function', 'Error: Missing Extension', 0) - return -end - -function main() - local _, _, dest_proj = markers() - - if dest_proj then - move_to_project_tab(dest_proj) - end - - GoToMarker(0, 997, false) - zoom() -end - ---------------------------------------------------------------------- - -function zoom() - local cur_pos = (GetPlayState() == 0) and GetCursorPosition() or GetPlayPosition() - SetEditCurPos(cur_pos - 3, false, false) - Main_OnCommand(40625, 0) -- Time selection: Set start point - SetEditCurPos(cur_pos + 3, false, false) - Main_OnCommand(40626, 0) -- Time selection: Set end point - local zoom_to_selection = NamedCommandLookup("_SWS_ZOOMSIT") - Main_OnCommand(zoom_to_selection, 0) -- SWS: Zoom to selected items or time selection - SetEditCurPos(cur_pos, false, false) - Main_OnCommand(1012, 0) -- View: Zoom in horizontal - Main_OnCommand(40635, 0) -- Time selection: Remove (unselect) time selection -end - ---------------------------------------------------------------------- - -function markers() - local marker_labels = { "DEST-IN", "DEST-OUT", "SOURCE-IN", "SOURCE-OUT" } - local sd_markers = {} - for _, label in ipairs(marker_labels) do - sd_markers[label] = { count = 0, proj = nil } - end - - local num = 0 - local source_proj, dest_proj - local proj_marker_count = 0 - local pos_table = {} - local active_proj = EnumProjects(-1) - local track_number = 1 - while true do - local proj = EnumProjects(num) - if proj == nil then - break - end - local _, num_markers, num_regions = CountProjectMarkers(proj) - for i = 0, num_markers + num_regions - 1, 1 do - local _, _, pos, _, raw_label, _ = EnumProjectMarkers2(proj, i) - local number = string.match(raw_label, "(%d+):.+") - local label = string.match(raw_label, "%d*:?(.+)") or "" - - if label == "DEST-IN" then - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[1] = pos - elseif label == "DEST-OUT" then - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[2] = pos - elseif label == "SOURCE-IN" then - track_number = number - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[3] = pos - elseif label == "SOURCE-OUT" then - track_number = number - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[4] = pos - elseif string.match(label, "SOURCE PROJECT") then - source_proj = proj - proj_marker_count = proj_marker_count + 1 - elseif string.match(label, "DEST PROJECT") then - dest_proj = proj - proj_marker_count = proj_marker_count + 1 - end - end - num = num + 1 - end - - if proj_marker_count == 0 then - for _, marker in pairs(sd_markers) do - if marker.proj ~= active_proj then - marker.count = 0 - end - end - end - - local source_in = sd_markers["SOURCE-IN"].count - local source_out = sd_markers["SOURCE-OUT"].count - local dest_in = sd_markers["DEST-IN"].count - local dest_out = sd_markers["DEST-OUT"].count - - local sin = sd_markers["SOURCE-IN"].proj - local sout = sd_markers["SOURCE-OUT"].proj - local din = sd_markers["DEST-IN"].proj - local dout = sd_markers["DEST-OUT"].proj - - - local source_count = source_in + source_out - local dest_count = dest_in + dest_out - - if (source_count == 2 and sin ~= sout) or (dest_count == 2 and din ~= dout) then proj_marker_count = -1 end - - if source_proj and ((sin and sin ~= source_proj) or (sout and sout ~= source_proj)) then - proj_marker_count = -1 - end - if dest_proj and ((din and din ~= dest_proj) or (dout and dout ~= dest_proj)) then - proj_marker_count = -1 - end - - return proj_marker_count, source_proj, dest_proj, dest_in, dest_out, dest_count, source_in, - source_out, source_count, pos_table, track_number -end - ---------------------------------------------------------------------- - -function move_to_project_tab(proj_type) - SelectProjectInstance(proj_type) -end - ---------------------------------------------------------------------- - -main() diff --git a/RCEditing/RCEditing_Zoom to Source IN marker.lua b/RCEditing/RCEditing_Zoom to Source IN marker.lua deleted file mode 100644 index 5e0d42ee..00000000 --- a/RCEditing/RCEditing_Zoom to Source IN marker.lua +++ /dev/null @@ -1,158 +0,0 @@ ---[[ -@noindex - -This file is a part of "ReaClassical Editing" package. - -Copyright (C) 2022–2025 chmaha - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program. If not, see . -]] - --- luacheck: ignore 113 - -for key in pairs(reaper) do _G[key] = reaper[key] end - -local main, markers, move_to_project_tab, zoom - ---------------------------------------------------------------------- - -local SWS_exists = APIExists("CF_GetSWSVersion") -if not SWS_exists then - MB('Please install SWS/S&M extension before running this function', 'Error: Missing Extension', 0) - return -end - -function main() - local _, source_proj = markers() - - if source_proj then - move_to_project_tab(source_proj) - end - - GoToMarker(0, 998, false) - zoom() -end - ---------------------------------------------------------------------- - -function zoom() - local cur_pos = (GetPlayState() == 0) and GetCursorPosition() or GetPlayPosition() - SetEditCurPos(cur_pos - 3, false, false) - Main_OnCommand(40625, 0) -- Time selection: Set start point - SetEditCurPos(cur_pos + 3, false, false) - Main_OnCommand(40626, 0) -- Time selection: Set end point - local zoom_to_selection = NamedCommandLookup("_SWS_ZOOMSIT") - Main_OnCommand(zoom_to_selection, 0) -- SWS: Zoom to selected items or time selection - SetEditCurPos(cur_pos, false, false) - Main_OnCommand(1012, 0) -- View: Zoom in horizontal - Main_OnCommand(40635, 0) -- Time selection: Remove (unselect) time selection -end - ---------------------------------------------------------------------- - -function markers() - local marker_labels = { "DEST-IN", "DEST-OUT", "SOURCE-IN", "SOURCE-OUT" } - local sd_markers = {} - for _, label in ipairs(marker_labels) do - sd_markers[label] = { count = 0, proj = nil } - end - - local num = 0 - local source_proj, dest_proj - local proj_marker_count = 0 - local pos_table = {} - local active_proj = EnumProjects(-1) - local track_number = 1 - while true do - local proj = EnumProjects(num) - if proj == nil then - break - end - local _, num_markers, num_regions = CountProjectMarkers(proj) - for i = 0, num_markers + num_regions - 1, 1 do - local _, _, pos, _, raw_label, _ = EnumProjectMarkers2(proj, i) - local number = string.match(raw_label, "(%d+):.+") - local label = string.match(raw_label, "%d*:?(.+)") or "" - - if label == "DEST-IN" then - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[1] = pos - elseif label == "DEST-OUT" then - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[2] = pos - elseif label == "SOURCE-IN" then - track_number = number - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[3] = pos - elseif label == "SOURCE-OUT" then - track_number = number - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[4] = pos - elseif string.match(label, "SOURCE PROJECT") then - source_proj = proj - proj_marker_count = proj_marker_count + 1 - elseif string.match(label, "DEST PROJECT") then - dest_proj = proj - proj_marker_count = proj_marker_count + 1 - end - end - num = num + 1 - end - - if proj_marker_count == 0 then - for _, marker in pairs(sd_markers) do - if marker.proj ~= active_proj then - marker.count = 0 - end - end - end - - local source_in = sd_markers["SOURCE-IN"].count - local source_out = sd_markers["SOURCE-OUT"].count - local dest_in = sd_markers["DEST-IN"].count - local dest_out = sd_markers["DEST-OUT"].count - - local sin = sd_markers["SOURCE-IN"].proj - local sout = sd_markers["SOURCE-OUT"].proj - local din = sd_markers["DEST-IN"].proj - local dout = sd_markers["DEST-OUT"].proj - - - local source_count = source_in + source_out - local dest_count = dest_in + dest_out - - if (source_count == 2 and sin ~= sout) or (dest_count == 2 and din ~= dout) then proj_marker_count = -1 end - - if source_proj and ((sin and sin ~= source_proj) or (sout and sout ~= source_proj)) then - proj_marker_count = -1 - end - if dest_proj and ((din and din ~= dest_proj) or (dout and dout ~= dest_proj)) then - proj_marker_count = -1 - end - - return proj_marker_count, source_proj, dest_proj, dest_in, dest_out, dest_count, source_in, source_out, - source_count, pos_table, track_number -end - ---------------------------------------------------------------------- - -function move_to_project_tab(proj_type) - SelectProjectInstance(proj_type) -end - ---------------------------------------------------------------------- - -main() diff --git a/RCEditing/RCEditing_Zoom to Source OUT marker.lua b/RCEditing/RCEditing_Zoom to Source OUT marker.lua deleted file mode 100644 index 85d62d6c..00000000 --- a/RCEditing/RCEditing_Zoom to Source OUT marker.lua +++ /dev/null @@ -1,158 +0,0 @@ ---[[ -@noindex - -This file is a part of "ReaClassical Editing" package. - -Copyright (C) 2022–2025 chmaha - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program. If not, see . -]] - --- luacheck: ignore 113 - -for key in pairs(reaper) do _G[key] = reaper[key] end - -local main, markers, move_to_project_tab, zoom - ---------------------------------------------------------------------- - -local SWS_exists = APIExists("CF_GetSWSVersion") -if not SWS_exists then - MB('Please install SWS/S&M extension before running this function', 'Error: Missing Extension', 0) - return -end - -function main() - local _, source_proj = markers() - - if source_proj then - move_to_project_tab(source_proj) - end - - GoToMarker(0, 999, false) - zoom() -end - ---------------------------------------------------------------------- - -function zoom() - local cur_pos = (GetPlayState() == 0) and GetCursorPosition() or GetPlayPosition() - SetEditCurPos(cur_pos - 3, false, false) - Main_OnCommand(40625, 0) -- Time selection: Set start point - SetEditCurPos(cur_pos + 3, false, false) - Main_OnCommand(40626, 0) -- Time selection: Set end point - local zoom_to_selection = NamedCommandLookup("_SWS_ZOOMSIT") - Main_OnCommand(zoom_to_selection, 0) -- SWS: Zoom to selected items or time selection - SetEditCurPos(cur_pos, false, false) - Main_OnCommand(1012, 0) -- View: Zoom in horizontal - Main_OnCommand(40635, 0) -- Time selection: Remove (unselect) time selection -end - ---------------------------------------------------------------------- - -function markers() - local marker_labels = { "DEST-IN", "DEST-OUT", "SOURCE-IN", "SOURCE-OUT" } - local sd_markers = {} - for _, label in ipairs(marker_labels) do - sd_markers[label] = { count = 0, proj = nil } - end - - local num = 0 - local source_proj, dest_proj - local proj_marker_count = 0 - local pos_table = {} - local active_proj = EnumProjects(-1) - local track_number = 1 - while true do - local proj = EnumProjects(num) - if proj == nil then - break - end - local _, num_markers, num_regions = CountProjectMarkers(proj) - for i = 0, num_markers + num_regions - 1, 1 do - local _, _, pos, _, raw_label, _ = EnumProjectMarkers2(proj, i) - local number = string.match(raw_label, "(%d+):.+") - local label = string.match(raw_label, "%d*:?(.+)") or "" - - if label == "DEST-IN" then - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[1] = pos - elseif label == "DEST-OUT" then - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[2] = pos - elseif label == "SOURCE-IN" then - track_number = number - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[3] = pos - elseif label == "SOURCE-OUT" then - track_number = number - sd_markers[label].count = 1 - sd_markers[label].proj = proj - pos_table[4] = pos - elseif string.match(label, "SOURCE PROJECT") then - source_proj = proj - proj_marker_count = proj_marker_count + 1 - elseif string.match(label, "DEST PROJECT") then - dest_proj = proj - proj_marker_count = proj_marker_count + 1 - end - end - num = num + 1 - end - - if proj_marker_count == 0 then - for _, marker in pairs(sd_markers) do - if marker.proj ~= active_proj then - marker.count = 0 - end - end - end - - local source_in = sd_markers["SOURCE-IN"].count - local source_out = sd_markers["SOURCE-OUT"].count - local dest_in = sd_markers["DEST-IN"].count - local dest_out = sd_markers["DEST-OUT"].count - - local sin = sd_markers["SOURCE-IN"].proj - local sout = sd_markers["SOURCE-OUT"].proj - local din = sd_markers["DEST-IN"].proj - local dout = sd_markers["DEST-OUT"].proj - - - local source_count = source_in + source_out - local dest_count = dest_in + dest_out - - if (source_count == 2 and sin ~= sout) or (dest_count == 2 and din ~= dout) then proj_marker_count = -1 end - - if source_proj and ((sin and sin ~= source_proj) or (sout and sout ~= source_proj)) then - proj_marker_count = -1 - end - if dest_proj and ((din and din ~= dest_proj) or (dout and dout ~= dest_proj)) then - proj_marker_count = -1 - end - - return proj_marker_count, source_proj, dest_proj, dest_in, dest_out, dest_count, - source_in, source_out, source_count, pos_table, track_number -end - ---------------------------------------------------------------------- - -function move_to_project_tab(proj_type) - SelectProjectInstance(proj_type) -end - ---------------------------------------------------------------------- - -main()