Old 07-25-2019, 04:51 PM   #1
Alkamist
Human being with feelings
 
Join Date: Dec 2011
Posts: 452
Default Is there a way to reliably get track height?

reaper.GetMediaTrackInfo_Value(track, "I_WNDH") gives you the height with all of the envelopes added on, and reaper.GetMediaTrackInfo_Value(track, "I_HEIGHTOVERRIDE") can return 0.

I suppose it's possible to find and subtract all of the envelope heights, but sometimes the envelope's lane height in the state chunk will be 0 as well.
Alkamist is offline   Reply With Quote
Old 07-26-2019, 07:05 AM   #2
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,399
Default

You could fumble it out a TrackStateChunk. Every track has an element called TRACKHEIGHT, which has three "parameters":

integer height - 24 up to 443
integer heightstate2 - 0 - use height, 1 - compact the track and ignore the height
integer lock_trackheight - 0, don't lock the trackheight; 1, lock the trackheight

Or you can use my Ultraschall-API and use this function:
https://mespotin.uber.space/Ultrasch...ackHeightState
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 07-26-2019, 07:06 AM   #3
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,399
Default

PS: If the height is 0, as you pointed out, it probably means default height, if I remember correctly...

TrackStateChunks should hold the actual height of the track.
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 07-26-2019, 07:31 AM   #4
Alkamist
Human being with feelings
 
Join Date: Dec 2011
Posts: 452
Default

Quote:
Originally Posted by mespotine View Post
PS: If the height is 0, as you pointed out, it probably means default height, if I remember correctly...

TrackStateChunks should hold the actual height of the track.
If you call the action "Zoom Vertically" (action 991), track height in the track state chunk will also return 0.

Is there a way to get the height after calling that action?
Alkamist is offline   Reply With Quote
Old 07-26-2019, 08:20 AM   #5
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,399
Default

Don't know. Will inspect that and see, if I find a way to make that work.
Thanks for pointing that out. Didn't know that yet..
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 07-27-2019, 03:45 AM   #6
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 8,915
Default

If I_HEIGHTOVERRIDE is 0 it's the "defvzoom"" config variable I think.
https://forum.cockos.com/showthread.php?t=208882

