|
|
|
11-05-2017, 05:40 AM
|
#1
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
|
API: CountEnvelopePointsEx() not returning nr. of points in AI (FIXED)
Last edited by nofish; 06-20-2019 at 08:24 AM.
|
|
|
12-08-2017, 10:36 AM
|
#2
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
|
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).
|
|
|
01-19-2018, 03:17 PM
|
#3
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,968
|
Still happens in 5.70.
|
|
|
03-02-2018, 07:32 AM
|
#4
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
|
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.
|
|
|
03-05-2018, 03:23 PM
|
#5
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
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.
|
|
|
04-08-2018, 07:15 AM
|
#6
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
|
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.
|
|
|
04-08-2018, 10:21 AM
|
#7
|
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 15,746
|
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.
|
|
|
04-08-2018, 10:35 AM
|
#8
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
|
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.
|
|
|
04-08-2018, 11:07 AM
|
#9
|
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 15,746
|
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...
|
|
|
04-08-2018, 11:15 AM
|
#10
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
|
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 ?
|
|
|
04-08-2018, 12:32 PM
|
#11
|
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 15,746
|
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.
|
|
|
04-08-2018, 12:58 PM
|
#12
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
|
Ok, thanks.
|
|
|
04-09-2018, 04:40 PM
|
#13
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
|
Quote:
Originally Posted by Justin
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.
|
|
|
04-10-2018, 06:46 AM
|
#14
|
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 15,746
|
Quote:
Originally Posted by nofish
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?
|
|
|
04-10-2018, 07:15 AM
|
#15
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
|
Quote:
Originally Posted by Justin
then bounds check them to >= AI start and < AI start+AI len.
|
This is the bit of info I needed, thanks!
|
|
|
04-11-2018, 07:32 PM
|
#16
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
|
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.
|
|
|
04-17-2018, 11:43 AM
|
#17
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
|
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)
|
|
|
04-19-2018, 09:04 PM
|
#18
|
Human being with feelings
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,984
|
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.
|
|
|
04-19-2018, 09:07 PM
|
#19
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,968
|
Quote:
Originally Posted by mpl
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
|
|
|
04-19-2018, 11:49 PM
|
#20
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
Quote:
Originally Posted by nofish
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.
|
|
|
04-20-2018, 03:41 AM
|
#21
|
Human being with feelings
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,984
|
Quote:
Originally Posted by juliansader
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.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 05:19 AM.
|