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

Reply
 
Thread Tools Display Modes
Old 11-05-2017, 05:40 AM   #1
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
Default API: CountEnvelopePointsEx() not returning nr. of points in AI (FIXED)

FIXED (v5.979)

See

https://forum.cockos.com/showthread.php?t=199142

Last edited by nofish; 06-20-2019 at 08:24 AM.
nofish is offline   Reply With Quote
Old 12-08-2017, 10:36 AM   #2
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
Default

bump

Also, as mentioned in the linked thread, CountEnvelopePoints() doesn't work the same anymore as before the introduction of AI's (when AI's are present on the track).
nofish is offline   Reply With Quote
Old 01-19-2018, 03:17 PM   #3
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,970
Default

Still happens in 5.70.
cfillion is offline   Reply With Quote
Old 03-02-2018, 07:32 AM   #4
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
Default

bump

as this also affects SWS currently.

So at least a statement if this is considered a bug or not a bug / 'live with it' and SWS / scripters should work around it would be nice.

Last edited by nofish; 03-02-2018 at 07:47 AM.
nofish is offline   Reply With Quote
Old 03-05-2018, 03:23 PM   #5
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

A related problem is that Automation Items are not included in track or item state chunks. Scripts can therefore not count the points by parsing the state chunk.
juliansader is offline   Reply With Quote
Old 04-08-2018, 07:15 AM   #6
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
Default

Hm..actually I'm not not so sure currently if it's completely fixed.

When I run the following code

Code:
function msg(m)
  return reaper.ShowConsoleMsg(tostring(m) .. "\n")
end


track = reaper.GetTrack(0,0)
env =  reaper.GetTrackEnvelope( track, 0 )

countPts_underlyingEnv = reaper.CountEnvelopePointsEx(env, -1);
countPtsAI_1 = reaper.CountEnvelopePointsEx(env, 0);
countPtsAI_2 = reaper.CountEnvelopePointsEx(env, 1);
countPtsAI_3 = reaper.CountEnvelopePointsEx(env, 2); -- doesn't exist

msg("Points in underlEnv: " .. countPts_underlyingEnv)
msg("Points in AI1: " .. countPtsAI_1)
msg("Points in AI2: " .. countPtsAI_2)
msg("Points in AI3: " .. countPtsAI_3)
I get this:


Could it be that the point count in AIs is (wrongly) doubled somehow ?

(R5.78)

edit:
Point count in AIs seems erratic.
I just retried above script with a fresh portbale R5.78 (32 bit) install in a project from scratch and get this:



In first AI it seems ok, second one seems doubled.

Last edited by nofish; 04-08-2018 at 09:07 AM.
nofish is offline   Reply With Quote
Old 04-08-2018, 10:21 AM   #7
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,746
Default

Duplicated.

This appears to be that it includes neighboring loop iterations in the envelope point list, sometimes even when those iterations are not visible. For now as a workaround you can call reaper. GetSetAutomationItemInfo() to get the start/length of the item, then loop through the points to see which ones are actually within those bounds.

Last edited by Justin; 04-08-2018 at 10:35 AM.
Justin is offline   Reply With Quote
Old 04-08-2018, 10:35 AM   #8
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
Default

Thanks Justin.

Maybe not necessary to post the .rpp as reproduced here from scratch ?
(fresh portable R5.78 32 bit)

Point count in second AI seems doubled:



edit:
Missed your edit, nevermind.
Thanks for looking into it.

PS:
Sorry for speaking to soon / sloppy testing.

Last edited by nofish; 04-08-2018 at 10:46 AM.
nofish is offline   Reply With Quote
Old 04-08-2018, 11:07 AM   #9
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,746
Default

Sorry for the confusing edit!

Looking at this more, we need to keep extra points outside of the visible area (even when looping) for obscure reasons (and also if bezier points are used), so it might just be good advice to check the points against the bounds of the container to see if they are meaningful...
Justin is offline   Reply With Quote
Old 04-08-2018, 11:15 AM   #10
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
Default

Ok, so it sounds like it'll stay this way (for the forseeable future) ?

Asking because I noticed this when working on SWS stuff and now wondering if I should use your suggested workaround or wait for a change / fix ?
nofish is offline   Reply With Quote
Old 04-08-2018, 12:32 PM   #11
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,746
Default

Yes, definitely use the workaround -- it might change at some point, but if it does it would still often contain points that are outside the visible area (so that linear or bezier transitions can be interpolated), so in this case you'd want to validate the points anyway.
Justin is offline   Reply With Quote
Old 04-08-2018, 12:58 PM   #12
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
Default

Ok, thanks.
nofish is offline   Reply With Quote
Old 04-09-2018, 04:40 PM   #13
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
Default

Quote:
Originally Posted by Justin View Post
For now as a workaround you can call reaper. GetSetAutomationItemInfo() to get the start/length of the item, then loop through the points to see which ones are actually within those bounds.
One question about this, sorry.

When I have a situation like this:


Left edge upper point is in underlying envelope, lower point is in AI, but visually the seem (alomost ?) at the same position. How should I do the bounds check to only and reliably catch the point within AI ?

Can I assume point_pos within AI is always > AI start and < AI end or can they fall exactly at AI bounds too ? (hope it's clear what I mean ?)

Last edited by nofish; 04-09-2018 at 04:54 PM.
nofish is offline   Reply With Quote
Old 04-10-2018, 06:46 AM   #14
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,746
Default

Quote:
Originally Posted by nofish View Post
One question about this, sorry.

When I have a situation like this:


Left edge upper point is in underlying envelope, lower point is in AI, but visually the seem (alomost ?) at the same position. How should I do the bounds check to only and reliably catch the point within AI ?

Can I assume point_pos within AI is always > AI start and < AI end or can they fall exactly at AI bounds too ? (hope it's clear what I mean ?)
If you only want the points within the AI, you should just request the points for that AI, then bounds check them to >= AI start and < AI start+AI len. You might need to look at the next points on each side if you need to transition to those values too?
Justin is offline   Reply With Quote
Old 04-10-2018, 07:15 AM   #15
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
Default

Quote:
Originally Posted by Justin View Post
then bounds check them to >= AI start and < AI start+AI len.
This is the bit of info I needed, thanks!
nofish is offline   Reply With Quote
Old 04-11-2018, 07:32 PM   #16
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
Default

Another thing...

I'm trying to count the actual visually present points in this envelope.
This is with 'AIs attach to underlying env. on both sides' enabled:




Code:
function msg(m)
  return reaper.ShowConsoleMsg(tostring(m) .. "\n")
end

track = reaper.GetTrack(0,0)
env =  reaper.GetTrackEnvelope( track, 0 )

countPts_underlyingEnv = reaper.CountEnvelopePointsEx(env, -1)
countPtsAI_1 = reaper.CountEnvelopePointsEx(env, 0)

countActualPtsAI_1 = 0
AIpos = reaper.GetSetAutomationItemInfo(env, 0, "D_POSITION", 0, false);
AIend = AIpos + reaper.GetSetAutomationItemInfo(env, 0, "D_LENGTH", 0, false);
for i = 0, countPtsAI_1-1  do
  retval, time, value, shape, tension, selected = reaper.GetEnvelopePointEx(env, 0, i)
  if time >= AIpos and time < AIend then
    countActualPtsAI_1 = countActualPtsAI_1 + 1
  end
end

pointsTotal = countPts_underlyingEnv +  countActualPtsAI_1

msg("Points in underlEnv: " .. countPts_underlyingEnv)
msg("actual Points in AI1: " .. countActualPtsAI_1)
msg("points total: " .. pointsTotal)
When I use your suggested workaround with the bounds check the points at AI edges are counted in the underlying env. (ok, as per Options) but also in the AIs (because using the bounds check method) which results in a total point count > the actual point count on this env.

(Background: I'm currently trying to make the SWS envelope actions work with AIs and this would be a problem there as it works with counting / looping through the env. points and caching them for manipulating. So it would cache more points than actually present.)

I'm not sure how I should get the correct total point count in this case.
I think a IsPointContainedInUnderlyingEnvelope(AIidx, ptIdx) could help in this case to avoid 'double counts'.

Or is there another way I'm missing ?

Last edited by nofish; 04-17-2018 at 11:53 AM.
nofish is offline   Reply With Quote
Old 04-17-2018, 11:43 AM   #17
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
Default

CountEnvelopePoints() seems also give wrong results in some cases:



Code:
function msg(m)
  return reaper.ShowConsoleMsg(tostring(m) .. "\n")
end

track = reaper.GetTrack(0,0)
env = reaper.GetTrackEnvelope( track, 0 )
countPts_underlyingEnv = reaper.CountEnvelopePoints(env)

msg("Points in underlEnv: " .. countPts_underlyingEnv)
nofish is offline   Reply With Quote
Old 04-19-2018, 09:04 PM   #18
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,984
Default

I would request a change for enumeration points of AI not in visible area, but real count, in case of looped AI it is a number of points in source AI. Other things is math.

Also maybe not related, but there is not any API for dealing (enumerate, getsetchunk, delete) with pooling AI sources (which are in the RPP header).
(It is one of the reason I still not included AI context into InteractiveToolbar yet).

Last edited by mpl; 04-19-2018 at 11:43 PM.
mpl is offline   Reply With Quote
Old 04-19-2018, 09:07 PM   #19
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,970
Default

Quote:
Originally Posted by mpl View Post
Also maybe not related, but there is not any API for dealing with pooling AI sources (which are in the RPP header).
Being able to get/set the source length would be useful! https://forum.cockos.com/showthread.php?t=202186
cfillion is offline   Reply With Quote
Old 04-19-2018, 11:49 PM   #20
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by nofish View Post
CountEnvelopePoints() seems also give wrong results in some cases:
I think REAPER must necessarily add points to the underlying envelope, otherwise there is no node to connect the downward sloping segment to the left with the flat segment to the right.
juliansader is offline   Reply With Quote
Old 04-20-2018, 03:41 AM   #21
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,984
Default

Quote:
Originally Posted by juliansader View Post
I think REAPER must necessarily add points to the underlying envelope, otherwise there is no node to connect the downward sloping segment to the left with the flat segment to the right.
If I understand right, something like EvaluateEnvelope() used internally for these cases.
mpl 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 01:22 PM.


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