function Msg(value)
reaper.ShowConsoleMsg(tostring(value).."\n")
end
os_type = reaper.GetOS() -- "Mac OSX" -- "Win64" --
sel_track = reaper.GetSelectedTrack2( 0, 0, 0 )
sel_track_count = reaper.CountSelectedTracks(0)
if not sel_track then
reaper.MB("Select Track", "Notice",0)
goto finish_tm
end
if sel_track_count ~= 1 then
reaper.MB("Select 1 Track", "Notice",0)
goto finish_tm
end
reaper.Undo_BeginBlock() -- Begining of the undo block. Leave it at the top of your main function.
reaper.Main_OnCommand(40289,0) -- Item: Unselect (clear selection of) all items
reaper.Main_OnCommand(40421,0) -- Item: Select all items in track
for i=0, reaper.CountSelectedMediaItems(0)-1 do
media_item = reaper.GetSelectedMediaItem(0, i)
take = reaper.GetMediaItemTake(media_item, 0)
source = reaper.GetMediaSourceFileName(reaper.GetMediaItemTake_Source(take), "")
startOffset = reaper.GetMediaItemTakeInfo_Value(take, "D_STARTOFFS")
--Msg("source "..source)
if string.find(source,"Drums") or string.find(source,"DRUMS")then
drums = 1
else
drums = 0
end
--Msg("drums "..drums)
if source then
if os_type ~= "Win32" and os_type ~= "Win64" then
--Mac OS
RT_track_name = string.match(source, "RealTracks/(.+)/")
if string.find(source,"Drums") then
RD_track_name = string.match(source, "Drums/(.+)/")
end
if string.find(source,"DRUMS")then
RD_track_name = string.match(source, "DRUMS/(.+)/")
end
else
--Win OS
RT_track_name = string.match(source, "RealTracks\\(.+)\\")
if string.find(source,"Drums") then
RD_track_name = string.match(source, "Drums\\(.+)\\")
end
if string.find(source,"DRUMS") then
RD_track_name = string.match(source, "DRUMS\\(.+)\\")
end
end
end
if drums == 0 then
track_name = RT_track_name
else
track_name = RD_track_name
end
--Msg("track_name "..track_name)
reaper.SetTakeMarker( take, 0, track_name, startOffset, reaper.ColorToNative(80, 237, 123 )|0x1000000)
end
reaper.Main_OnCommand(40289,0) -- Item: Unselect (clear selection of) all items
reaper.UpdateArrange() -- Update the arrangement (often needed)
reaper.Undo_EndBlock("Write take markers to track items", -1) -- End of the undo block. Leave it at the bottom of your main function.
::finish_tm::