How fast can I send my Max objects distinct messages?

Igneous Rock's icon

dear community,

I am trying to visualize what's going on in my M4L granular synth using NeoPixel LEDs. I have four strips of LEDs to correspond to four synths. I've gotten this to work beautifully with two synths/two strips of LEDs, but now that I up it to four, my LEDs are behaving erratically and my patch is crashing constantly.

I'm wondering: am I overloading my Max objects with data? Each of the 4 synths is sending data into my LED patch every 1 ms. All this nearly-simultaneous data is parsed through a single trigger objects at first, before being sent finally to a single set message object. So I'm wondering--can these modest Max objects handle packs of data coming at such speeds?

Simplified version of patch attached with notes.

Granular-Synthesis-Message-Overload.maxpat
Max Patch
Peter Castine's icon

Yes and no.

In theory you should never have to worry about the speed at which objects receive messages. In practice… most objects will still handle a message in the nanosecond ballpark. But some things take longer: drawing (screen updates) take longer and are handled in a different thread. MSP objects are off in their own thread and handle a lot more data than plain-vanilla Max objects; Jitter objects are typically handling even larger amounts of data and can need more time.

Eyeballing your patch, the two potential bottlenecks are the [serial] and Jitter objects. Have you tried hanging a jit.fpsgui under your jit.pwindow to see what sort of frame rates you're actually getting? Your metro is hammering away at 1000 bangs/sec, and I don't believe for a msec that you were getting frame rates anywhere near that.

I'd suggest watching the frame rate and adjusting your metro to something in that ballpark. A 9600bps serial port isn't going at that rate either.