[sharing] Knowing if a device is visible

    Max For Live

    Mattijs Kneppers
    Sep 18 2023 | 9:17 am
    Sometimes when a device has a CPU-intensive UI, it is useful to know whether the device is visible at all. If not, drawing can be turned off. Here is a script that does that.
    "use strict";
    
    /*
      Outputs a bang when it becomes visible. Only passes on incoming bangs when visible.
      Note that to be visible for a device in presentation mode, this object must be included in presentation.
    */
    
    mgraphics.init()
    
    function paint() {
      outlet(0, "bang")
    }
    
    function bang() {
      mgraphics.redraw()
    }
    Visiblebang test.zip
    application/zip 2.66 KB
    Here is an example of usage in a device.

    • 11OLSEN's icon
      11OLSEN
      Sep 18 2023 | 1:12 pm
      I also tried to find something to get visible state of a device in js. Only thing I found is that this.patcher.getattr('rect') reports 0 for x and y if device is hidden.. Using C sdk it's easy to detect (and observe) device visibillity.
      Share