-
Notifications
You must be signed in to change notification settings - Fork 12
Description
Thanks for the awesome asyncio-first library. Works really well.
I was able to get Grid + Arc consistently output at 30fps with ~90fps logic updates without stuttering. To achieve this, I had to switch from using GridBuffer and ArcBuffer which allocate the entire map every frame. Instead, I used a numpy array that I simply zeroed between frames, which is measurably faster.
To make this work, I had to make two changes:
-
Add
grid.led_level_map_rawandarc.ring_map_rawmethods that don't unpack*databut simply passdatadirectly to OSC. -
In
aiosc, I added support for numpy arrays inpack_messagewithout importing numpy by doing this:
elif type(arg).__module__ == 'numpy' and type(arg).__qualname__ == 'ndarray':
result += arg.tobytes()
dt = arg.dtype
if dt == '>i4':
tt = 'i' * arg.size
elif dt == '>f4':
tt = 'f' * arg.size
else:
raise NotImplementedError('Unsupported numpy ndarray dtype: ' + dt)
typetag += ttWith those changes, numpy arrays passed to the new methods allow reusing the same memory buffer and are very efficiently translated to bytes entirely in C land (with arg.tobytes() above).
Would you be interested in pull requests to upstream my changes?