(Didn't check it myself...)
nofish is offline   Reply With Quote
Old 07-27-2019, 05:26 AM   #7
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,399
Default

Sounds legit, so it's worth a try.

@Alkamist
Some more info on config-vars, especially that one:
https://mespotin.uber.space/Ultrasch....html#defvzoom
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 07-27-2019, 08:45 AM   #8
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 1,259
Default

Just an idea,...

Code:
-- based on code by Embass,
-- https://forum.cockos.com/showpost.php?p=2122175&postcount=93

function print(value)
  if string == nil then reaper.ShowConsoleMsg("nil..\n")
  else reaper.ShowConsoleMsg(tostring(value).."\n")
  end
end  

local arrange_window = reaper.JS_Window_FindChildByID(reaper.GetMainHwnd(), 1000)
if arrange_window == nil then show("Error: arrange window = nil.\n"); return end -- exit

-- track panels and envelope panels parent window
function get_trackview_window()
  local _, _, arr_top = reaper.JS_Window_GetRect(arrange_window)
  local window = reaper.JS_Window_GetRelated(arrange_window, "NEXT")
  while window do
    local _, _, top = reaper.JS_Window_GetRect(window)
    if top == arr_top then return reaper.JS_Window_GetRelated(window, "CHILD") end
    window = reaper.JS_Window_GetRelated(window, "NEXT")
  end
end

local trackview_window = get_trackview_window()
if trackview_window == nil then show("Error: trackview window = nil.\n"); return end -- exit

function get_track_heights()
  local track_count = 0
  local t = {}
  -- loop over track and envelope windows
  local window = reaper.JS_Window_GetRelated(trackview_window, "CHILD")
  while window do
    if reaper.JS_Window_IsVisible(window) then
      -- windows visible in arrange view only
      local _, _, top, _, bottom = reaper.JS_Window_GetRect(window)
      local pointer = reaper.JS_Window_GetLongPtr(window, "USERDATA")
      if reaper.ValidatePtr(pointer, "MediaTrack*") then
        track_count = track_count+1
        t[track_count] = bottom-top
      end
    end
    window = reaper.JS_Window_GetRelated(window, "NEXT") --> window or nil
  end
  return t
end

track_heights = get_track_heights()

for i = 1, #track_heights do
 print (track_heights[i])
end
Edgemeal is offline   Reply With Quote
Old 07-27-2019, 11:24 AM   #9
Alkamist
Human being with feelings
 
Join Date: Dec 2011
Posts: 452
Default

Thanks for the help everyone!

Quote:
Originally Posted by nofish View Post
If I_HEIGHTOVERRIDE is 0 it's the "defvzoom"" config variable I think.
https://forum.cockos.com/showthread.php?t=208882

(Didn't check it myself...)
In that link the OP uses a function "reaper.SNM_GetIntConfigVar("defvzoom", -1)". I can't find that in the API documentation. Do you know where the documentation for this is?

Quote:
Originally Posted by Edgemeal View Post
Just an idea,...

Code:
-- based on code by Embass,
-- https://forum.cockos.com/showpost.php?p=2122175&postcount=93

function print(value)
  if string == nil then reaper.ShowConsoleMsg("nil..\n")
  else reaper.ShowConsoleMsg(tostring(value).."\n")
  end
end  

local arrange_window = reaper.JS_Window_FindChildByID(reaper.GetMainHwnd(), 1000)
if arrange_window == nil then show("Error: arrange window = nil.\n"); return end -- exit

-- track panels and envelope panels parent window
function get_trackview_window()
  local _, _, arr_top = reaper.JS_Window_GetRect(arrange_window)
  local window = reaper.JS_Window_GetRelated(arrange_window, "NEXT")
  while window do
    local _, _, top = reaper.JS_Window_GetRect(window)
    if top == arr_top then return reaper.JS_Window_GetRelated(window, "CHILD") end
    window = reaper.JS_Window_GetRelated(window, "NEXT")
  end
end

local trackview_window = get_trackview_window()
if trackview_window == nil then show("Error: trackview window = nil.\n"); return end -- exit

function get_track_heights()
  local track_count = 0
  local t = {}
  -- loop over track and envelope windows
  local window = reaper.JS_Window_GetRelated(trackview_window, "CHILD")
  while window do
    if reaper.JS_Window_IsVisible(window) then
      -- windows visible in arrange view only
      local _, _, top, _, bottom = reaper.JS_Window_GetRect(window)
      local pointer = reaper.JS_Window_GetLongPtr(window, "USERDATA")
      if reaper.ValidatePtr(pointer, "MediaTrack*") then
        track_count = track_count+1
        t[track_count] = bottom-top
      end
    end
    window = reaper.JS_Window_GetRelated(window, "NEXT") --> window or nil
  end
  return t
end

track_heights = get_track_heights()

for i = 1, #track_heights do
 print (track_heights[i])
end
This works perfectly so far, thanks!
Alkamist is offline   Reply With Quote
Old 07-27-2019, 02:36 PM   #10
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 8,915
Default

Quote:
Originally Posted by Alkamist View Post
In that link the OP uses a function "reaper.SNM_GetIntConfigVar("defvzoom", -1)". I can't find that in the API documentation. Do you know where the documentation for this is?
It's a function provided by SWS extension, they are all listed here:
https://www.extremraym.com/cloud/rea...etIntConfigVar

and in API doc maintained by mespotine:
https://mespotin.uber.space/Ultrasch...mentation.html

The config variables are documented here:
https://mespotin.uber.space/Ultrasch...Variables.html

Last edited by nofish; 07-27-2019 at 02:46 PM.
nofish is offline   Reply With Quote
Old 07-27-2019, 02:56 PM   #11
Alkamist
Human being with feelings
 
Join Date: Dec 2011
Posts: 452
Default

Quote:
Originally Posted by nofish View Post
It's a function provided by SWS extension, they are all listed here:
https://www.extremraym.com/cloud/rea...etIntConfigVar

and in API doc maintained by mespotine:
https://mespotin.uber.space/Ultrasch...mentation.html

The config variables are documented here:
https://mespotin.uber.space/Ultrasch...Variables.html
Thanks! That is really helpful. That actually fixes a problem I had that I posted about in another thread as well.
Alkamist is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 05:09 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.