Something got broken with envelope track Y calculation in the process of 5.9 - 6. Fund this by accident because I've installed latest V6 (was on 5.9)
New CORE TCP behavior was introduced in dev 5.9 (I made the port then) and there everything is fine, but on V6 something got offseted:
V5.9 - tracking envelope is fine
v.6 latest stable and tested with this RC
It does not detect envelopes when OVER envelopes but in the portion of track?
My script has 0 changes, but on V6 envelope operations are broken.
The code just tracks whats under the mouse, nothing special and it detects envelopes in lower part of the track.
Not sure why this is only happening when drawing ghosts, but I can actually draw on envelopes (it detects them).
Code:
local function GetTracksFromMouse(x, y)
local track, env_info = reaper.GetTrackFromPoint(x, y)
if track == reaper.GetMasterTrack( 0 ) and reaper.GetMasterTrackVisibility() == 0 then return end -- IGNORE DOCKED MASTER TRACK
if track and env_info == 0 then
return track, TBH[track].t, TBH[track].b, TBH[track].h
elseif track and env_info == 1 then
for i = 1, reaper.CountTrackEnvelopes(track) do
local env = reaper.GetTrackEnvelope(track, i - 1)
if TBH[env].t <= y and TBH[env].b >= y then
return env, TBH[env].t, TBH[env].b, TBH[env].h
end
end
end
end
and it returns track from this array
Code:
local TBH
function GetTracksXYH()
TBH = {}
local _, x_view_start, y_view_start, x_view_end, y_view_end = reaper.JS_Window_GetRect(track_window)
-- ONLY ADD MASTER TRACK IF VISIBLE IN TCP
local master_tr_visibility = reaper.GetMasterTrackVisibility()
if master_tr_visibility == 1 or master_tr_visibility == 3 then
local master_tr = reaper.GetMasterTrack(0)
local m_tr_h = reaper.GetMediaTrackInfo_Value(master_tr, "I_TCPH")
local m_tr_t = reaper.GetMediaTrackInfo_Value(master_tr, "I_TCPY") + y_view_start
local m_tr_b = m_tr_t + m_tr_h
TBH[master_tr] = {t = m_tr_t, b = m_tr_b, h = m_tr_h}
end
for i = 1, reaper.CountTracks(0) do
local tr = reaper.GetTrack(0, i - 1)
local tr_h = reaper.GetMediaTrackInfo_Value(tr, "I_TCPH")
local tr_t = reaper.GetMediaTrackInfo_Value(tr, "I_TCPY") + y_view_start
local tr_b = tr_t + tr_h
TBH[tr] = {t = tr_t, b = tr_b, h = tr_h}
for j = 1, reaper.CountTrackEnvelopes(tr) do
local env = reaper.GetTrackEnvelope(tr, j - 1)
local env_h = reaper.GetEnvelopeInfo_Value(env, "I_TCPH")
local env_t = reaper.GetEnvelopeInfo_Value(env, "I_TCPY") + tr_t
local env_b = env_t + env_h
TBH[env] = {t = env_t, b = env_b, h = env_h}
end
end
end
the ghost code uses this to give info about mouse envelope
Code:
local window, segment, details = reaper.BR_GetMouseCursorContext()
local m_env, _ = reaper.BR_GetMouseCursorContext_Envelope()
EDIT:
Tested with old versions to see when things got broken:
Last version that works is 5.99
60rc1 got broken
Do not understand how same code works differently between versions
EDIT2: It seems that BR API is the issue, refactoring some functions to use native API