the behavior should be pretty much identical to the above described protools function.
here's the action:
and here's the first script listed in it: Relocate_Time_Selection_To_Cursor.lua (thanks to Edgemeal):
Code:
-- move time selection to cursor by Edgemeal 20191008
function Main()
local start_time, end_time = reaper.GetSet_LoopTimeRange(false, false, 0, 0, false)
if start_time == end_time then return end
local length = end_time-start_time
local cursor = reaper.GetCursorPosition()
reaper.GetSet_LoopTimeRange(true, false, cursor, cursor+length, false)
end
Main()
reaper.defer(function () end)
and the other: AUDIOBOOKS____Select_item_on_selected_track_by_ite m_name____RoomTone_35secs.wav.lua (thanks to Archie and everybody at ReaPack):
Code:
--[[
* Category: Item
* Description: Select item on selected track by item name (hard-coded)
* Oписание: Выбрать первый элемент от позиции курсора в первом выбранном треке
* GIF: http://goo.gl/9rRSpp
* Website: http://forum.cockos.com/showthread.php?t=212819
* Donation: http://money.yandex.ru/to/410018003906628
* Author: Archie
* Version: 1.0
* customer: ---
* gave idea: HDVulcan(RMM Forum)
--==========================================]]
--===========================================================================
--////////////////////////////// SCRIPT \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
--===========================================================================
-----------------------------------------------------------------------------
local function No_Undo()end; local function no_undo()reaper.defer(No_Undo)end
-----------------------------------------------------------------------------
local SelTrack = reaper.GetSelectedTrack( 0, 0 )
if not SelTrack then no_undo() return end
local CountTrItem = reaper.CountTrackMediaItems( SelTrack )
if CountTrItem > 0 then
local Name = "RoomTone_35secs.wav"
for i = 1,CountTrItem do
local Tr_item = reaper.GetTrackMediaItem( SelTrack, i-1 )
local Take = reaper.GetActiveTake( Tr_item )
if Take ~= nil then
local Take_Name = reaper.GetTakeName( Take )
if Take_Name == Name then
reaper.SelectAllMediaItems( 0, 0 )
reaper.SetMediaItemSelected( Tr_item, 1 )
undo = 1
break
end
end
end
end
if undo == 1 then
reaper.Undo_BeginBlock()
reaper.Undo_EndBlock( [[Select first item from cursor
position in first selected track]],-1)
else
no_undo()
end
reaper.UpdateArrange()
how it works:
i work with a template project of 4 tracks.
track 1 is content
track 2 is spare
track 3 is room tone that i pre-split into specific lengths
track 4 is the full room tone file (35 sec.)
if they don't give me a full 35 sec. of room tone, i make my own from what i do get.
i have both a toolbar and second keyboard that i use to trigger the custom actions. i also have a time display at the top of my tcp screen that shows me the duration of my time selection. much of the time i just paste one of my preset lengths of room tone, whichever length is closest to the selected length. the other option is to match the selected length exactly.
for the purposes of this discussion, it's the latter setup that's of interest. running the posted custom action in this template should:
store the current time selection and cursor position,
go to track 4 and select the 35 sec room tone item.
relocate the time selection to near the beginning of said room tone item,
grab a chunk of tone matching the selected length
paste it back into track 1 while returning the original cursor position and time selection
if you try to use these, know that the second script has the take name (RoomTone_35secs.wav) hard coded into it. you'll either want to name your room tone to that or amend the script.
no buffer. on my system it works plenty fast. it's a really simple template.
hth,
babag