Modifying CHOPs with a Wrangle on a Per Channel Basis

   1409   1   2
User Avatar
Member
12 posts
Joined: May 2015
Offline
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).



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).
Edited by Kubaki - Feb. 3, 2018 08:02:55

Attachments:
Peak Modification Example.jpg (1.3 MB)

User Avatar
Member
402 posts
Joined: June 2014
Offline
Hi,

had a pop at a setup that might do what you're after… see what you reckon.

Think you were on the right track from what you said - run over channels to be able to store a previous non-zero value and set a “sample” attribute to store that value. Then in another wrangle iterating over samples, write this value back out (you already found that we can't currently write out to a given sample when iterating over channels, this gets us round that). Remember that there are three different kinds of attibutes in CHOPs - “clip”, “channel” and “sample”, this may have been tangling you up.

Hope this helps!

Attachments:
chop_plateau_example.hip (31.8 KB)

Henry Dean
  • Quick Links