How to optimize the performance of a device with complex scripting and processing? Emmanuel Katto Uganda
Hi everyone, I am Emmanuel Katto. I'm building a Max for Live device that uses a combination of scripting and processing to generate complex audio patterns. However, I've noticed that the device is consuming a significant amount of CPU resources and can cause slowdowns or even crashes when used in a live performance setting. I'm looking for advice on how to optimize the performance of my device and make it more suitable for use in live shows.
Some potential areas to explore:
Are there any specific techniques or best practices for optimizing the performance of Max for Live devices?
How can I reduce the number of objects or messages being processed in my device?
Are there any specific optimizations that can be made to the scripting language used in Max for Live (e.g. JavaScript)?
Are there any specific processing techniques or algorithms that can be used to reduce the computational load on my device?
Are there any third-party libraries or plugins available that can help with performance optimization?
If anyone has experience with similar challenges, I'd love to hear your suggestions and advice on how to optimize my device's performance!
Best,
Emmanuel Katto
it is doubtful that any of this is actually causing your problem, but i will still try to answer your 5 generic questions:
1.) it highly depends on what you are doing, but the basic techniques are downsampling, removing unused GUI objects, avoiding high scheduler load, avoiding to switch between signal and data domain, organizing quality modes or number of polyphopny voices as dynamic as possible.
then - as for complex signal patches - you might move the code to gen~ or even to rnbo in order to export a compiled external.
2.) there are objects like [defer] and [deferlow] which can affect order and priority of messages, or [speedlim] which can thin out a stream of data. for all of them you really need to know what they actually do before you can add them to your code with success.
another thing you can do is to bundle many messges (which you need at the same time) into a list and then only send this list around and process the whole list as such wherever possible. as a result, the number of connections between objects will decrease.
3.) by not using them. javascript is about 50 times slower than sending messages in max.
4.) see 1.)
5.) not that i´d know of. there are a few higher level DSP objects which will of course less CPU than writing the same using basic objects, but they will also often be less flexible than your own code.
creating audio files or audio output from data can be a lot of fun, but you should not exaggerate the realtime use of such many messages.
maybe you re using message too long and would be better off going to signal domain at a point earlier than you currently do.
Thanks @Roman Thilenius..
>How can I reduce the number of objects or messages being processed in my device?
a few things to look for here:
are you using many "copies" of mechanisms?
if so, make abstractions and optimise THOSE. This saves you from having to move around and replace many instances, and instead you can work on ONE instance, and have that as your focus. It also increases your overview.
are you speaking more than you need to the scheduler?
in line with Roman's comment re defer/speedlim etc, you might optimise by focusing on gating and using [change] to prevent the system from being "distracted".
this also means that any objects downstream get relieved.
in regard to mfl, there are some objects that speak to the api at audio-rates, which are crazy fast for most thing.