Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Bug Reports

Reply
 
Thread Tools Display Modes
Old 03-30-2022, 04:58 AM   #1
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,547
Default [Fixed in v6.53+dev0404] API: GetThingFromPoint returns wrong envelope id




Steps to reproduce:
1) Create a few envelopes (Volume included)
2) Hide (make not Visible) the Volume envelope


BUG:

GetThingFromPoint returns the first envelope it finds as having 0 id (=Volume) which is not true. The rest of the envelopes are returned correctly


Test code:
Code:
function main()
  local x, y = reaper.GetMousePosition()
  local track, info = reaper.GetThingFromPoint( x, y )
  if info:match("envelope") then
    local envidx = tonumber(info:match("%d+"))
    if envidx then
      env_name = ({reaper.GetEnvelopeName( reaper.GetTrackEnvelope( track, envidx ) )})[2]
      last_info = info
    end
  end
  reaper.defer(main)
end

reaper.atexit(function() return end)
main()
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)

Last edited by amagalma; 04-04-2022 at 01:16 PM.
amagalma is offline   Reply With Quote
Old 03-30-2022, 05:15 AM   #2
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,792
Default

Wanna +100 this since we cannot find which envelope is under mouse using native API (only with JS at the moment is correct, SWS BR_ is broken when zoomed)
Sexan is offline   Reply With Quote
Old 03-30-2022, 08:26 AM   #3
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 2,038
Default

+1
Things are weird.
The idx GetThingFromPoint returns are from visible in arrange envelopes, while other API like GetTrackEnvelope the idx consider hidden envelopes. So need to convert.

Besides that GetThingFromPoint is confusing idx. Like getting different values in the same envelope

Code:
function print(...)
	for k,v in ipairs({...}) do
		reaper.ShowConsoleMsg(tostring(v))
	end
	reaper.ShowConsoleMsg("\n")
end
local x, y = reaper.GetMousePosition()
track, info = reaper.GetThingFromPoint( x, y )
print('info:   ',info)


