Writing channel values?

   733   7   0
User Avatar
Member
30 posts
Joined: 9月 2019
Offline
I'm still familiarizing myself with CHOPs, and one thing is (no pun intended) vexing me: how do I actually write a value to a channel? I've got a Phoneme CHOP set up, and I've got character blend shape channels corresponding to some of the phonemes, but I haven't figured out how to convert the Phoneme (a float value where each integer is a different phoneme) to a value of 1 on the appropriate blend shape, e.g. Phoneme 4 to blendshape EH. Nothing I've tried so far has worked to affect the value of any of the channels in any way. What am I missing here?
User Avatar
Member
30 posts
Joined: 9月 2019
Offline
I am absolutely pulling my hair out trying to figure out what seems like the most basic, critical part of working in CHOPs. I'm not even bothering about writing values to a channel at this point: how do I REFERENCE the value of a channel? I'm feeding a Phoneme CHOP , outputting the channel Phoneme, into a Channel Wrangle with the following code:
float ph = ch("Phoneme");
printf("%g", ph);
No matter what the value of Phoneme is at the time, the printf always outputs 0. I've tried changing multiple parameters on both CHOPs involved, tried changing the iteration on the Wrangle, even tried things like chattr, chop and chp, but nothing is doing the trick. What am I missing?
User Avatar
Member
22 posts
Joined: 4月 2013
Offline
One method for getting a value of a channel from chops into a vex wrangle requires creating a parameter on the sop wrangle using the "parameter edit menu", give it a data name / label, then use an "export" node from inside chops to link to the new parameter.

Turn on the orange tab (second from left) on the export node which will override your new parameter then you can access it inside vex.

There maybe a few other/better ways I am not aware of but this does work for wrangles.

**********

If you simply need to read the value of a channel into a parameter in SOPs for example you can use the chopcf() function to read any channel value at any given time directly.


Also look into the "channel sop" in combination with a "geometry node" from in chops to pull in existing data, manipulate the channels in sops with a math node and waveform or whatever and return them back to sops using the channel sop, it will overwrite the existing data from sops with the chop modified version.....this allows many channels to be adjusted at the same time....cool for delay effects, offsets etc.

Attachments:
Chops_to_Vex.hipnc (208.8 KB)

User Avatar
Member
8597 posts
Joined: 7月 2007
Offline
gordig
... I'm feeding a Phoneme CHOP , outputting the channel Phoneme, into a Channel Wrangle with the following code:
float ph = ch("Phoneme");
printf("%g", ph);
No matter what the value of Phoneme is at the time, the printf always outputs 0. I've tried changing multiple parameters on both CHOPs involved, tried changing the iteration on the Wrangle, even tried things like chattr, chop and chp, but nothing is doing the trick. What am I missing?

channel in Houdini refers to many things and it can get confusing, ch() is to sample channels of parameters, not CHOP channels
but since you are interested in a chop channel coming from input chop ( assuming you named your channel "phoneme" )you can use chinput():
float phoneme_value = chinput(0, "phoneme", I); // to read at the current sample or use custom sample number instead of I
to read and write value of the current channel at current sample you can use V global variable
float current_channel_value = V; // read current channel's value at current sample
V = 5; //set current channel's value at current sample to 5
there are other global variables [www.sidefx.com] that can help you, like C for current channel number or CN for current channel name, ..
Edited by tamte - 2024年5月2日 10:43:31
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
30 posts
Joined: 9月 2019
Offline
tamte
channel in Houdini refers to many things and it can get confusing, ch() is to sample channels of parameters, not CHOP channels
but since you are interested in a chop channel coming from input chop ( assuming you named your channel "phoneme" )you can use chinput():
float phoneme_value = chinput(0, "phoneme", I); // to read at the current sample or use custom sample number instead of I
to read and write value of the current channel at current sample you can use V global variable
float current_channel_value = V; // read current channel's value at current sample
V = 5; //set current channel's value at current sample to 5
there are other global variables [www.sidefx.com] that can help you, like C for current channel number or CN for current channel name, ..
Thank you, the documentation can get pretty sparse for CHOPs and VEX, so this helps. I've tried using V before, but wasn't quite sure how, and I didn't bother with I because I didn't think I wanted the INDEX of a sample. Now I'm back to the problem I was having before I only got 0: it prints the value of Phoneme at EVERY frame, so now it outputs 00000031313131313144444443535353535358888880000003131313131311515151515151500000066666638383838383800000037373737373737101010101010383838383838000000272727272727271111111111112121212121211313131313133232323232322727272727272719191919191955555533333333333327272727272722222222828282828280000000.

This is only when the Wrangle is set to Channels and Samples, or Samples and Channels. If I set it to Channels, it outputs a single 0, and if Samples, a 0 for every frame. Is the current output of the value at every frame workable, or is there a way to output only the value at the current frame? I'm still at the stage where I'm frenetically changing parameters in the vain hope of getting the results I want, so I don't fully grasp what a lot of those parameters do.

EZiniT
If you simply need to read the value of a channel into a parameter in SOPs for example you can use the chopcf() function to read any channel value at any given time directly.


Also look into the "channel sop" in combination with a "geometry node" from in chops to pull in existing data, manipulate the channels in sops with a math node and waveform or whatever and return them back to sops using the channel sop, it will overwrite the existing data from sops with the chop modified version.....this allows many channels to be adjusted at the same time....cool for delay effects, offsets etc.
Every time I've tried to use a Geometry CHOP, I get an invalid SOP error, so I haven't spent a lot of time with them. I'll definitely give chopcf a try, though. Thank you.
User Avatar
Member
8597 posts
Joined: 7月 2007
Offline
gordig
This is only when the Wrangle is set to Channels and Samples, or Samples and Channels. If I set it to Channels, it outputs a single 0, and if Samples, a 0 for every frame. Is the current output of the value at every frame workable, or is there a way to output only the value at the current frame?
it will process all samples of the input channels, that's how chops work
if you want it to process just current time slice you ether feed it channels that are generated only for current time sample or if the channels are generated for certain time range like from Phoneme CHOP you can insert Trim CHOP inbetween, set to Current Time Slice

or you can also connect phoneme to second input of Channel Wrangle, keep first empty, set channel range to Use Current Frame and sample the phoneme value from 2nd input
float phoneme_value = chinput(1, "phoneme", I);
// process phoneme value
V = phoneme_value;

however I'd keep it processing all samples rather than introducing time dependency by slicing the channel
Edited by tamte - 2024年5月2日 16:20:56
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
30 posts
Joined: 9月 2019
Offline
I plugged a chopcf argument into an Attribute Wrangle SOP, and it kicked up errors about an unrecognized command. I dropped that same code into an Attribute Create, and that worked to create an attribute with the correct value read from the channel. I've had this problem before with things like pulse(), so I'm guessing Wrangles are literally ONLY VEX, or ONLY Python?

Thanks for all your help so far.
User Avatar
Member
8597 posts
Joined: 7月 2007
Offline
Yes, wrangle is only VEX, you can't use chopcf() as that's a HScript function, VEX closest equivalent is chop() or mentioned chinput() if sampling direct inputs
Those however take sample index not frame so you need to convert that if you want to use frames
Tomas Slancik
FX Supervisor
Method Studios, NY
  • Quick Links