Posts

Showing posts with the label python

convert string into a table of letters

 say you have a few words in a sentence or a bunch of words in a line (could be a very long line - I think this requires there to be no "returns" or "new lines" to work). Say you wanted to create a table of all the letters and spaces. This is one way to achieve it. Eg. Here are some words in a line. This might be displayed as a few lines because there are so many words, but there is no return or new line character. Your words will sit inside a text DAT, or some form of DAT. Lets say it's in a select DAT called "select1" Attach a Substitute DAT In the before parameter field, toggle the python option and enter: op('select1').text In the after field, enter : op('select1').text.replace("","/")[1:-1] The first bit of code is just taking your original text. The second is specifying what to replace, in our case it is putting a "/" after everything. The part in the square brackets is saying to start at the 1th lett...

using the CHOP EXECUTE DAT node - VALUE CHANGE

 Will make other posts as I learn how to use the other bits! use case - say you have a Count CHOP and wish to execute a set of instructions everytime the value changes, the CHOP Execute DAT node is what you want! Eg, take values from a NOISE and apply them to a TRANSFORM, everytime the Count changes value. This is a bit like sample/hold of random values. Create the CHOP EXECUTE DAT. Next type in the name of your Count node in the CHOPs box The part we're interested in is this segment of code- def onValueChange(channel, sampleIndex, val, prev):     return We can delete everything above that! Also make sure on the Chop Execute, that "Value Change" is set to ON. so after the colon, we can make some variables (this is for clarity, not necessary) def onValueChange(channel, sampleIndex, val, prev):          source=op('NOISE')     target=op('TRANSFORM')              target.par.tx=sourc...