Workload: multiple instances of same object or update one object frequently?

Simon Dawes's icon

Hi all,

I'm working on a project where I'll be sending 96 MIDI CC's from Max to a Teensy, to control the R/G/B channels of 32 LEDs.

The LEDs will be represented in 32 [bpatch] objects, each numbered ('addressed') 1-32.
Rather than number each R/G/B channel manually 0-95 I'm going to number them 0-2 in each [bpatch], then use the 'addresses' of the LEDs to multiply the R/G/Bs to cover all 96 CCs.

Where I'm unsure of myself and the reason I'm writing: is it better to have the same multiplication (et al) and [ctlout] objects in all 32 subpatches; or to have these only once in the master patch, then just the essentials in each subpatch?
The latter option (screenshot 1) would see the objects in the master patch getting absolutely hammered with updates, specially where multiple LEDs are changing colours at the same time. That sounds like more workload due to the constant tweaks to the objects. But I've read that every object and connection counts, and to cut down unnecessary double-ups wherever possible.

How would more experienced Maxers go about discerning the best method here?

Thanks for reading and thanks for any insights!

–Dawes

Screenshot 1 – too much work for the master patch multiplication and [ctlout] objects?

Screenshot 2 – too many repeats of the same objects in multiple subpatches?

11OLSEN's icon

I would go with option 2. Save everything for 1 led as a .maxpat file and load that in multiple bpatchers with the LED number as an argument.

Roman Thilenius's icon


multiplication for small integers is a good idea to encode them for targets, and the better alternative to "prepend/route".

but i think addition is even better - for readability. value 8 for target #3: 8 + 300.

107, 108, 308, ...

Source Audio's icon

I would pay more attention to avoid repeatedly sending unchanged values to Teensy,
and remove all not needed gui as well as print etc objects.

Max Patch
Copy patch and select New From Clipboard in Max.


Simon Dawes's icon

You're all legends, thanks so much for the help and ideas.

Can't do addition as numbers beyond 127 weren't transmitting between [ctlout] and the Teensy's Control Change read. But doing multiplication just as a one-off here as each LED and [ctlout] is initialised, I'm happy with that.

I'll probably do steps 1 and 2 once only, in the master patch, but then everything else is in the [bpatch] objects. Might go back to using one [ctlout] in each subpatch, will revisit in a few days. Feeling good about this for now!

Thanks again – Dawes

Source Audio's icon

decision to use midi CC is allready limiting a bit, forcing you to reduce resolution of color control.
But maybe it is fine enough for your use.
Another factor is speed, if you wanted higher than 0-127 resolution than it would double the data sent to
Teensy.
In that case I would drop CC and use sysex instead.
That reduces number of bytes needed from 8 to 5

sysex example: 240 (LED ID) LSB MSB 247
insead of 2 x CC
176 (CC LSB) $1 , 176 (CC MSB) $1
------
Or then use Teensy in Serial mode and send single value directly
needs LED ID and value only