Track Chunk in this test:
Code:
<TRACK
  NAME ""
  PEAKCOL 16576
  BEAT -1
  AUTOMODE 0
  VOLPAN 1 0 -1 -1 1
  MUTESOLO 0 0 0
  IPHASE 0
  PLAYOFFS 0 1
  ISBUS 0 0
  BUSCOMP 0 0 0 0 0
  SHOWINMIX 1 0.6667 0.5 1 0.5 -1 -1 -1
  FREEMODE 2
  REC 0 0 0 0 0 0 0
  VU 2
  TRACKHEIGHT 0 0 0 0 0 0
  INQ 0 0 0 0.5 100 0 0 100
  NCHAN 2
  FX 1
  TRACKID {FBEDFD91-048C-4E7F-B79C-A649052E3DEC}
  PERF 0
  MIDIOUT -1
  MAINSEND 1 0
  <VOLENV2
    EGUID {AF469B2B-2A90-4722-B519-47A767CB8196}
    ACT 1 -1
    VIS 0 1 1
    LANEHEIGHT 0 0
    ARM 1
    DEFSHAPE 0 -1 -1
    PT 0 1 0
    PT 0.88 1 0 0 1
    PT 0.89 1 0 0 1
    PT 0.9 0.98360656 0 0 1
    PT 0.92 0.93442623 0 0 1
    PT 0.93 0.90983607 0 0 1
    PT 0.94 0.88114754 0 0 1
    PT 0.96 0.81967213 0 0 1
    PT 0.97 0.80327869 0 0 1
    PT 0.98 0.77868852 0 0 1
    PT 0.99 0.75819672 0 0 1
    PT 1.01 0.72131148 0 0 1
    PT 1.03 0.70491803 0 0 1
    PT 1.04 0.70491803 0 0 1
    PT 1.05 0.70491803 0 0 1
    PT 1.06 0.70491803 0 0 1
    PT 1.07 0.70491803 0 0 1
    PT 1.08 0.70491803 0 0 1
    PT 1.09 0.70491803 0 0 1
    PT 1.1 0.72131148 0 0 1
    PT 1.11 0.73770492 0 0 1
    PT 1.12 0.75409836 0 0 1
    PT 1.13 0.75409836 0 0 1
    PT 1.14 0.7704918 0 0 1
    PT 1.15 0.78688525 0 0 1
    PT 1.16 0.80327869 0 0 1
    PT 1.17 0.81967213 0 0 1
    PT 1.18 0.83606557 0 0 1
    PT 1.19 0.86885246 0 0 1
    PT 1.21 0.8852459 0 0 1
    PT 1.23 0.91803279 0 0 1
    PT 1.24 0.91803279 0 0 1
    PT 1.26 0.95081967 0 0 1
    PT 1.27 0.96721311 0 0 1
    PT 1.29 0.98360656 0 0 1
    PT 1.3 0.99180328 0 0 1
    PT 1.32 1.09836066 0 0 1
    PT 1.34 1.09836066 0 0 1
    PT 1.35 1.19672131 0 0 1
    PT 1.37 1.19672131 0 0 1
    PT 1.39 1.29508197 0 0 1
    PT 1.41 1.39344262 0 0 1
    PT 1.42 1.39344262 0 0 1
    PT 1.43 1.44262295 0 0 1
    PT 1.45 1.49180328 0 0 1
    PT 1.46 1.54098361 0 0 1
    PT 1.47 1.54098361 0 0 1
    PT 1.48 1.54098361 0 0 1
    PT 1.49 1.54098361 0 0 1
    PT 1.5 1.54098361 0 0 1
    PT 1.51 1.51639344 0 0 1
    PT 1.52 1.4795082 0 0 1
    PT 1.54 1.39344262 0 0 1
    PT 1.56 1.3442623 0 0 1
    PT 1.58 1.24590164 0 0 1
    PT 1.59 1.24590164 0 0 1
    PT 1.61 1.14754098 0 0 1
    PT 1.62 1.09836066 0 0 1
    PT 1.63 1.09836066 0 0 1
    PT 1.65 1 0 0 1
    PT 1.66 1 0 0 1
    PT 1.67 1 0 0 1
    PT 1.68 1 0 0 1
    PT 1.69 1 0 0 1
    PT 1.7 1 0 0 1
    PT 1.71 1 0 0 1
    PT 1.72 1 0 0 1
    PT 1.73 1 0 0 1
    PT 1.74 1 0 0 1
    PT 1.75 1 0 0 1
    PT 1.76 1 0 0 1
    PT 1.77 1 0 0 1
    PT 1.78 1 0 0 1
    PT 1.79 1 0 0 1
    PT 1.8 1 0 0 1
    PT 1.81 1 0 0 1
    PT 1.82 1 0 0 1
    PT 1.83 1 0 0 1
    PT 1.85 0.98360656 0 0 1
    PT 1.86 0.98360656 0 0 1
    PT 1.87 0.98360656 0 0 1
    PT 1.88 0.98360656 0 0 1
    PT 1.89 0.96721311 0 0 1
    PT 1.9 0.96721311 0 0 1
    PT 1.92 1 0 0 1
  >
  <PANENV2
    EGUID {F6CBD6A2-AB18-4B1B-8478-D5E75DF7BC8D}
    ACT 1 -1
    VIS 0 1 1
    LANEHEIGHT 0 0
    ARM 1
    DEFSHAPE 0 -1 -1
    PT 0 0 0
    PT 0.81 0.05 0 0 1
    PT 0.83 0.23032787 0 0 1
    PT 0.84 0.22213115 0 0 1
    PT 0.85 0.20983607 0 0 1
    PT 0.87 0.18114754 0 0 1
    PT 0.88 0.18114754 0 0 1
    PT 0.89 0.18114754 0 0 1
    PT 0.9 0.18114754 0 0 1
    PT 0.92 0.19754098 0 0 1
    PT 0.93 0.19754098 0 0 1
    PT 0.95 0.21393443 0 0 1
    PT 0.97 0.24672131 0 0 1
    PT 0.98 0.24672131 0 0 1
    PT 1 0.2795082 0 0 1
    PT 1.01 0.2795082 0 0 1
    PT 1.02 0.29590164 0 0 1
    PT 1.03 0.29590164 0 0 1
    PT 1.04 0.31229508 0 0 1
    PT 1.05 0.31229508 0 0 1
    PT 1.06 0.32868852 0 0 1
    PT 1.07 0.34508197 0 0 1
    PT 1.08 0.36147541 0 0 1
    PT 1.09 0.36147541 0 0 1
    PT 1.1 0.37786885 0 0 1
    PT 1.11 0.37786885 0 0 1
    PT 1.12 0.3942623 0 0 1
    PT 1.13 0.41065574 0 0 1
    PT 1.14 0.41065574 0 0 1
    PT 1.16 0.44344262 0 0 1
    PT 1.17 0.44344262 0 0 1
    PT 1.18 0.45163934 0 0 1
    PT 1.2 0.47622951 0 0 1
    PT 1.21 0.47622951 0 0 1
    PT 1.22 0.47622951 0 0 1
    PT 1.23 0.46803279 0 0 1
    PT 1.25 0.44344262 0 0 1
    PT 1.26 0.44344262 0 0 1
    PT 1.28 0.41065574 0 0 1
    PT 1.29 0.3942623 0 0 1
    PT 1.3 0.37786885 0 0 1
    PT 1.31 0.35327869 0 0 1
    PT 1.32 0.32459016 0 0 1
    PT 1.34 0.26311475 0 0 1
    PT 1.35 0.24672131 0 0 1
    PT 1.36 0.23032787 0 0 1
    PT 1.38 0.18114754 0 0 1
    PT 1.4 0.14836066 0 0 1
    PT 1.42 0.13196721 0 0 1
    PT 1.43 0.13196721 0 0 1
    PT 1.44 0.13196721 0 0 1
    PT 1.45 0.13196721 0 0 1
    PT 1.46 0.13196721 0 0 1
    PT 1.47 0.13196721 0 0 1
    PT 1.48 0.13196721 0 0 1
    PT 1.49 0.13196721 0 0 1
    PT 1.5 0.13196721 0 0 1
    PT 1.51 0.13196721 0 0 1
    PT 1.52 0.13196721 0 0 1
    PT 1.53 0.13196721 0 0 1
    PT 1.54 0.13196721 0 0 1
    PT 1.55 0.13196721 0 0 1
    PT 1.56 0.13196721 0 0 1
    PT 1.57 0.13196721 0 0 1
    PT 1.58 0.13196721 0 0 1
    PT 1.59 0.13196721 0 0 1
    PT 1.6 0.13196721 0 0 1
    PT 1.61 0.13196721 0 0 1
    PT 1.62 0.13196721 0 0 1
    PT 1.63 0.13196721 0 0 1
    PT 1.64 0.13196721 0 0 1
    PT 1.65 0.13196721 0 0 1
    PT 1.66 0.13196721 0 0 1
    PT 1.67 0.13196721 0 0 1
    PT 1.68 0.13196721 0 0 1
    PT 1.7 0.05 0 0 1
  >
  <VOLENV3
    EGUID {4F14090A-541B-4732-8E60-03F0E85B2776}
    ACT 1 -1
    VIS 1 1 1
    LANEHEIGHT 0 0
    ARM 1
    DEFSHAPE 0 -1 -1
    PT 0 1 0
    PT 1.75 0.45454545 0
  >
  <FXCHAIN
    WNDRECT -1895 171 755 461
    SHOW 0
    LASTSEL 0
    DOCKED 0
    BYPASS 0 0 0
    <VST "VST: ReaEQ (Cockos)" reaeq.dll 0 "" 1919247729<56535472656571726561657100000000> ""
      cWVlcu5e7f4CAAAAAQAAAAAAAAACAAAAAAAAAAIAAAABAAAAAAAAAAIAAAAAAAAArAAAAAEAAAAAABAA
      IQAAAAQAAAAAAAAAAQAAACbC0dsx11ZAQAAAoO1O2j8AAAAAAAAAQAEIAAAAAQAAANf/////v3JAOgAA4J2tAUAAAAAAAAAAQAEIAAAAAQAAAH/tvGmx1Y5A4P//373D5D8AAAAAAAAAQAEBAAAAAQAAAICbUXalC7RAy///n+oOAEAAAAAAAAAAQAEBAAAAAQAAAAAAAAAAAPA/AAAAAP0BAABcAQAAAgAAAA==
      AAAQAAAA
    >
    FLOATPOS 0 0 0 0
    FXID {7FDB2096-689F-42AF-8B80-25502DE8D9E6}
    <PARMENV 10:_Gain_High_Shelf 0 1 0.25
      EGUID {F0EE38CA-6508-42DD-B584-CDCEA0E7557E}
      ACT 1 -1
      VIS 1 1 1
      LANEHEIGHT 0 0
      ARM 1
      DEFSHAPE 0 -1 -1
      PT 0 0.50182086 0
    >
    <PARMENV 7:_Gain_Band_3 0 1 0.25
      EGUID {0554C877-CC3A-48AA-A896-620AD28A6C0E}
      ACT 1 -1
      VIS 1 1 1
      LANEHEIGHT 0 0
      ARM 1
      DEFSHAPE 0 -1 -1
      PT 0 0.16222356 0
    >
    <PARMENV 4:_Gain_Band_2 0 1 0.25
      EGUID {B3B870C5-32DF-4940-AF1C-B58427CEEB99}
      ACT 1 -1
      VIS 1 1 1
      LANEHEIGHT 0 0
      ARM 1
      DEFSHAPE 0 -1 -1
      PT 0 0.55244344 0
    >
    <PARMENV 1:_Gain_Low_Shelf 0 1 0.25
      EGUID {41C18FDA-4C3E-4CC6-9767-914AD30D8C5E}
      ACT 1 -1
      VIS 1 1 1
      LANEHEIGHT 0 0
      ARM 1
      DEFSHAPE 0 -1 -1
      PT 0 0.10276685 0
    >
    WAK 0 0
  >
