Jump to content

Modifying CHOPs with a Wrangle on a Per Channel Basis


DeeLan

Recommended Posts

Hey Guys. I've import some midi files into chops. Each time a key is pressed, it creates a flat peak, and then goes down to zero. So basically I've got a bunch of channels with localised plateau peaks. What I want to do is essentially extend the tops of these peaks until a new plateau is reached, at which point I will extend that plateau out the the next one, and so on. I've gone ahead and done this in SOPs to illustrate what I'm trying to do (cause that explanation above likely made no sense).

5a752841ec4c3_PeakModificationExample.thumb.jpg.45968823b9dab3f0ab295dc3815ecde0.jpg

The pseudo code for what I want to do is:

maxVal = value of sample0;
foreach sample (excluding 0){
    curVal =  the value of the current sample;
    if curVal is equal to 0{
    Current Sample Value is set to the maxVal;
    } else {
    maxVal is set to the curVal;
    }
}

This is the logic I followed in SOPs and it worked perfectly. However I cannot figure out how to do the same thing in CHOPs. My problems are two fold.

1) I can't figure out how to set the value of samples that are NOT the current one being iterated on. The way I've found so far to set sample values is using the global variable V. I tried to do it using the 'chsetattr' function, but either it doesn't set sample values or "V" is not the right attribute to use (and I can't find the correct one). Also tried setting a sample attribute on one wrangle, then on another (with iterate set to channels and samples) set "V" to the value of the attribute. Also didn't work.

2) So far I have found no way of only executing the code once (such as in a detail wrangle, which is what I used for the SOPs example). I thought setting the wrangle to iterate by "Over Channels" would do the trick, as the documentation says, "Runs the snippet one time per channel with the I variable set to zero." but in this this post Guillaume points out that this isn't the case. And even if it was I still would be in trouble because that mode does allow setting "V" or channel data.

2.5) On that note, whats the difference between channel data and attributes? One can be written the other can't. I thought attributes were just data stored on the geo (or in this case channel). Not sure why CHOPs is suddenly making a distinction.

So to summarise, I need to find a way to set the values of individual samples and I need a way of executing a CHOP wrangle once per channel (like a detail wrangle in SOPs).

 

Link to comment
Share on other sites

Do you specifically want to do this with a wrangle or do you just want to do it?

Attached is a file that does what you're after but it's not done in a wrangle. I did try but they're still a bit of a dark art to me too, I will have another try when I get chance

peaks and troughs.hiplc

peaks and troughs.hiplc <-- updated

Edited by j00ey
updated file
Link to comment
Share on other sites

Ps from what I can gather, chsetattr sets metadata attributes - I don't know what that means in depth but it's clearly not the same as normal channel data. In the attached file I write the channel data to an attribute called 'testval', then read it back.

Perhaps there might be a way of storing all the sample data as a clip level attribute as an array, then manipulating it in a second wrangle..? From what I gather if you run a wrangle over channels or samples and input 0 only has 1 channel and 1 sample, that would be like running a SOP level wrangle in detail mode. I'm just thinking aloud, I'll give it a go when I get chance

set_get_attrib.hiplc

Link to comment
Share on other sites

@j00ey thats perfect! It doesn't at all have to be in a wrangle. I just tend to default to solving problems with VEX but in this case your method is exactly what I need! 

I'm gonna guess that channel data vs metadata is like the "P" attribute vs every other possible point attribute. One's the default attribute that exists and is used on every single point/channel, the others are just extras we can use. I think part of the problem I was having is the mode that the wrangle is set two. Definitely something to look into (also some more documentation would be nice haha).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...