chops wrangle - access min/max value of a channel?

   6719   18   5
User Avatar
Member
1738 posts
Joined: May 2006
Online
Dabbling with channel wrangles, can see this handy stuff in the info window (see attached image).

Is it possible to access that in a wrangle? I hoped chattr() would do it, but all my assumptions about what that attribute might be called aren't valid. Eg


int success=0;
float result;
result = chattr(0,'channel','min',C,-1,success);
if (success) {
  printf('%s',result);
} else {
  printf('fail');
}

I'm sure I could get to it with other chop nodes, but would be nice to just pull it in directly via vex.

Attachments:
chops_info_window.jpg (152.9 KB)

http://www.tokeru.com/cgwiki [www.tokeru.com]
https://www.patreon.com/mattestela [www.patreon.com]
User Avatar
Member
2041 posts
Joined: Sept. 2015
Offline
This is an interesting one…I couldn't find a way to pull data with this function.
User Avatar
Member
4 posts
Joined: Sept. 2015
Offline
Weeee first forum post! Here's my attempt at a solution, though there has to be a faster way.

float sample[];
for(float i = 1; i < L ; i++){
  
    float test = chinput(0, C, i);
    
    append(sample, test);
}
float max = max(sample);
float min = min(sample);
User Avatar
Member
7722 posts
Joined: July 2005
Online
What about using an Expression CHOP first to compute the min/max via the icmin()/icmax() hscript expression functions?
User Avatar
Member
1738 posts
Joined: May 2006
Online
Hscript? Expression chop? Ew.

Yeah that'll work, but feels like some more vex chops functions would be handy.
http://www.tokeru.com/cgwiki [www.tokeru.com]
https://www.patreon.com/mattestela [www.patreon.com]
User Avatar
Member
402 posts
Joined: June 2014
Offline
+1 to more chops vex functions

Can I throw in the idea of some channel creation functions…? I'm probably going to try writing some of these in the next few days, so I'll be back with some stupid questions.
Henry Dean
User Avatar
Member
402 posts
Joined: June 2014
Offline
In the short-term if you need them, you can always drop something like this into your vex include directory

then plonk #include <chop_custom.h> at the start of your wrangle
Edited by friedasparagus - April 18, 2017 06:20:57

Attachments:
chop_custom.h (532 bytes)

Henry Dean
User Avatar
Staff
476 posts
Joined: April 2014
Offline
I'll need to add more vex helper functions for chop.( chinput_minmax being one of them ).
You need to be careful when doing loops in Channel wrangles because the code will be executed for each time sample and for each channel.

One way to get around that is to create an intermediate set of channels in a wrangle and make sure it has its first input unconnected and is setup in a non time dependent manner. This gives something similar to a detail wrangle in SOP, but with much more headaches. (It's the wave_compile_minmax node in the red group comment box).

Another way is to use the new per channel attributes that you can set/get with chsetattr/chattr. This gives you a single chain of nodes and you can store attribute on channels, but the Channel Wrangle doesn't yet support being executed only one time per channel when the node has multiple time samples.

Attachments:
chinput_minmax.hip (61.5 KB)
channel_wrangle_min_max.png (77.9 KB)

User Avatar
Member
402 posts
Joined: June 2014
Offline
Ah sugar lumps! I was thinking that iterating over channels meant that it would only run a loop once for each channel…
Henry Dean
User Avatar
Staff
476 posts
Joined: April 2014
Offline
friedasparagus
Ah sugar lumps! I was thinking that iterating over channels meant that it would only run a loop once for each channel…

It isn't clear. I think Over all Samples computes all the samples from the first channel, then moves on the next channel. It's the legacy iteration mode where you couldn't write to multiple channels at the same time.

Over all Channels, sets the time to the first sample, then iterates over all the channels. sets the time to the second sample, iterates over all the channels and so on.

Every Nth Channels is the same as Over all Channels, but it regroups multiple channels together.
User Avatar
Member
8555 posts
Joined: July 2007
Offline
as a side question, while talking about Channel VOP/Wrangle CHOP, this seems to be based on the old vopchop, is there a plan to make a CVEX version?

Or even something more customized that'd allow for binding(in/out) channels or channel groups by name/pattern? Like Volume VOP allows for volumes, that would be invaluable
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
402 posts
Joined: June 2014
Offline
chinputlimits() !!!

how did this not make it to the changelogs? (only just noticed it on build 605)
lovely new iteration methods too!

Thanks very much guys!
Henry Dean
User Avatar
Staff
476 posts
Joined: April 2014
Offline
Oups. My bad.. the changes were a direct response to this thread. I did update the documentation on the CHOP wrangle node.
User Avatar
Member
402 posts
Joined: June 2014
Offline
I guessed as much I know things along these lines have been said before, but for thoughts in a forum thread barely a month old to actually make it into the software is just bloomin' great! Keep it up!
Henry Dean
User Avatar
Member
146 posts
Joined: Jan. 2016
Offline
@Guillaume, please, I have tried this new function chinputlimits().
- chinputlimits(0,0,…) iterates fine and gives me min/max
- chinputlimits(0,1,…) seems to evaluate just the first sample … not over all the range

Am I doing something wrong? I have attached my file.

Attachments:
minmax.PNG (56.7 KB)
minmax.hiplc (97.2 KB)

User Avatar
Member
4516 posts
Joined: Feb. 2012
Offline
tamte
as a side question, while talking about Channel VOP/Wrangle CHOP, this seems to be based on the old vopchop, is there a plan to make a CVEX version?

Or even something more customized that'd allow for binding(in/out) channels or channel groups by name/pattern? Like Volume VOP allows for volumes, that would be invaluable

+1
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
User Avatar
Staff
476 posts
Joined: April 2014
Offline
ikoon
Am I doing something wrong? I have attached my file.
No you do it correctly, the vex function has a bug and I'll need to investigate.
User Avatar
Staff
476 posts
Joined: April 2014
Offline
and yes we do want to move to CVEX, but it isn't something that can happen overnight.
I'll probably start by adding CHOP lookup functions to CVEX. Currently, you need to use a Channel SOP to import CHOP data into SOP, even if you are using wrangles.
User Avatar
Member
2537 posts
Joined: June 2008
Offline
So if I use Guillaume's method for generating min/max as an attribute on a channel. How would I fetch that value from a Python node in the /obj context?

I am trying to find the min/max rotation range for each bone in a mocap skeleton.
So the CHOP channel attribute is stored within the hou.Track()?
Edited by Enivob - May 5, 2018 10:51:05
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
  • Quick Links