>
daniellumertz is offline   Reply With Quote
Old 03-30-2022, 08:41 AM   #4
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,706
Default

Oh, interesting finds. Maybe the docs are a little confusing on that one and should mention that at least.

But I agree: returning the index of over all envelopes is more intuitive and more versatile than just visible ones, as there are no functions needing the index of visible envelopes, but plenty who use the index of all envelopes.

+1

Quote:
Besides that GetThingFromPoint is confusing idx. Like getting different values in the same envelope
Hmm..odd...
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is online now   Reply With Quote
Old 03-30-2022, 12:47 PM   #5
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,547
Default

Guys, the API returns the correct track envelope envidx, for the visible envelopes it finds at that point.

The bug is very specific: if the volume envelope has points but is hidden, then the first visible envelope it finds, it shows it incorrectly as having envidx 0.

@daniellumertz: that is what is happening in your gif too. Sometimes it returns 2, which is the correct envidx, but most times it returns 0.
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 03-30-2022, 03:51 PM   #6
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 2,038
Default

idk anymore what to think about this API, but it can get wrong results without the volume envelope



Code:
 function print(...)
	for k,v in ipairs({...}) do
		reaper.ShowConsoleMsg(tostring(v))
	end
	reaper.ShowConsoleMsg("\n")
end

local x, y = reaper.GetMousePosition()
local track, info = reaper.GetThingFromPoint( x, y )
local idx = tonumber(string.match(info,'%d'))
local env = reaper.GetTrackEnvelope( track, idx)
local retval, name = reaper.GetEnvelopeName(env)

print('')
print('info:   ',info)
print('name:   ',name)

Last edited by daniellumertz; 03-30-2022 at 04:08 PM.
daniellumertz is offline   Reply With Quote
Old 04-02-2022, 08:26 PM   #7
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 4,027
Default

Quote:
Originally Posted by daniellumertz View Post
idk anymore what to think about this API, but it can get wrong results without the volume envelope
Ya, it doesn't matter what env I hide, the returned index where the removed env was is now wrong (almost always).
If I resize the height of TCP enough then the indexes start working as expected again.
Its like some redraw/tcp size calc code not getting updated or something.
Edgemeal is offline   Reply With Quote
Old 04-02-2022, 09:11 PM   #8
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,998
Default

ah yeah, fixing, thanks!
Justin is offline   Reply With Quote
Old 04-04-2022, 01:15 PM   #9
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,547
Default

Thank you!


Fixed in v6.53+dev0404 - April 4 2022
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma 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 03:38 AM.


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