Compare commits
No commits in common. "a5072fc596bd4b05b2959e314f02dda1040573ae" and "6438d7c8da49454a3464c64f9f91f8bda23580e6" have entirely different histories.
a5072fc596
...
6438d7c8da
@ -5,7 +5,7 @@
|
|||||||
-- Git: https://files.eleton-audio.de/gitea/Ludwig/Reaper-Scripts.git
|
-- Git: https://files.eleton-audio.de/gitea/Ludwig/Reaper-Scripts.git
|
||||||
-- License: GPL v3.0
|
-- License: GPL v3.0
|
||||||
-- Requires: Reaper 5 or 6
|
-- Requires: Reaper 5 or 6
|
||||||
-- Requires: SWS extensions. http://standingwaterstudios.com
|
-- Requires: SWS extensions, if not present no crossfades are created. http://standingwaterstudios.com
|
||||||
-- Requires: This script goes with several other scripts that work closely together.
|
-- Requires: This script goes with several other scripts that work closely together.
|
||||||
|
|
||||||
local stored_cursorPos = 0
|
local stored_cursorPos = 0
|
||||||
@ -23,7 +23,6 @@ local mark_dstin_pos = -1
|
|||||||
local mark_dstin_id = -1
|
local mark_dstin_id = -1
|
||||||
local mark_dstout_pos = -1
|
local mark_dstout_pos = -1
|
||||||
local mark_dstout_id = -1
|
local mark_dstout_id = -1
|
||||||
local dst_track_offset = 0 -- if the uppermost item is not on the first sourcetrack, this offset needs to be applied to the dst-track selection
|
|
||||||
local edit_mode = 0
|
local edit_mode = 0
|
||||||
local sws_present = false
|
local sws_present = false
|
||||||
-- edit modes: 0=not enough markers set; 1=src-in, src-out, dst-in; 2=src-in, src-out, dst-out;
|
-- edit modes: 0=not enough markers set; 1=src-in, src-out, dst-in; 2=src-in, src-out, dst-out;
|
||||||
@ -40,35 +39,6 @@ function round(num, numDecimalPlaces)
|
|||||||
return math.floor(num * mult + 0.5) / mult
|
return math.floor(num * mult + 0.5) / mult
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Calculate offset between first source track and uppermost source item (how many
|
|
||||||
-- tracks are empty in source selection on top). This needs to be applied to destination
|
|
||||||
-- track selection, otherwise the items will be pasted shifted upwards.
|
|
||||||
-- This function depends on the source tracks AND items to be already selected,
|
|
||||||
-- it does not care about any markers or stored sourcetracks!
|
|
||||||
function calculate_track_offset()
|
|
||||||
local first_sel_track = 9999
|
|
||||||
local uppermost_item_track = 9999
|
|
||||||
|
|
||||||
-- get number of first selected track
|
|
||||||
for i = 0, reaper.CountSelectedTracks(0)-1 do
|
|
||||||
local nof_track = reaper.GetMediaTrackInfo_Value(reaper.GetSelectedTrack(0, i), "IP_TRACKNUMBER")
|
|
||||||
if nof_track < first_sel_track then
|
|
||||||
first_sel_track = nof_track
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- get tracknumber of first selected item
|
|
||||||
for i = 0, reaper.CountSelectedMediaItems(0)-1 do
|
|
||||||
local trackno_item = reaper.GetMediaTrackInfo_Value(reaper.GetMediaItemTrack(reaper.GetSelectedMediaItem(0, i)), "IP_TRACKNUMBER")
|
|
||||||
if trackno_item < uppermost_item_track then
|
|
||||||
uppermost_item_track = trackno_item
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- calculate offset
|
|
||||||
dst_track_offset = uppermost_item_track - first_sel_track
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Selects the source tracks, or, if not stored in rpp, selects all tracks
|
-- Selects the source tracks, or, if not stored in rpp, selects all tracks
|
||||||
function select_src_tracks()
|
function select_src_tracks()
|
||||||
local tracks_str = ''
|
local tracks_str = ''
|
||||||
@ -94,36 +64,15 @@ function select_src_tracks()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Select the destination tracks, or, if not stored in rpp, the first track
|
-- Select the destination tracks, or, if not stored in rpp, the first track
|
||||||
-- Also a offset must be specified which will be applied to the tracknumber to select
|
|
||||||
function select_dst_track_only()
|
function select_dst_track_only()
|
||||||
local track_str = ''
|
local track_str = ''
|
||||||
local retval
|
local retval
|
||||||
local raw_dst_track
|
|
||||||
|
|
||||||
-- Get "raw" track, without offset
|
|
||||||
retval, track_str = reaper.GetProjExtState(0, '4PointCut', 'dst_track')
|
retval, track_str = reaper.GetProjExtState(0, '4PointCut', 'dst_track')
|
||||||
if retval > 0 then -- variable exists in rpp
|
if retval > 0 then -- variable exists in rpp
|
||||||
raw_dst_track = reaper.BR_GetMediaTrackByGUID(0, track_str)
|
reaper.SetOnlyTrackSelected(reaper.BR_GetMediaTrackByGUID(0, track_str))
|
||||||
else --default to first track
|
else --default to first track
|
||||||
raw_dst_track = reaper.GetTrack(0, 0)
|
reaper.SetOnlyTrackSelected(reaper.GetTrack(0, 0))
|
||||||
end
|
end
|
||||||
|
|
||||||
if dst_track_offset <= 0 then
|
|
||||||
-- no offset to respect, easy
|
|
||||||
reaper.SetOnlyTrackSelected(raw_dst_track)
|
|
||||||
else
|
|
||||||
local trackno_dst_track = reaper.GetMediaTrackInfo_Value(raw_dst_track, "IP_TRACKNUMBER") + dst_track_offset
|
|
||||||
-- Run trough all tracks, select the one with the matching tracknumber and return
|
|
||||||
for i = 0, reaper.CountTracks(0)-1 do
|
|
||||||
local nof_track = reaper.GetMediaTrackInfo_Value(reaper.GetTrack(0, i), "IP_TRACKNUMBER")
|
|
||||||
if nof_track == trackno_dst_track then
|
|
||||||
reaper.SetOnlyTrackSelected(reaper.GetTrack(0, i))
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
-- In theory should never be reached, use raw track as fallback, probably something is wrong with the offset:
|
|
||||||
reaper.SetOnlyTrackSelected(raw_dst_track)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- START HERE vvvvvvvvvvvvvvvvvvvvvvvvvv
|
-- START HERE vvvvvvvvvvvvvvvvvvvvvvvvvv
|
||||||
@ -227,18 +176,12 @@ end
|
|||||||
reaper.Main_OnCommand(40718, 0) -- select items on selected tracks under time selection
|
reaper.Main_OnCommand(40718, 0) -- select items on selected tracks under time selection
|
||||||
reaper.Main_OnCommand(40060, 0) -- copy selected items under time selection 41383
|
reaper.Main_OnCommand(40060, 0) -- copy selected items under time selection 41383
|
||||||
|
|
||||||
-- Calculate track offset between first selected item and first dst-track
|
|
||||||
calculate_track_offset()
|
|
||||||
|
|
||||||
-- Move edit cursor to Dest-In and Paste
|
-- Move edit cursor to Dest-In and Paste
|
||||||
reaper.GoToMarker(0, mark_dstin_id, false)
|
reaper.GoToMarker(0, mark_dstin_id, false)
|
||||||
select_dst_track_only()
|
select_dst_track_only()
|
||||||
--reaper.Main_OnCommand(40058, 0) -- paste item
|
--reaper.Main_OnCommand(40058, 0) -- paste item
|
||||||
reaper.Main_OnCommand( reaper.NamedCommandLookup('_SWS_AWPASTE'), 0 ) -- SWS Paste
|
reaper.Main_OnCommand( reaper.NamedCommandLookup('_SWS_AWPASTE'), 0 ) -- SWS Paste
|
||||||
|
|
||||||
-- Remove content behind selected items (avoid overlapping). Only really needed if "Trim content behind media items when editing" is off.
|
|
||||||
reaper.Main_OnCommand( 40930, 0 ) -- Remove content (trim) behind items
|
|
||||||
|
|
||||||
-- Crossfade
|
-- Crossfade
|
||||||
local selected_items_count = reaper.CountSelectedMediaItems(0)
|
local selected_items_count = reaper.CountSelectedMediaItems(0)
|
||||||
for i = 0, selected_items_count - 1 do -- select tracks with selected items...
|
for i = 0, selected_items_count - 1 do -- select tracks with selected items...
|
||||||
|
Loading…
x
Reference in New Issue
Block a user