Slow cook on chop execute to table

Hello, maybe is something that I am missing out but I have a very slow cook on this type of chop execute into a table.
3,4 mseconds for 150 samples / three channels.
I attached the example project, any help would be appreciated.

testEXECUTE.3.toe (5.0 KB)

I also attached a bigger project that needs to send this values through udp on 30 ip adresses.
LEDUPDATE.19.toe (162.8 KB)

My specs are
ryzen 7 2700x 3.70Ghz
64 Gb RAM
Geforce 1080ti

Hey there!

I’m a big fan of this sort of work with Touch. I had a look at your files and can share a couple of thoughts. First off: If I’m just looking to get some CHOP channels into a DAT I usually reach for the ChopToDat operator. It’s pretty fast and generally a good starting point for solving these sort of things.
For your case because you’re working on sending this data out via udp send methods I’d start by coming up with some python that takes some chop data and spits it out as bytes. This would probably be more efficient then trying to loop through rows in a table

I took a swing at it and came up with something like the following:

some_chop = op('some_chop')
#this will only take 3 channels. we assume they're rgb

 to_send = [[int(some_chop[0][i]), int(some_chop[1][i]),int(some_chop[2][i])]
		for i in range(0,some_chop.numSamples)]

import itertools as it
flattened =  list(it.chain(*to_send))
print(len(flattened)) //should be 3 * numSamples
op("udpout1").sendBytes(bytes(flattened))

In your project I dropped this into the onCook method of a scriptOp but you could just as easily do it on a pulse or frameEnd depending on you optimization needs. The scriptOp solution has a cpuCook time of ~.5 millis on my machine

hope this helps

-d

LEDUPDATE_SCRIPT.toe (115.6 KB)

Final thought that occurs to me :
If you want to solve this same problem with less python and more CHOPs you could also use the shuffleCHOP to sequence your channels and then send them via UDP.

Might be a little simpler and arguably just as fast or faster depending on your implementations.

good luck and happy coding.

LEDUPDATE_SHUFFLE.toe (115.4 KB)

-d

Hi there ! I also found a solution which gave me ~4-6 millis. I will be back with an update of the method I ended up using and share it with the others. Thanks a lot !

Cool! Glad you figured something out!
Looking forward to seeing how you solved this problem.

-d