View Single Post
Old 05-13-2019, 04:10 AM   #470
Breeder
Human being with feelings
 
Breeder's Avatar
 
Join Date: Nov 2010
Location: Croatia
Posts: 2,225
Default

I'm trying to set tempo envelope display range via .lua script but I can't seem to make REAPER redraw the envelope with the new values.

Code:
local tempoenvmin = reaper.SNM_GetIntConfigVar("tempoenvmin", -222)
local tempoenvmax = reaper.SNM_GetIntConfigVar("tempoenvmax", -222)

local button, value = reaper.GetUserInputs("Set tempo map display range", 2, "Min:,Max:", tempoenvmin .. "," .. tempoenvmax)
if button == true then
	local min, max = value:match'(.*),(.*)'
	min, max = math.floor(tonumber(min)), math.floor(tonumber(max))
	if min > max then local tmp = min; min = max; max = tmp; end
	if min <= 0 then min = tempoenvmin end

	reaper.PreventUIRefresh(1)
	reaper.SNM_SetIntConfigVar("tempoenvmin", min)
	reaper.SNM_SetIntConfigVar("tempoenvmax", max)
	reaper.PreventUIRefresh(-1)

	reaper.UpdateArrange()
	reaper.UpdateTimeline()
	reaper.TrackList_AdjustWindows(false)
end
Update API doesn't seem to work and so doesn't the show/hide tempo envelope action run after the script.

Anyone got any idea on how to do this?
Breeder is offline   Reply With Quote