Skip to content

Commit

Permalink
Use more robust way of operating on last recorded item
Browse files Browse the repository at this point in the history
  • Loading branch information
chmaha committed Dec 13, 2024
1 parent 3339109 commit b671ec6
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 23 deletions.
6 changes: 6 additions & 0 deletions ReaClassical/ReaClassical_Classical Take Record.lua
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ function main()
end
end

--group last recorded items
Main_OnCommand(40032, 0)
--save recorded item guid
local recorded_item = GetSelectedMediaItem(0,0)
local recorded_item_guid = BR_GetMediaItemGUID(recorded_item)
SetProjExtState(0, "ReaClassical", "LastRecordedItem", recorded_item_guid)
Main_OnCommand(40289, 0) -- Unselect all items

if workflow == "Vertical" then
Expand Down
15 changes: 8 additions & 7 deletions ReaClassical/ReaClassical_Rank Higher.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function modify_item_name(item)
return colors.rank_good
end,
[0] = function()
return 0 -- Default color
return 0 -- Default color
end,
[-1] = function()
return colors.rank_below_average
Expand Down Expand Up @@ -116,12 +116,13 @@ function process_items()
modify_item_name(item)
end
else
local track = GetTrack(0, 0)
if track then
local item_count = CountTrackMediaItems(track)
if item_count > 0 then
local last_item = GetTrackMediaItem(track, item_count - 1)
modify_item_name(last_item)
local _, recorded_item_guid = GetProjExtState(0, "ReaClassical", "LastRecordedItem")
if recorded_item_guid ~= "" then
local recorded_item = BR_GetMediaItemByGUID(0, recorded_item_guid)
if recorded_item then
modify_item_name(recorded_item)
else
MB("The previously recorded item no longer exists.", "ReaClassical Take Ranking", 0)
end
end
end
Expand Down
13 changes: 7 additions & 6 deletions ReaClassical/ReaClassical_Rank Lower.lua
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,13 @@ function process_items()
modify_item_name(item)
end
else
local track = GetTrack(0, 0)
if track then
local item_count = CountTrackMediaItems(track)
if item_count > 0 then
local last_item = GetTrackMediaItem(track, item_count - 1)
modify_item_name(last_item)
local _, recorded_item_guid = GetProjExtState(0, "ReaClassical", "LastRecordedItem")
if recorded_item_guid ~= "" then
local recorded_item = BR_GetMediaItemByGUID(0, recorded_item_guid)
if recorded_item then
modify_item_name(recorded_item)
else
MB("The previously recorded item no longer exists.", "ReaClassical Take Ranking", 0)
end
end
end
Expand Down
14 changes: 7 additions & 7 deletions ReaClassical/ReaClassical_Remove Ranking.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ function process_items()
modify_item_name(item)
end
else
-- No items selected, process the last item on track 1
local track = reaper.GetTrack(0, 0) -- Get track 1
if track then
local item_count = reaper.CountTrackMediaItems(track)
if item_count > 0 then
local last_item = reaper.GetTrackMediaItem(track, item_count - 1)
modify_item_name(last_item)
local _, recorded_item_guid = GetProjExtState(0, "ReaClassical", "LastRecordedItem")
if recorded_item_guid ~= "" then
local recorded_item = BR_GetMediaItemByGUID(0, recorded_item_guid)
if recorded_item then
modify_item_name(recorded_item)
else
MB("The previously recorded item no longer exists.", "ReaClassical Take Ranking", 0)
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions ReaClassical/ReaClassical_Take Counter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ local start_time, end_time, duration
local run_once = false

local F9_command = NamedCommandLookup("_RS25887d941a72868731ba67ccb1abcbacb587e006")
local auto_group = NamedCommandLookup("_SWS_AWAUTOGROUPTOG")
local auto_group_state = GetToggleCommandState(auto_group)
if auto_group_state ~= 1 then Main_OnCommand(auto_group, 0) end
-- local auto_group = NamedCommandLookup("_SWS_AWAUTOGROUPTOG")
-- local auto_group_state = GetToggleCommandState(auto_group)
-- if auto_group_state ~= 1 then Main_OnCommand(auto_group, 0) end


---------------------------------------------------------------------
Expand Down

0 comments on commit b671ec6

Please sign in to comment.