-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateRegionsFromMarkers.lua
More file actions
30 lines (25 loc) · 982 Bytes
/
Copy pathcreateRegionsFromMarkers.lua
File metadata and controls
30 lines (25 loc) · 982 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
function CreateRegionsFromMarkers()
local retval, num_markers, num_regions = reaper.CountProjectMarkers(0)
local total_markers = num_markers + num_regions
local markers = {}
for i = 0, total_markers - 1 do
local retval, isrgn, pos, rgnend, name, markrgnindexnumber = reaper.EnumProjectMarkers(i)
if not isrgn then
table.insert(markers, {pos = pos, name = name, index = markrgnindexnumber})
end
end
for i = 1, #markers - 1 do
local start_pos = markers[i].pos
local end_pos = markers[i + 1].pos
local name = markers[i].name
reaper.AddProjectMarker2(0, true, start_pos, end_pos, name, -1, 0)
end
for i = #markers, 1, -1 do
local index = markers[i].index
reaper.DeleteProjectMarker(0, index, false)
end
reaper.Undo_EndBlock("Create regions from markers and remove markers", -1)
end
reaper.Undo_BeginBlock()
CreateRegionsFromMarkers()
reaper.UpdateArrange()