После рендеров несложно было сделать и этот скрипт, т.к. алгоритм посылов у меня уже был.
Итак, скрипт создает сенды на новый сенд трек с параметрами, если ввести имя сенд трека, которого нет в проекте.
Если ввести имя сенд трека, который уже есть, то посыл будет создаваться соответственно к существующему сенд треку
В шапке скрипта можно ввести некоторые свои параметры.
Вроде и все. Для мастер сенда пишем 0 или 1 (0 нет, 1 да). Если найдете ошибки, пишите, поправлю.
Итак, скрипт создает сенды на новый сенд трек с параметрами, если ввести имя сенд трека, которого нет в проекте.
Если ввести имя сенд трека, который уже есть, то посыл будет создаваться соответственно к существующему сенд треку
В шапке скрипта можно ввести некоторые свои параметры.
Вроде и все. Для мастер сенда пишем 0 или 1 (0 нет, 1 да). Если найдете ошибки, пишите, поправлю.
JavaScript:
--///////----USER--INPUTS----\\\\\\\\\----CUSTOMIZE--THIS----////////////////////
----User input default values-------------------------------------------------
send_track_name = 'BUS' ---- "Set the send track name"
source_send = '1/2' ---- "Set source send (x or x/y)"
destination_send = '1/2' ---- "Set destination send (x or x/y)"
master_send = '0' ---- "Master send on source tracks"
send_mode = '0' ---- "Post-fd (0) pre-fx (1) post-fx (3)"
------------------------------------------------------------------------------
----Color for new send track, if no existed-----------------------------------
R = 40 ---- Red
G = 40 ---- Green
B = 40 ---- Blue
------------------------------------------------------------------------------
----Other parameters for new send track, if no existed------------------------
height_size = 45 ---- Height size in TCP
height_lock = true ---- Lock height track in TCP --- true or false
show_in_TCP = true ---- Show or hide track in TCP --- true or false
end_of_track_list = false ---- Insert at end of track list --- true of false
------------------------------------------------------------------------------
--\\\\\\----RUN--RUN--RUN----/////////----START--SCRIPT------\\\\\\\\\\\\\\\\\\\\
function bla() end function nothing() reaper.defer(bla) end
count_sel_tracks = reaper.CountSelectedTracks(0)
if count_sel_tracks == 0 then reaper.MB('No tracks. Please select a track', 'Error', 0) nothing() return end
local test_SWS = reaper.NF_GetMediaItemPeakRMS_Windowed --function added in 2.9.7 SWS
if not test_SWS then
reaper.MB('Please install or update SWS extension', 'Error', 0) nothing() return
end
if (height_lock ~= true and height_lock ~= false)
or (show_in_TCP ~= true and show_in_TCP ~= false)
or (end_of_track_list ~= true and end_of_track_list ~= false) then
reaper.MB('Incorrect values for "height lock" or "show in TCP" or "end_of_track_list" parameters. Please enter "true" or "false"',
'Error',0)
nothing() return
end
function bool_for_settings(bl)
if bl == true then
bl = 1
elseif bl == false then
bl = 0
end
return bl
end
height_lock = bool_for_settings(height_lock)
show_in_TCP = bool_for_settings(show_in_TCP)
local values_for_script = send_track_name
..","..source_send
..","..destination_send
..","..master_send
..","..send_mode
::START::
local retval, retvals_csv = reaper.GetUserInputs('Create sends to track from sel. tracks', 5,
'Set the send track name:,Set source send (x or x/y):,Set destination send (x or x/y):,Master send on source tracks:,Post-fd (0) pre-fx (1) post-fx (3):',
values_for_script)
if retval then
reaper.Undo_BeginBlock()
reaper.PreventUIRefresh(1)
local t_val = {}
for s in string.gmatch(retvals_csv, "[^,]+") do
table.insert(t_val,s)
end
if #t_val ~= 5 then
reaper.MB('Incorrect value or no value. Please enter a valid value for any line','Error',0) goto START
end
local val_name, val_src_send, val_dst_send, val_main_send, val_mode =
retvals_csv:match("([^,]+),([^,]+),([^,]+),([^,]+),([^,]+)")
val_main_send = tonumber(val_main_send)
val_mode = tonumber(val_mode)
if (not val_main_send or (val_main_send ~= 1 and val_main_send ~= 0))
or (not val_mode or (val_mode ~= 0 and val_mode ~= 1 and val_mode ~= 2 and val_mode ~= 3)) then
reaper.MB('Incorrect value. Please enter a valid value for master send or send mode','Error',0)
goto START
end
function Round_To_Integer(x, n)
n = n or 1
return math.floor(x / n + 0.5) * n
end
function Round_To_Even(number_round)
if (number_round % 2 ~= 0) then
number_round = number_round+1
end
return number_round
end
function convert_string_to_send_number_or_channels(value)
if value == tostring(value) then
local t_string = {}
local bool_num = true
for num in string.gmatch(value, "([^/]+)") do
if not tonumber(num) then
bool_num = false
end
table.insert(t_string, num)
end
if bool_num == true then
local def_num = Round_To_Integer(tonumber(t_string[1]),1)
if value == def_num .. '/' .. def_num+1
and (def_num > 0 and def_num < 64) and def_num == tonumber(t_string[1]) then
value = def_num-1
elseif value == t_string[1]
and (def_num > 0 and def_num <= 64) and def_num == tonumber(t_string[1]) then
value = def_num+1023
else
value = false
end
elseif bool_num == false then
value = false
end
elseif value == tonumber(value) then
if value < 1024 then
value = Round_To_Even(value+2)
else
value = Round_To_Even(value-1023)
end
end
return value
end
val_src_send = convert_string_to_send_number_or_channels(val_src_send)
val_dst_send = convert_string_to_send_number_or_channels(val_dst_send)
if val_src_send == false or val_dst_send == false then
reaper.MB('Incorrect value. Please enter a valid value for source or destination sends','Error',0) goto START
end
local found_tr = false
for i=1, reaper.CountTracks(0) do
local get_tr = reaper.GetTrack(0,i-1)
retval, buf = reaper.GetTrackName(get_tr)
if buf == val_name then
save_tr = get_tr
found_tr = true
break
end
end
if found_tr == true then
if reaper.IsTrackSelected(save_tr) == true then
reaper.MB('The send track has already been selected, take a closer look :)','Error',0)
nothing() return
end
elseif found_tr == false then
if end_of_track_list == false then
reaper.InsertTrackAtIndex(0,false)
save_tr = reaper.GetTrack(0,0)
elseif end_of_track_list == true then
reaper.InsertTrackAtIndex(reaper.CountTracks(0),false)
save_tr = reaper.GetTrack(0,reaper.CountTracks(0)-1)
end
color = reaper.ColorToNative(R,G,B)|0x1000000
reaper.SetTrackColor(save_tr,color)
reaper.GetSetMediaTrackInfo_String(save_tr, 'P_NAME', val_name, true)
reaper.SetMediaTrackInfo_Value(save_tr, 'I_HEIGHTOVERRIDE', height_size)
reaper.SetMediaTrackInfo_Value(save_tr, 'B_HEIGHTLOCK', height_lock)
reaper.SetMediaTrackInfo_Value(save_tr, 'B_SHOWINTCP', show_in_TCP)
end
if reaper.GetMediaTrackInfo_Value(save_tr, "I_NCHAN") < convert_string_to_send_number_or_channels(val_dst_send) then
reaper.SetMediaTrackInfo_Value(save_tr, "I_NCHAN", convert_string_to_send_number_or_channels(val_dst_send))
end
local count_s = {}
local count_unit = 0
for i=0, count_sel_tracks-1 do
local track_get = reaper.GetSelectedTrack(0,i)
reaper.CreateTrackSend(track_get, save_tr)
for j=0, reaper.GetTrackNumSends(track_get,0)-1 do
local send_t = reaper.BR_GetMediaTrackSendInfo_Track(track_get, 0, j, 1)
if send_t == save_tr then
count_unit = count_unit + 1
end
end
count_s[i+1] = count_unit
count_unit = 0
end
local cycle_cnt = 0
for i=0, count_sel_tracks-1 do
local get_track = reaper.GetSelectedTrack(0,i)
reaper.SetMediaTrackInfo_Value(get_track, 'B_MAINSEND', val_main_send)
if reaper.GetMediaTrackInfo_Value(get_track, "I_NCHAN") < convert_string_to_send_number_or_channels(val_src_send) then
reaper.SetMediaTrackInfo_Value(get_track, "I_NCHAN", convert_string_to_send_number_or_channels(val_src_send))
end
for j=0, reaper.GetTrackNumSends(get_track,0)-1 do
local send_track = reaper.BR_GetMediaTrackSendInfo_Track(get_track, 0, j, 1)
if send_track == save_tr then
cycle_cnt = cycle_cnt + 1
if cycle_cnt == count_s[i+1] then
reaper.SetTrackSendInfo_Value( get_track, 0, j, 'I_SRCCHAN', val_src_send)
reaper.SetTrackSendInfo_Value( get_track, 0, j, 'I_DSTCHAN', val_dst_send)
reaper.SetTrackSendInfo_Value( get_track, 0, j, 'I_SENDMODE', val_mode)
reaper.BR_GetSetTrackSendInfo( get_track, 0, j, 'I_MIDI_SRCCHAN', true, -1)
end
end
end
cycle_cnt = 0
end
reaper.Undo_EndBlock('Create send track with sends parameters from selected tracks',-1)
reaper.PreventUIRefresh(-1)
else nothing() return end
Вложения
Последнее редактирование: