Quote:
Originally Posted by Sexan
Maybe today I'm genuinely stupid but... are you sure about
Code:
env_t = env_t + tr_t
?
because for the first track which has I_TCPY of 0, adding that to envelope adds nothing?
Nothing changed it still offseted
|
Yes. Having said that, you can't pass the mouse screen coordinates in, it must be arrange-view coordinates. and to get that (for now) you probably need to use an extension-provided API (going to add a general coordinate conversion API)...
e.g.:
Code:
local function GetTrackEnvFromMouse(x, y)
local tr, info = reaper.GetTrackFromPoint(x, y)
if tr and info == 1 then
local wnd = reaper.BR_Win32_FindWindowEx(
reaper.BR_Win32_HwndToString(reaper.BR_Win32_GetMainHwnd()),0,
"REAPERTrackListWindow","",true,false)
x,y = reaper.BR_Win32_ScreenToClient(wnd,x,y)
local tr_t = reaper.GetMediaTrackInfo_Value(tr, "I_TCPY" )
for i = 1 , reaper.CountTrackEnvelopes(tr) do
local env = reaper.GetTrackEnvelope(tr, i-1)
local env_t = reaper.GetEnvelopeInfo_Value(env,"I_TCPY") + tr_t
local env_h = reaper.GetEnvelopeInfo_Value(env,"I_TCPH")
if y >= env_t and y < env_t + env_h then
return tr, env
end
end
end
return tr, nil
end
function run()
track,env = GetTrackEnvFromMouse(reaper.GetMousePosition())
reaper.defer(run);
if env ~= nil then
_,name = reaper.GetEnvelopeName(env)
else
name = ""
end
end
run()